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.
000
0
- adding001
1
- subtraction010
2
- multiplication011
3
- dividing100
4
- modulo101
5
- power110
6
- logarithm111
7
- absolute and factorial (first argument absolute, second factorial)
-
Status field - 4-bit field containing the transmission status.
0001
1
- a query0010
2
- the result of the operation0011
3
- general error0100
4
- error - the result is too big0101
5
- error - wrong status0110
6
- error - factorial too big0111
7
- error - division by 01000
8
- 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 -
int
variable size - 16-64 bits - first argument exists -
bool
- 1 bit - first argument length -
short unsigned int
- 8 bit - field of the first argument -
int
variable size - 16-64 bits - second argument exists -
bool
- 1 bit - second argument length -
short unsigned int
- 8 bit - field of the second argument -
int
variable 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 |