Simple protocol for CS studies on PUT
Features:
- connection-oriented,
- all data sent in binary form,
- 3-bit operation field,
- 4-bit status field,
- 32-bit data length field,
- variable-size data field,
- additional fields defined by the programmer, nested in the data field.
-
Operation field - 3-bit field containing information on one of 9 mathematical operations.
0000- adding0011- subtraction0102- multiplication0113- dividing1004- modulo1015- power1106- logarithm1117- absolute and factorial (first argument absolute, second factorial)
-
Status field - 4-bit field containing the transmission status.
00011- a query00102- the result of the operation00113- general error01004- error - the result is too big01015- error - wrong status01106- error - factorial too big01117- error - division by 010008- error - wrong logarithm base or argument
-
Data length field - a 32-bit field containing information about the length of the data field.
-
Data field - the field where the information is located:
- session exists -
bool- 1 bit - session length -
short unsigned int- 8 bit - session number field -
intvariable size - 16-64 bits - first argument exists -
bool- 1 bit - first argument length -
short unsigned int- 8 bit - field of the first argument -
intvariable size - 16-64 bits - second argument exists -
bool- 1 bit - second argument length -
short unsigned int- 8 bit - field of the second argument -
intvariable size - 16-64 bits
- session exists -
| length | field |
|---|---|
| 3 | operation |
| 4 | status |
| 32 | length |
| 1 | session field exists |
| 8 | session id length |
| 16-64 | session id |
| 1 | first field exists |
| 8 | first argument length |
| 16-64 | first argument |
| 1 | second field exists |
| 8 | second argument length |
| 16-64 | second argument |
| 0-8 | offset |