This project is part of a laboratory session. The task involves designing and implementing a custom communication protocol between a server and multiple clients.
The task involves the development of a communication protocol between a server and multiple clients, designed to facilitate basic arithmetic operations. The server acts as a computational engine that can perform three specific tasks: multiplication of signed integers, calculation of the average of integers, and subtraction of two sets of integers.
The server supports the following three operations:
-
Multiplication
- Multiplies
Nsigned integers. Nmust be between 2 and 10.- Each integer must be in the range -5 to 5.
- Returns a single integer as the product.
- Multiplies
-
Average
- Calculates the average of
Nunsigned integers. Nmust be between 2 and 20.- Each integer must be in the range 0 to 200.
- Returns a float or integer as the average result.
- Calculates the average of
-
Set Subtraction
- Accepts two sets of
Nunsigned integers. Nmust be between 2 and 10.- Each integer must be in the range 0 to 60000.
- Returns a new set of
Nintegers, where each value is the result of subtracting the corresponding value of the second set from the first.
- Accepts two sets of
- Sends a command to the server specifying the operation and the required input numbers.
- Receives:
- The result of the operation, or
- An error message describing the type of input validation failure (e.g., out-of-range values).
- Accepts multiple client connections simultaneously (multithreaded or multiprocessing based on lab session 3).
- Validates inputs and responds accordingly.
- Maintains communication using a custom protocol with structured headers and payloads.
- Executable Python code for the Server.
- Executable Python code for the Client.
- Number range examples:
- 1-byte unsigned = 0 to 255
- 2-byte unsigned = 0 to 65535
- 4-byte unsigned = 0 to 4294967295
- 1-byte signed = -128 to 127
- 2-byte signed = -32768 to 32767
- 4-byte signed = -2147483648 to 2147483647
You can test the application by running both the server and multiple clients. Inputs can be:
- Read from the keyboard
- Randomly generated using built-in Python functions
Course: Network Protocols
Institution: University of Piraeus
Let me know if you'd like to include a
.gitignoretemplate forvenvas well.