To achieve these expectations, we'll need to implement a reliable data transfer protocol over UDP with congestion control and flow control mechanisms. Here's an outline of how we can approach this:
-
Packet Structure: Define a packet structure that includes sequence numbers, acknowledgment numbers, checksums, and data payload.
-
Sender Implementation (
rsend):- Split the file into chunks.
- Implement a sliding window mechanism to control the number of unacknowledged packets.
- Use selective repeat ARQ (Automatic Repeat reQuest) to handle lost packets.
- Implement congestion control mechanisms like slow start and congestion avoidance using algorithms like TCP Tahoe or TCP Reno.
- Calculate and verify checksums for data integrity.
- Handle flow control based on receiver's acknowledgment window size.
- Send packets using UDP sockets.
-
Receiver Implementation (
rrecv):- Receive packets using UDP sockets.
- Implement a sliding window for receiving and buffering packets.
- Send acknowledgments for received packets and handle duplicate acknowledgments.
- Write received data to the destination file with consideration of the write rate limit.
- Signal the sender to adjust transmission rate based on flow control.
- Calculate and verify checksums for data integrity.
-
Main Functions:
- Implement main functions in sender.c and receiver.c to handle command-line arguments and invoke the data transfer operations.
-
Testing and Evaluation:
- Test the protocol under different network conditions, including dropped packets and varying bandwidth.
- Evaluate the protocol's performance against the provided expectations (E1-E8), ensuring fairness, throughput, and adherence to flow control.
In further detail:
Define a packet structure that includes fields for sequence number, acknowledgment number, checksum, and data payload.
struct Packet {
unsigned int seq_num;
unsigned int ack_num;
unsigned int checksum;
char data[MAX_DATA_SIZE];
};Here's an outline of steps to implement rsend:
- Read the file in chunks of a certain size.
- Maintain a sender window to control the number of unacknowledged packets.
- Update the window based on acknowledgments received.
- Retransmit packets that are not acknowledged within a certain timeout period.
- Implement slow start and congestion avoidance algorithms.
- Adjust the sender window size based on congestion signals.
- Monitor receiver's acknowledgment window size.
- Adjust transmission rate based on receiver's flow control signals.
- Send packets using UDP sockets.
Here's an outline of steps to implement rrecv:
- Receive packets using UDP sockets.
- Buffer received packets in a receive window.
- Send acknowledgments for received packets.
- Handle duplicate acknowledgments.
- Write received data to the destination file.
- Respect the write rate limit specified.
- Signal the sender to adjust transmission rate based on flow control.
- Receive packets and send acknowledgments using UDP sockets.
Implement main functions in sender.c and receiver.c to handle command-line arguments and invoke the data transfer operations.
Test the protocol under different network conditions, including dropped packets and varying bandwidth. Evaluate the protocol's performance against the provided expectations (E1-E8).