C OMPUTER NETWORKING HOMEWORK 2
UDP VS. TCP UDP Unreliable Unordered delivery No congestion control, flow control, connection setup TCP Reliable In-order delivery Congestion control Flow control Connection setup
T ARGET Implement TCP by UDP Socket programming
A RCHITECTURE (1/2) Implement programs File transmitter 1 program for both sender and receiver or 1 program for sender and 1 program for receiver are all permitted Agent File transmitter Reliable transmission on UDP Congestion control Agent Control loss rate
A RCHITECTURE (2/2) Sender A Receiver C Data1 Ack1 Agent B
R ELIABLE T RANSMISSION (1/3) Implement the program that… Works as sender and receiver Transmit files by UDP Guarantee reliability Retransmission Time out Sequence number Acknowledge
R ELIABLE T RANSMISSION (2/3) SenderReceiver Data1 Ack1
R ELIABLE T RANSMISSION (3/3) SenderReceiver Data1 Ack1
R EQUIREMENTS (1/4) Implement reliability on UDP socket Both DATA and ACK must be reliable and clearly distinguished The file received is exactly the same as it is sent
R EQUIREMENTS (2/4) ACK for acknowledgement FIN for closing the file transmission PSH for data transmission
R EQUIREMENTS (3/4) Data packet size : <=1KB File size : more than 0.5MB Time out : < 5sec.
R EQUIREMENTS (4/4) Sender and receiver shows message below send, receive, resend, time out, sequence number, DATA, ACK and FIN etc. Sender Receiver
A GENT (1/2) Implement an agent that… Drop packets randomly Show loss rate Parse packets and forward to the correct destination
A GENT (2/2) SA : A ; DA : BDATA : A → B SA : B ; DA : CDATA : B → C SA : C ; DA : BACK : C → B SA : B ; DA : AACK : B → A Sender A Receiver C Agent B Data1 Ack1
R EQUIREMENTS (1/2) Complete the agent Show the accumulated loss rate dropped DATA pkt / total DATA pkt Drop DATA packets only Do not drop ACK packets
R EQUIREMENTS (2/2) Sender, receiver and agent shows message below send, receive, resend, time out, sequence number, DATA, ACK and FIN etc. for file transmitter get, forward, drop, DATA, ACK, sequence number, loss rate, etc. Sender A Receiver C Agent B
C ONGESTION CONTROL (1/4) Implement congestion control on the transmitter with… Congestion window The number of packet you transmit Buffer for receiver Handling buffer overflow Slow start Threshold Packet loss Retransmission
C ONGESTION CONTROL (2/4) Slow start Send single packet in the beginning When below the threshold, congestion window increase exponentially until packet loss i.e. 1 → 2 → 4 → 8 → … When above the threshold, congestion window increase linearly until packet loss i.e. 16 → 17 → 18 → … Default threshold : 16 Default receiver buffer size : 32
C ONGESTION CONTROL (3/4)
C ONGESTION CONTROL (4/4) Buffer overflow Drop the packet Write to the file if buffer is full as well The following example is 4-buffer with default threshold 2 for demonstration only
4-B UFFER E XAMPLE (1/6) Sender Receiver buffer Sender send DATA 1 Congestion window = 1 threshold = 2 Receiver send ACK 1 1 Data1 Ack1
4-B UFFER E XAMPLE (2/6) Sender Receiver buffer Sender send DATA 2 & 3 Congestion window = 2 threshold = 2 Receiver send ACK 2 & Data2 Ack2 Data3 Ack3
4-B UFFER E XAMPLE (3/6) Sender Receiver buffer Sender send DATA 4 & 5 & 6 Congestion window = 3 (linear) threshold = 2 Receiver send ACK Data4 Ack4 Data5 Data6
4-B UFFER E XAMPLE (4/6) Sender Receiver buffer Receiver buffer overflow Drop DATA 5 & 6 Flush Data5 Data6
4-B UFFER E XAMPLE (5/6) Sender Receiver buffer Sender resend DATA 5 Congestion window = 1 threshold = 1 Receiver send ACK 5 5 Data5 Ack5
4-B UFFER E XAMPLE (6/6) Sender Receiver buffer Sender resend DATA 6 & send DATA 7 Congestion window = 2 threshold = 1 Receiver send ACK 6 & Data6 Ack6 Data7 Ack7
R EQUIREMENTS (1/2) Complete the transmitter with congestion control Show the accumulated loss rate, window size and threshold Drop DATA packets only Do not drop ACK packets
R EQUIREMENTS (2/2) Sender, receiver and agent shows message below Add ignore, drop, flush, window size, threshold, etc. Sender A Receiver C Agent B …
F ORMAT R EQUIREMENTS (1/2) Your program should be... Read data from file (i.e. file I/O) Correctly handles error responses The message must follow the format in the previous slide!!
F ORMAT R EQUIREMENTS (2/2) Naming b01902xxx_hw2_trans.c ( b01902xxx_hw2_send.c, b01902xxx_hw2_recv.c) b01902xxx_hw2_agent.c Compression tar -zcvf b01902xxx_hw2.tar.gz b01902xxx_hw2/ tar -zcvf b01902xxx_hw2_v2.tar.gz b01902xxx_hw2/ (new version) Upload server FTP server : voip.csie.org account/password : cn2014/cn2014
G RADING P OLICIES Reliable transmission - (20%) Agent - (25%) Congestion control - (25%) Clarity of your code (comments!) - (5%) Demo - (15%) Report - (10%) Execution instruction What you do, and how you do it Challenging issues and solutions
R EMINDERS Do not cheat! You cheat, you fail! Do not copy source codes from the Internet Read the spec carefully!! Ask TA if you have any question, except for debugging
D EADLINE Homework due 2014/12/12 23:59: Start your work as early as possible For late submission - 10% per day
HAPPY CODING AGAIN ^o^