X

Download Acknowledgements in TCP PowerPoint Presentation

SlidesFinder-Advertising-Design.jpg

Login   OR  Register
X


Iframe embed code :



Presentation url :

Home / Business & Management / Business & Management Presentations / Acknowledgements in TCP PowerPoint Presentation

Acknowledgements in TCP PowerPoint Presentation

Ppt Presentation Embed Code   Zoom Ppt Presentation

PowerPoint is the world's most popular presentation software which can let you create professional Acknowledgements in TCP powerpoint presentation easily and in no time. This helps you give your presentation on Acknowledgements in TCP in a conference, a school lecture, a business proposal, in a webinar and business and professional representations.

The uploader spent his/her valuable time to create this Acknowledgements in TCP powerpoint presentation slides, to share his/her useful content with the world. This ppt presentation uploaded by worldwideweb in Business & Management ppt presentation category is available for free download,and can be used according to your industries like finance, marketing, education, health and many more.

About This Presentation

Slide 1 - 1 TCP - Part II
Slide 2 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined
Slide 3 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK
Slide 4 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup
Slide 5 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5).
Slide 6 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes
Slide 7 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged
Slide 8 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK)
Slide 9 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet
Slide 10 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4
Slide 11 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements
Slide 12 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order
Slide 13 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70
Slide 14 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8
Slide 15 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available?
Slide 16 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled.
Slide 17 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK
Slide 18 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control
Slide 19 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window
Slide 20 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data
Slide 21 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8.
Slide 22 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4):
Slide 23 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application).
Slide 24 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used
Slide 25 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example
Slide 26 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control
Slide 27 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer?
Slide 28 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive
Slide 29 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer
Slide 30 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1
Slide 31 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff)
Slide 32 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer
Slide 33 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes.
Slide 34 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control
Slide 35 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network
Slide 36 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh
Slide 37 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential
Slide 38 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh
Slide 39 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged.
Slide 40 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh
Slide 41 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered
Slide 42 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1;
Slide 43 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe:
Slide 44 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: 44 Flavors of TCP Congestion Control TCP Tahoe (1988, FreeBSD 4.3 Tahoe) Slow Start Congestion Avoidance Fast Retransmit TCP Reno (1990, FreeBSD 4.3 Reno) Fast Recovery New Reno (1996) SACK (1996) RED (Floyd and Jacobson 1993)
Slide 45 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: 44 Flavors of TCP Congestion Control TCP Tahoe (1988, FreeBSD 4.3 Tahoe) Slow Start Congestion Avoidance Fast Retransmit TCP Reno (1990, FreeBSD 4.3 Reno) Fast Recovery New Reno (1996) SACK (1996) RED (Floyd and Jacobson 1993) 45 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) ACKs are not delayed when packets are received out of sequence Why? Lost segment
Slide 46 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: 44 Flavors of TCP Congestion Control TCP Tahoe (1988, FreeBSD 4.3 Tahoe) Slow Start Congestion Avoidance Fast Retransmit TCP Reno (1990, FreeBSD 4.3 Reno) Fast Recovery New Reno (1996) SACK (1996) RED (Floyd and Jacobson 1993) 45 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) ACKs are not delayed when packets are received out of sequence Why? Lost segment 46 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) Why? ACKs are not delayed when packets are received out of sequence Why? Out-of-order arrivals
Slide 47 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: 44 Flavors of TCP Congestion Control TCP Tahoe (1988, FreeBSD 4.3 Tahoe) Slow Start Congestion Avoidance Fast Retransmit TCP Reno (1990, FreeBSD 4.3 Reno) Fast Recovery New Reno (1996) SACK (1996) RED (Floyd and Jacobson 1993) 45 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) ACKs are not delayed when packets are received out of sequence Why? Lost segment 46 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) Why? ACKs are not delayed when packets are received out of sequence Why? Out-of-order arrivals 47 Fast Retransmit If three or more duplicate ACKs are received in a row, the TCP sender believes that a segment has been lost. Then TCP performs a retransmission of what seems to be the missing segment, without waiting for a timeout to happen. Enter slow start: ssthresh = cwnd/2 cwnd = 1
Slide 48 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: 44 Flavors of TCP Congestion Control TCP Tahoe (1988, FreeBSD 4.3 Tahoe) Slow Start Congestion Avoidance Fast Retransmit TCP Reno (1990, FreeBSD 4.3 Reno) Fast Recovery New Reno (1996) SACK (1996) RED (Floyd and Jacobson 1993) 45 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) ACKs are not delayed when packets are received out of sequence Why? Lost segment 46 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) Why? ACKs are not delayed when packets are received out of sequence Why? Out-of-order arrivals 47 Fast Retransmit If three or more duplicate ACKs are received in a row, the TCP sender believes that a segment has been lost. Then TCP performs a retransmission of what seems to be the missing segment, without waiting for a timeout to happen. Enter slow start: ssthresh = cwnd/2 cwnd = 1 48 Fast Recovery Fast recovery avoids slow start after a fast retransmit Intuition: Duplicate ACKs indicate that data is getting through After three duplicate ACKs set: Retransmit packet that is presumed lost ssthresh = cwnd/2 cwnd = cwnd+3 (note the order of operations) Increment cwnd by one for each additional duplicate ACK When ACK arrives that acknowledges “new data” (here: AckNo=6148), set: cwnd=ssthresh enter congestion avoidance
Slide 49 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: 44 Flavors of TCP Congestion Control TCP Tahoe (1988, FreeBSD 4.3 Tahoe) Slow Start Congestion Avoidance Fast Retransmit TCP Reno (1990, FreeBSD 4.3 Reno) Fast Recovery New Reno (1996) SACK (1996) RED (Floyd and Jacobson 1993) 45 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) ACKs are not delayed when packets are received out of sequence Why? Lost segment 46 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) Why? ACKs are not delayed when packets are received out of sequence Why? Out-of-order arrivals 47 Fast Retransmit If three or more duplicate ACKs are received in a row, the TCP sender believes that a segment has been lost. Then TCP performs a retransmission of what seems to be the missing segment, without waiting for a timeout to happen. Enter slow start: ssthresh = cwnd/2 cwnd = 1 48 Fast Recovery Fast recovery avoids slow start after a fast retransmit Intuition: Duplicate ACKs indicate that data is getting through After three duplicate ACKs set: Retransmit packet that is presumed lost ssthresh = cwnd/2 cwnd = cwnd+3 (note the order of operations) Increment cwnd by one for each additional duplicate ACK When ACK arrives that acknowledges “new data” (here: AckNo=6148), set: cwnd=ssthresh enter congestion avoidance 49 TCP Reno Duplicate ACKs: Fast retransmit Fast recovery  Fast Recovery avoids slow start Timeout: Retransmit Slow Start TCP Reno improves upon TCP Tahoe when a single packet is dropped in a round-trip time.
Slide 50 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: 44 Flavors of TCP Congestion Control TCP Tahoe (1988, FreeBSD 4.3 Tahoe) Slow Start Congestion Avoidance Fast Retransmit TCP Reno (1990, FreeBSD 4.3 Reno) Fast Recovery New Reno (1996) SACK (1996) RED (Floyd and Jacobson 1993) 45 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) ACKs are not delayed when packets are received out of sequence Why? Lost segment 46 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) Why? ACKs are not delayed when packets are received out of sequence Why? Out-of-order arrivals 47 Fast Retransmit If three or more duplicate ACKs are received in a row, the TCP sender believes that a segment has been lost. Then TCP performs a retransmission of what seems to be the missing segment, without waiting for a timeout to happen. Enter slow start: ssthresh = cwnd/2 cwnd = 1 48 Fast Recovery Fast recovery avoids slow start after a fast retransmit Intuition: Duplicate ACKs indicate that data is getting through After three duplicate ACKs set: Retransmit packet that is presumed lost ssthresh = cwnd/2 cwnd = cwnd+3 (note the order of operations) Increment cwnd by one for each additional duplicate ACK When ACK arrives that acknowledges “new data” (here: AckNo=6148), set: cwnd=ssthresh enter congestion avoidance 49 TCP Reno Duplicate ACKs: Fast retransmit Fast recovery  Fast Recovery avoids slow start Timeout: Retransmit Slow Start TCP Reno improves upon TCP Tahoe when a single packet is dropped in a round-trip time. 50 TCP Tahoe and TCP Reno (for single segment losses) Reno time cwnd time cwnd Taho
Slide 51 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: 44 Flavors of TCP Congestion Control TCP Tahoe (1988, FreeBSD 4.3 Tahoe) Slow Start Congestion Avoidance Fast Retransmit TCP Reno (1990, FreeBSD 4.3 Reno) Fast Recovery New Reno (1996) SACK (1996) RED (Floyd and Jacobson 1993) 45 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) ACKs are not delayed when packets are received out of sequence Why? Lost segment 46 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) Why? ACKs are not delayed when packets are received out of sequence Why? Out-of-order arrivals 47 Fast Retransmit If three or more duplicate ACKs are received in a row, the TCP sender believes that a segment has been lost. Then TCP performs a retransmission of what seems to be the missing segment, without waiting for a timeout to happen. Enter slow start: ssthresh = cwnd/2 cwnd = 1 48 Fast Recovery Fast recovery avoids slow start after a fast retransmit Intuition: Duplicate ACKs indicate that data is getting through After three duplicate ACKs set: Retransmit packet that is presumed lost ssthresh = cwnd/2 cwnd = cwnd+3 (note the order of operations) Increment cwnd by one for each additional duplicate ACK When ACK arrives that acknowledges “new data” (here: AckNo=6148), set: cwnd=ssthresh enter congestion avoidance 49 TCP Reno Duplicate ACKs: Fast retransmit Fast recovery  Fast Recovery avoids slow start Timeout: Retransmit Slow Start TCP Reno improves upon TCP Tahoe when a single packet is dropped in a round-trip time. 50 TCP Tahoe and TCP Reno (for single segment losses) Reno time cwnd time cwnd Taho 51 TCP New Reno When multiple packets are dropped, Reno has problems Partial ACK: Occurs when multiple packets are lost A partial ACK acknowledges some, but not all packets that are outstanding at the start of a fast recovery, takes sender out of fast recovery Sender has to wait until timeout occurs New Reno: Partial ACK does not take sender out of fast recovery Partial ACK causes retransmission of the segment following the acknowledged segment New Reno can deal with multiple lost segments without going to slow start
Slide 52 - 1 TCP - Part II 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information Error Control: Algorithms to recover or conceal the effects from packet losses Congestion Control: Algorithms to prevent that the sender overloads the network  The goal of each of the control mechanisms are different.  In TCP, the implementation of these algorithms is combined 3 Acknowledgements in TCP TCP receivers use acknowledgments (ACKs) to confirm the receipt of data to the sender Acknowledgment can be added (“piggybacked”) to a data segment that carries data in the opposite direction ACK information is included in the the TCP header Acknowledgements are used for flow control, error control, and congestion control Data for B A B Data for A ACK ACK 4 Sequence Numbers and Acknowledgments in TCP TCP uses sequence numbers to keep track of transmitted and acknowledged data Each transmitted byte of payload data is associated with a sequence number Sequence numbers count bytes and not segments Sequence number of first byte in payload is written in SeqNo field Sequence numbers wrap when they reach 232-1 The sequence number of the first sequence number (Initial sequence number) is negotiated during connection setup 5 Sequence Numbers and Acknowledgments in TCP An acknowledgment is a confirmation of delivery of data When a TCP receiver wants to acknowledge data, it writes a sequence number in the AckNo field, and sets the ACK flag IMPORTANT: An acknowledgment confirms receipt for all unacknowledged data that has a smaller sequence number than given in the AckNo field Example: AckNo=5 confirms delivery for 1,2,3,4 (but not 5). 6 Cumulative Acknowledgements SeqNo=0 10 bytes TCP has cumulative acknowledgements: An acknowledgment confirms the receipt of all unacknowledged data with a smaller sequence number A B SeqNo=10 10 bytes ACK 10 ACK 20 ACK 40 ACK 70 ACK 100 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes SeqNo=90 10 bytes 7 Cumulative Acknowledgements With cumulative ACKs, the receiver can only acknowledge a segment if all previous segments have been received With cumulative ACKs, receiver cannot selectively acknowledge blocks of segments: e.g., ACK for S0-S3 and S5-S7 (but not for S4) Note: The use of cumulative ACKs imposes constraints on the retransmission schemes: In case of an error, the sender may need to retransmit all data that has not been acknowledged 8 Rules for sending Acknowledgments TCP has rules that influence the transmission of acknowledgments Rule 1: Delayed Acknowledgments Goal: Avoid sending ACK segments that do not carry data Implementation: Delay the transmission of (some) ACKs Rule 2: Nagle’s rule Goal: Reduce transmission of small segments Implementation: A sender cannot send multiple segments with a 1-byte payload (i.e., it must wait for an ACK) 9 Observing Delayed Acknowledgements Remote terminal applications (e.g., Telnet) send characters to a server. The server interprets the character and sends the output at the server to the client. For each character typed, you see three packets: Client  Server: Send typed character Server  Client: Echo of character (or user output) and acknowledgement for first packet Client  Server: Acknowledgement for second packet 10 Observing Delayed Acknowledgements This is the output of typing 3 (three) characters : Time 44.062449: Argon  Neon: Push, SeqNo 0:1(1), AckNo 1 Time 44.063317: Neon  Argon: Push, SeqNo 1:2(1), AckNo 1 Time 44.182705: Argon  Neon: No Data, AckNo 2 Time 48.946471: Argon  Neon: Push, SeqNo 1:2(1), AckNo 2 Time 48.947326: Neon  Argon: Push, SeqNo 2:3(1), AckNo 2 Time 48.982786: Argon  Neon: No Data, AckNo 3 Time 55.116581: Argon  Neon: Push, SeqNo 2:3(1) AckNo 3 Time 55.117497: Neon  Argon: Push, SeqNo 3:4(1) AckNo 3 Time 55.183694: Argon  Neon: No Data, AckNo 4 11 Why 3 segments per character? We would expect four segments per character: But we only see three segments per character: This is due to delayed acknowledgements 12 Delayed Acknowledgement TCP delays transmission of ACKs for up to 200ms Goal: Avoid to send ACK packets that do not carry data. The hope is that, within the delay, the receiver will have data ready to be sent to the receiver. Then, the ACK can be piggybacked with a data segment In Example: Delayed ACK explains why the “ACK of character” and the “echo of character” are sent in the same segment The duration of delayed ACKs can be observed in the example when Argon sends ACKs Exceptions: ACK should be sent for every second full sized segment Delayed ACK is not used when packets arrive out of order 13 Because of delayed ACKs, an ACK is often observed for every other segment Delayed Acknowledgement SeqNo=0 10 bytes A B SeqNo=10 10 bytes ACK 20 ACK 40 ACK 50 ACK 90 SeqNo=20 10 bytes SeqNo=30 10 bytes SeqNo=40 10 bytes SeqNo=50 10 bytes SeqNo=60 10 bytes SeqNo=70 10 bytes SeqNo=80 10 bytes ACK 70 14 Observing Nagle’s Rule This is the output of typing 7 characters : Time 16.401963: Argon  Tenet: Push, SeqNo 1:2(1), AckNo 2 Time 16.481929: Tenet  Argon: Push, SeqNo 2:3(1) , AckNo 2 Time 16.482154: Argon  Tenet: Push, SeqNo 2:3(1) , AckNo 3 Time 16.559447: Tenet  Argon: Push, SeqNo 3:4(1), AckNo 3 Time 16.559684: Argon  Tenet: Push, SeqNo 3:4(1), AckNo 4 Time 16.640508: Tenet  Argon: Push, SeqNo 4:5(1) AckNo 4 Time 16.640761: Argon  Tenet: Push, SeqNo 4:8(4) AckNo 5 Time 16.728402: Tenet  Argon: Push, SeqNo 5:9(4) AckNo 8 15 Observing Nagle’s Rule Observation: Transmission of segments follows a different pattern, i.e., there are only two segments per character typed Delayed acknowledgment does not kick in at Argon The reason is that there is always data at Argon ready to sent when the ACK arrives Why is Argon not sending the data (typed character) as soon as it is available? 16 Observing Nagle’s Rule Observations: Argon never has multiple unacknowledged segments outstanding There are fewer transmissions than there are characters. This is due to Nagle’s Rule: Each TCP connection can have only one small (1-byte) segment outstanding that has not been acknowledged Implementation: Send one byte and buffer all subsequent bytes until acknowledgement is received.Then send all buffered bytes in a single segment. (Only enforced if byte is arriving from application one byte at a time) Goal of Nagle’s Rule: Reduce the amount of small segments. The algorithm can be disabled. 17 ACK 1 SeqNo=0, 1 byte Only one 1-byte segment can be in transmission (Here: Since no data is sent from B to A, we also see delayed ACKs) A B ACK 5 SeqNo=5, 5 byte SeqNo=1, 4 byte Nagle’s Rule Typed characters Delayed ACK Delayed ACK ACK 10 Delayed ACK 18 TCP Flow Control 19 TCP Flow Control TCP uses a version of the sliding window flow control, where Sending acknowledgements is separated from setting the window size at sender Acknowledgements do not automatically increase the window size During connection establishment, both ends of a TCP connection set the initial size of the sliding window 20 Window Management in TCP The receiver is returning two parameters to the sender The interpretation is: I am ready to receive new data with SeqNo= AckNo, AckNo+1, …., AckNo+Win-1 Receiver can acknowledge data without opening the window Receiver can change the window size without acknowledging data 21 Sliding Window Flow Control Sliding Window Protocol is performed at the byte level: Here: Sender can transmit sequence numbers 6,7,8. 22 Sliding Window: “Window Closes” Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4): 23 Sliding Window: “Window Opens” Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6): A receiver opens a window when TCP buffer empties (meaning that data is delivered to the application). 24 Sliding Window: “Window Shrinks” Acknowledgement is received that reduces the window from the right (AckNo = 5, Win=3): Shrinking a window should not be used 25 Sliding Window: Example 26 TCP Error Control 27 Error Control in TCP TCP maintains a Retransmission Timer for each connection: The timer is started during a transmission. A timeout causes a retransmission TCP couples error control and congestion control (i.e., it assumes that errors are caused by congestion) Retransmission mechanism is part of congestion control algorithm Here: How to set the timeout value of the retransmission timer? 28 TCP Retransmission Timer Retransmission Timer: The setting of the retransmission timer is crucial for efficiency Timeout value too small  results in unnecessary retransmissions Timeout value too large  long waiting time before a retransmission can be issued A problem is that the delays in the network are not fixed Therefore, the retransmission timers must be adaptive 29 Round-Trip Time Measurements The retransmission mechanism of TCP is adaptive The retransmission timers are set based on round-trip time (RTT) measurements that TCP performs The RTT is based on time difference between segment transmission and ACK But: TCP does not ACK each segment Each connection has only one timer 30 Round-Trip Time Measurements Retransmission timer is set to a Retransmission Timeout (RTO) value. RTO is calculated based on the RTT measurements. The RTT measurements are smoothed by the following estimators srtt and rttvar: srttn+1 = a RTT + (1- a ) srttn rttvarn+1 = b ( | RTT - srttn+1 | ) + (1- b ) rttvarn RTOn+1 = srttn+1 + 4 rttvarn+1 The gains are set to a =1/4 and b =1/8 srtt0 = 0 sec, rttvar0 = 3 sec, Also: RTO1 = srtt1 + 2 rttvar1 31 Karn’s Algorithm If an ACK for a retransmitted segment is received, the sender cannot tell if the ACK belongs to the original or the retransmission. Karn’s Algorithm: Don’t update srtt on any segments that have been retransmitted. Each time when TCP retransmits, it sets: RTOn+1 = max ( 2 RTOn, 64) (exponential backoff) 32 Measuring TCP Retransmission Timers Transfer file from ellington to satchmo Unplug Ethernet cable in the middle of file transfer 33 Exponential Backoff Scenario: File transfer between two machines. Disconnect cable. The interval between retransmission attempts in seconds is: 1.03, 3, 6, 12, 24, 48, 64, 64, 64, 64, 64, 64, 64. Time between retrans-missions is doubled each time (Exponential Backoff Algorithm) Timer is not increased beyond 64 seconds TCP gives up after 13th attempt and 9 minutes. 34 TCP Congestion Control 35 TCP Congestion Control TCP has a mechanism for congestion control. The mechanism is implemented at the sender The window size at the sender is set as follows: Send Window = MIN (flow control window, congestion window) where flow control window is advertised by the receiver congestion window is adjusted based on feedback from the network 36 TCP Congestion Control TCP congestion control is governed by two parameters: Congestion Window (cwnd) Slow-start threshhold Value (ssthresh) Initial value is 216-1 Congestion control works in two modes: slow start (cwnd < ssthresh) congestion avoidance (cwnd ≥ ssthresh 37 Slow Start Initial value: Set cwnd = 1 Note: Unit is a segment size. TCP actually is based on bytes and increments by 1 MSS (maximum segment size) The receiver sends an acknowledgement (ACK) for each Segment Note: Generally, a TCP receiver sends an ACK for every other segment. Each time an ACK is received by the sender, the congestion window is increased by 1 segment: cwnd = cwnd + 1 If an ACK acknowledges two segments, cwnd is still increased by only 1 segment. Even if ACK acknowledges a segment that is smaller than MSS bytes long, cwnd is increased by 1. Does Slow Start increment slowly? Not really. In fact, the increase of cwnd is exponential 38 Slow Start Example The congestion window size grows very rapidly For every ACK, we increase cwnd by 1 irrespective of the number of segments ACK’ed TCP slows down the increase of cwnd when cwnd > ssthresh 39 Congestion Avoidance Congestion avoidance phase is started if cwnd has reached the slow-start threshold value If cwnd ≥ ssthresh then each time an ACK is received, increment cwnd as follows: cwnd = cwnd + 1/ cwnd So cwnd is increased by one only if all cwnd segments have been acknowledged. 40 Example of Slow Start/Congestion Avoidance Assume that ssthresh = 8 Roundtrip times Cwnd (in segments) ssthresh 41 Responses to Congestion So, TCP assumes there is congestion if it detects a packet loss A TCP sender can detect lost packets via: Timeout of a retransmission timer Receipt of a duplicate ACK TCP interprets a Timeout as a binary congestion signal. When a timeout occurs, the sender performs: cwnd is reset to one: cwnd = 1 ssthresh is set to half the current size of the congestion window: ssthressh = cwnd / 2 and slow-start is entered 42 Summary of TCP congestion control Initially: cwnd = 1; ssthresh = advertised window size; New Ack received: if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd; Timeout: /* Multiplicative decrease */ ssthresh = cwnd/2; cwnd = 1; 43 Slow Start / Congestion Avoidance A typical plot of cwnd for a TCP connection (MSS = 1500 bytes) with TCP Tahoe: 44 Flavors of TCP Congestion Control TCP Tahoe (1988, FreeBSD 4.3 Tahoe) Slow Start Congestion Avoidance Fast Retransmit TCP Reno (1990, FreeBSD 4.3 Reno) Fast Recovery New Reno (1996) SACK (1996) RED (Floyd and Jacobson 1993) 45 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) ACKs are not delayed when packets are received out of sequence Why? Lost segment 46 Acknowledgments in TCP Receiver sends ACK to sender ACK is used for flow control, error control, and congestion control ACK number sent is the next sequence number expected Delayed ACK: TCP receiver normally delays transmission of an ACK (for about 200ms) Why? ACKs are not delayed when packets are received out of sequence Why? Out-of-order arrivals 47 Fast Retransmit If three or more duplicate ACKs are received in a row, the TCP sender believes that a segment has been lost. Then TCP performs a retransmission of what seems to be the missing segment, without waiting for a timeout to happen. Enter slow start: ssthresh = cwnd/2 cwnd = 1 48 Fast Recovery Fast recovery avoids slow start after a fast retransmit Intuition: Duplicate ACKs indicate that data is getting through After three duplicate ACKs set: Retransmit packet that is presumed lost ssthresh = cwnd/2 cwnd = cwnd+3 (note the order of operations) Increment cwnd by one for each additional duplicate ACK When ACK arrives that acknowledges “new data” (here: AckNo=6148), set: cwnd=ssthresh enter congestion avoidance 49 TCP Reno Duplicate ACKs: Fast retransmit Fast recovery  Fast Recovery avoids slow start Timeout: Retransmit Slow Start TCP Reno improves upon TCP Tahoe when a single packet is dropped in a round-trip time. 50 TCP Tahoe and TCP Reno (for single segment losses) Reno time cwnd time cwnd Taho 51 TCP New Reno When multiple packets are dropped, Reno has problems Partial ACK: Occurs when multiple packets are lost A partial ACK acknowledges some, but not all packets that are outstanding at the start of a fast recovery, takes sender out of fast recovery Sender has to wait until timeout occurs New Reno: Partial ACK does not take sender out of fast recovery Partial ACK causes retransmission of the segment following the acknowledged segment New Reno can deal with multiple lost segments without going to slow start 52 SACK SACK = Selective acknowledgment Issue: Reno and New Reno retransmit at most 1 lost packet per round trip time Selective acknowledgments: The receiver can acknowledge non-continuous blocks of data (SACK 0-1023, 1024-2047) Multiple blocks can be sent in a single segment. TCP SACK: Enters fast recovery upon 3 duplicate ACKs Sender keeps track of SACKs and infers if segments are lost. Sender retransmits the next segment from the list of segments that are deemed lost.