This project implements an unreliable chat client that connects to a server of which the code is also created to send and receive messages. The client uses error-checking algorithms such as checksum and sequencing to ensure message integrity. It also supports various protocol commands to manipulate connections, including setting burst values, delay, and bit flips.
- Checksum for Error Checking: Adds and verifies checksums to detect message corruption.
- Sequencing: Ensures that messages are received in the correct order.
- Protocol Commands: Supports commands for manipulating connections, including setting drop rate, flip rate, burst value, and delay.
- User Management: Allows users to log in with a unique username, checks for username availability, and lists online users.
- Python 3.x
socket
library (standard library)threading
library (standard library)math
library (standard library)time
library (standard library)re
library (standard library)queue
library (standard library)binascii
library (standard library)
-
Running the Server:
- Adjust the IP Address and port to your needs.
- Ensure the port is free in order to run the server.
-
Running the Client:
- Ensure the server is running and accessible.
- Ensure the client uses the correct server address and port.
- Run the client script:
python3 chat_client.py
.
-
Logging In:
- Enter a unique username when prompted.
- If the username is in use or contains disallowed characters, you will be prompted to enter a different username.
-
Sending Messages:
- To send a message to a user:
@username message
- To see who is online:
!who
(Currently the implementation for adjusting the server values to manually create network circumstances is not finished yet) - To reset the server values:
!reset
- To get the value of a setting:
!get SETTING_NAME
- To set the value of a setting:
!set SETTING_NAME value
- To send a message to a user:
-
Quitting:
- To quit the client:
!quit
- To quit the client:
- Checksum Errors: If a message fails checksum verification, an error message is sent back to the sender.
- Unknown Commands: If an unknown command is received, an appropriate error message is displayed.
!quit
: Quit the chat client.!who
: List all online users.!reset
: Reset server settings.!get [SETTING]
: Get the value of a server setting.!set [SETTING] [VALUE]
: Set the value of a server setting. Valid settings includeDROP
,FLIP
,BURST
,DELAY
,BURST-LEN
, andDELAY-LEN
.
- HELLO-FROM username: Login request.
- HELLO username: Login acknowledgment.
- IN-USE: Username already in use.
- BUSY: Server is full.
- SEND username message: Send a message to a user.
- DELIVERY username message: Deliver a message to the client.
- ERROR: Indicate an error in message delivery.
- ACK: Acknowledge receipt of a message.
- LIST: Request list of online users.
- LIST-OK user1,user2,...: List of online users.
- SET parameter value: Set server parameter.
- SET-OK: Acknowledge setting change.
- GET parameter: Get server parameter value.
- VALUE parameter value: Return server parameter value.
- Checksum: Calculated by dividing the message into 4 parts, summing the binary values, and flipping the bits of the result.
- Sequencing: Uses sequence numbers to ensure messages are processed in the correct order.
- Multithreading: Uses separate threads for sending and receiving messages to handle concurrency.
- Error Handling: Checks for message integrity using checksums and sequence numbers, and handles various protocol errors.
This project is licensed under the Apache 2.0 License.