Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS4470 Computer Networking Protocols

Similar presentations


Presentation on theme: "CS4470 Computer Networking Protocols"— Presentation transcript:

1 CS4470 Computer Networking Protocols
1/1/2019 CS Computer Networking Protocols 15. TCP 2 Huiping Guo Department of Computer Science California State University, Los Angeles

2 Outline Principles of reliable transfer Stop and wait Go back N
1/1/2019 Outline Principles of reliable transfer Stop and wait Go back N 15. TCP CS4470

3 Principles of reliable transfer
Errors A segment is corrupted A segment is lost Automatic retransmission request (ARQ) When errors occur, the receiver sends a message to the sender asking for retransmission Types of ARQ Stop and wait Sliding window (Go back N) 15. TCP CS4470

4 A trivial reliable transfer protocol
Assumption A segment may be corrupted. NO segment gets lost Sender Sends a segment Waits for the acknowledgement for the segment If the acknowledgement is positive Sends the next segment If the acknowledgement is negative Resends the segment 15. TCP CS4470

5 A trivial reliable transfer protocol
Receiver Receives a segment Is the segment corrupted? Yes. Sends a negative acknowledgement (NAK) asking for retransmission No. Sends a positive acknowledgement (ACK). Waits for the next segment 15. TCP CS4470

6 Problems with this protocol
What happens if ACK/NAK is corrupted? sender doesn’t know what happened at receiver! A possible approach The sender just simply resends the segment . This causes possible duplicate segments The receiver cannot tell whether the received segment is the re-transmitted segment or a new segment A solution to this problem Add a field sequence number(1 bit) to the segment header The receiver only need to check the sequence number to determine whether or not the received segment is a retransmission. 15. TCP CS4470

7 Stop-and-Wait Protocol v1
Characteristics Use 1 bit sequence number A NAK free protocol The receiver always sends positive acknowledgements ACK0: Seg1 is correctly received, waiting for seg 0 ACK1: Seg0 is correctly received, waiting for seg 1 15. TCP CS4470

8 Stop-and-Wait Protocol v1(cont.)
Sender: Sender keeps track of the sequence number k (0,1) of the current segment being sent out Sender sends out a segment k If the sender receives ACK k, go to step 1 If the sender receives ACK k+1 , k=k+1 mod 2, go to step 1 15. TCP CS4470

9 Stop-and-Wait Protocol v1 (cont.)
Receiver: keeps track of the sequence number of(0, 1) of the next expected segment Receiver is expecting segment k Receiver receives a segment . If the sequence number of the segment is not k, discards the segment , sends ack k, go to step 1 If sequence number is k and the segment is OK, sends ACK k=k+1 mod 2 to the sender, go to step 1 If segment k is corrupted, sends ACK k Go to step 1 15. TCP CS4470

10 Stop-and-Wait v1 Examples
Sender Receiver seg0 Sends seg0 Receives ack1 Sends seg1 seg1 ACK 0 ACK 1 Receives ack0 Receives seg0 Sends ack1 Receives seg1 Sends ack0 a. Without erros Sender Receiver seg0 Sends seg0 Receives seg0 Sends ack1 ACK 1 seg1 Receives ack1 Sends seg1 Receives seg1 Seg1 has errors Sends ack1 ACK 1 seg1 Receives ack1 resends seg1 b. With a seg corrupted 15. TCP CS4470

11 Stop-and-Wait v1 Examples (cont.)
Sender Receiver seg0 Sends seg0 Receives seg0 Sends ack1 ACK 1 seg1 Receives ack1 Sends seg1 Receives seg1 Sends ack0 ACK 0 Ack0 is corrupted resends seg1 seg1 Receives seg1, discards it Sends ack0 ACK 0 c. With an ack corrupted 15. TCP CS4470

12 Stop-and-Wait Protocol v2
Stop-and-wait protocol v1 only works if there is no data loss. What if there is data loss? A segment may be lost An ACK may be lost Stop-and-wait protocol v2 Works with data errors AND data loss 15. TCP CS4470

13 Stop-and-Wait Protocol v2 (cont.)
Approach: sender waits “reasonable” amount of time for ACK retransmits if no ACK received in this time if segments(or ACKs) are just delayed (not lost): retransmission will be duplicate, but use of seq. #’s already handles this receiver must specify seq # of seg being ACKed requires countdown timer 15. TCP CS4470

14 Stop-and-Wait examples
Sender Receiver Sender Receiver seg0 Sends seg0 Receives ack1 Sends seg1 seg1 ACK 0 ACK 1 Receives ack0 Receives seg0 Sends ack1 Receives seg1 Sends ack0 a. Without errors seg0 Sends seg0 Receives seg0 Sends ack1 ACK 1 seg1 Receives ack1 Sends seg1 X loss seg1 timeout resends seg1 Receives seg1 Sends ack0 b. segment loss 15. TCP CS4470

15 Stop-and-Wait examples
Sender Receiver Sender Receiver seg0 Sends seg0 Receives seg0 Sends ack1 seg0 Sends seg0 ACK 1 Receives seg0 Sends ack1 ACK 1 seg1 Receives ack1 Sends seg1 Receives seg1 Sends ack0 seg1 Receives ack1 Sends seg1 Receives seg1 Sends ack0 ACK 0 ACK 0 lost Timeout Resends seg1 seg1 Receives seg1 Discards it Sends ack0 Receives ack0 Sends seg0 seg0 seg1 timeout Resends seg1 ACK 0 Receives ack0 Resends seg0 Receives seg0 Sends ack1 Receives seg1 Sends ack0 ACK 1 seg0 ACK 0 Receives ack1 Sends seg1 seg1 Receives seg0 Sends ack1 c. Ack loss d. Premature timeout 15. TCP CS4470

16 Pros and Cons of Stop-and-wait
Stop-and-wait is a complete reliable transfer protocol It’s very simple Cons Inefficient While the sender is waiting for an ACK, it doesn’t do anything. Why not the sender sends multiple segments at a time? Need more than 1 bits for the sequence number. 15. TCP CS4470

17 RTT and transmission delay
1/1/2019 RTT and transmission delay Definition of RTT: time to send a small segment to travel from sender to receiver and back. Transmission delay R=link bandwidth (bps) L=segment length (bits) time to send bits into link = L/R Total delay RTT+L/R 15. TCP CS4470

18 RTT and transmission delay
first segment bit transmitted, t = 0 first segment bit arrives RTT ACK arrives, send next segment, t = RTT + L / R 15. TCP CS4470

19 Performance of stop-and-wait
sender receiver first segment bit transmitted, t = 0 last packet bit transmitted, t = L / R first segment bit arrives RTT last packet bit arrives, send ACK ACK arrives, send next segment, t = RTT + L / R 15. TCP CS4470

20 Increased utilization
first segment bit transmitted, t = 0 sender receiver RTT last bit transmitted, t = L / R first segment bit arrives last segment bit arrives, send ACK ACK arrives, send next segment, t = RTT + L / R last bit of 2nd segment arrives, send ACK last bit of 3rd frame arrives, send ACK Increase utilization by a factor of 3! 15. TCP CS4470

21 Go-Back-N Based on a sliding window
Use window to control number of segments to send Number of segments that the sender can send N-(nextseqnum – send_base) 15. TCP CS4470

22 Go-Back-N Cumulative ACKs
ACK (n): ACKs all segments up to, including seq # n - 1 Timer Only one timer is used. The timer is for the oldest transmitted, yet un-acked segment 15. TCP CS4470

23 Go-back-N: sender Needs to send segments
If the window is full, wait until it’s not full If the window is not full, sends out as many segment as allowed, adjusts nextsegnum Receive an ACK for un-acked segments Slide the window forward by the number of acked segments Start the timer Adjust send_base Timerout Re-transmit all un-acked segments in the window 15. TCP CS4470

24 Go-back-N: receiver Waits for seg k Receives seg k, sends ack k+1
Receives, seg k+1, discards it and sends ack k Receives seg k-1, discards it and sends ack k 15. TCP CS4470

25 Go-back-N example The window size is 4 ACK1 ACK2 ACK3 ACK4
15. TCP CS4470

26 1/1/2019 Exercise Consider a sender sends  7 segments to  a receiver. The RTT between the sender and the receiver is 2ms.  The transmission time of each segment is 0.2ms. The timeout value is 3 ms.  In  each of the following cases, how long does it take for sender to transfer the 7 segments? (time between sending out the first segment   and receiving the ack of the last segment). a) Stop-and-wait protocol is used. b) Go-Back-N protocol is used.   The window size is 4. The 2nd  and the 5th segment are lost during the first transmission. For each case, draw a diagram that shows the interaction between the sender and receiver. You also need to provide the information about which segment is sent and the ACK number. 15. TCP CS4470

27 For each segment, it takes 2+0. 2=2
For each segment, it takes 2+0.2=2.2 to send and receive the ack,  so the total time is 7x2.2 =15.4ms 15. TCP CS4470

28 15. TCP CS4470


Download ppt "CS4470 Computer Networking Protocols"

Similar presentations


Ads by Google