Chair of Network Architectures and Services Department of Informatics Technical University of Munich iLab X Transport Layer Dominik Scholz scholz@net.in.tum.de Chair of Network Architectures and Services Department of Informatics Technical University of Munich SoSe 2019
Outline Transport Layer UDP TCP Other Transport Layer Protocols 1/39
Outline Transport Layer UDP TCP Other Transport Layer Protocols 2/39
Transport Layer application protocol app 2 app 2 application protocol app 1 app 1 app 1 app 1 transport protocol TCP/UDP TCP/UDP router IP protocol IP protocol IP IP IP Ethernet WLAN Ethernet Ethernet WLAN WLAN protocol protocol driver driver driver driver wireless LAN Ethernet 3/39
Ports • purpose: transport layer multiplexing / demultiplexing • 16bit number (0..65535) • address applications on a host Client/Server communication • client-side: usually random choice from [1024..65535] • server-side: well known port numbers Well-known port numbers • HTTP/HTTPS: TCP port 80/443 • SSH: TCP port 22 • DNS: UDP and TCP port 53 see: http://www.iana.org/assignments/port-numbers 4/39
Sockets application layer API to networking functionality usually offered by the OS network stack Message Orientation sender receiver send(“Hi Bob!”) recv() -> “Hi Bob!” send(“How are you?”) recv() -> “How are you?” Stream Orientation sender receiver (possible outcome) send(“Hi Bob!”) recv() -> “” send(“How are you?”) recv() -> “Hi Bob!How are you?” 5/39
Transport Protocol Implementations User Datagram Protocol (UDP) • unreliable • lightweight Transmission Control Protocol (TCP) • reliable • connection oriented • sending-rate limitation Other • Stream Control Transmission Protocol (SCTP) • Multipath TCP (MTCP) • Quick UDP Internet Connections (QUIC) 6/39
Outline Transport Layer UDP TCP Other Transport Layer Protocols 7/39
User Datagram Protocol (UDP) 0 15 16 31 source port destination port length checksum Functions • port multiplexing / demultiplexing • error checking Example Applications • DNS (port 53) • RIP (port 520) • media streaming / realtime communication 8/39
User Datagram Protocol (UDP) 0 15 16 31 source port destination port length checksum Functions • port multiplexing / demultiplexing • error checking Example Applications • DNS (port 53) • RIP (port 520) • media streaming / realtime communication Why is UDP used for these applications? 8/39
UDP Summary Characteristics • simple and lightweight • unreliable • message-oriented • stateless • good choice for time-critical applications • supports unidirectional communication Problems • unlimited sending rate may overload the network/receiver 9/39
Outline Transport Layer UDP TCP Other Transport Layer Protocols 10/39
Transmission Control Protocol (TCP) Functions • port multiplexing / demultiplexing • error checking • reliable and ordered delivery • stream-orientation • control of sending-rate (avoid overloading the network or the receiver) Applications • most reliable protocols: HTTP(S), SMTP , etc. 11/39
Background: Reliable Data Transfer How does the sender know whether a packet was successfully transferred? • requires feedback from the receiver • requires identification of packets Sender Receiver segment X segment Y ACK segment X ACK segment Y 12/39
Reliable Data Transfer in TCP Sequence Number (SEQ) • indicates the first data byte of a segment • increased with every byte of payload sent • initial SEQ is exchanged during connection establishment Sender Receiver SEQ=5035 SEQ=6059 SEQ=12 ACK=6059 SEQ=12 ACK=7083 13/39
Reliable Data Transfer in TCP Sequence Number (SEQ) • indicates the first data byte of a segment • increased with every byte of payload sent • initial SEQ is exchanged during connection establishment Sender Receiver SEQ=5035 SEQ=6059 SEQ=12 ACK=6059 SEQ=12 ACK=7083 What is the size of the segments? 13/39
Reliable Data Transfer in TCP (contd.) Acknowledgement Number (ACK) • gives the next sequence number that the receiver is expecting • also acknowledges all smaller sequence numbers Receiver Sender SEQ=5035 SEQ=6059 SEQ=12 ACK=6059 SEQ=12 ACK=7083 14/39
Retransmission after Timeout • timeout at the sender triggers retransmission Sender Receiver SEQ=1 SEQ=2 timeout ACK=2 SEQ=2 15/39
Fast Retransmit • sender retansmits segment after receiving three duplicate ACKs Sender Receiver SEQ=1 SEQ=2 ACK=2 SEQ=3 SEQ=4 ACK=2 SEQ=5 ACK=2 ACK=2 3 duplicate SEQ=2 ACKs 16/39
Connection Establishment 3-way-handshake • establish initial sequence numbers and window sizes out-of-band TCP injection: http://arxiv.org/abs/1602.07128 • negotiate options Client Server [ S Y N ] S E Q = 7 8 K = C A 1 3 Q = E S K ] A C N , Y S [ [ A C K ] S E Q = 8 A C K = 1 4 17/39
Connection Establishment 3-way-handshake • establish initial sequence numbers and window sizes out-of-band TCP injection: http://arxiv.org/abs/1602.07128 • negotiate options • vulnerable to SYN-flood attacks → SYN cookies, TCPCT Client Server [ S Y N ] S E Q = 7 8 K = C A 1 3 Q = E S K ] A C N , Y S [ [ A C K ] S E Q = 8 A C K = 1 4 17/39
Connection Teardown 4-way-handshake • each side needs to terminate the connection → half-open connections possible • initiator waits for a timeout before closing the connection Initiator Receiver [ F I N ] K ] C [ A ] I N [ F [ A C timeout K ] 18/39
TCP header 0 3 4 6 7 15 16 31 source port destination port sequence number acknowledgement number hdr U A P R S F resvd window size R C S S Y I len G K H T N N urgent pointer checksum [options] • up to 40 Bytes of header options e.g. Window Scale, Selective Acknowledgment (SACK) • header length: 20 – 60 Bytes 19/39
Limiting the Sending-rate Why? • avoid overloading the receiver → flow control • avoid overloading the network → congestion control Sending Window • specifies the amount of unacknowledged data that the sender is allowed to send • is equal to the max. number of bytes in transit sending _ window = min ( receive _ window , cwnd ) • 20/39
Flow Control Flow Control • prohibits overloading the receiver • receiver announces the current size of the receive _ window to the sender in the TCP header window size field • limited by the buffer size at the receiver 21/39
Background: Network Congestion Jacobson, Van. "Congestion avoidance and control." ACM SIGCOMM Computer Communication Review, 1988. 22/39
Background: Network Congestion • segments get lost due to full buffers in routers • retransmissions may even amplify a congestion Jacobson, Van. "Congestion avoidance and control." ACM SIGCOMM Computer Communication Review, 1988. 22/39
Background: Network Congestion • segments get lost due to full buffers in routers • retransmissions may even amplify a congestion • self-clocking creates an equilibrium at the max. sending-rate: Jacobson, Van. "Congestion avoidance and control." ACM SIGCOMM Computer Communication Review, 1988. 22/39
Congestion Control Principles • basic assumption: packet loss is only caused by congestion • end-host driven: no support from the network necessary Two phases • Slow Start starts a connection: gradually increase the amount of data in-transit until reaching the equilibrium • Congestion Avoidance tries to keep the equilibrium state and react to changes on the link State • current size of the congestion window ( cwnd ) • slow start threshold ( ssthresh ) defines transition between phases 23/39
Congestion Control: Slow Start Phase • initialization: cwnd = 10 ∗ MSS , ssthresh cwnd [ MSS ] 80 60 40 20 0 time [ RTT ] 0 1 2 3 4 5 24/39
Congestion Control: Slow Start Phase • initialization: cwnd = 10 ∗ MSS , ssthresh • when receiving an ACK: cwnd = cwnd + 1 MSS cwnd [ MSS ] 80 60 40 20 0 time [ RTT ] 0 1 2 3 4 5 24/39
Congestion Control: Slow Start Phase • initialization: cwnd = 10 ∗ MSS , ssthresh • when receiving an ACK: cwnd = cwnd + 1 MSS cwnd [ MSS ] 80 60 40 20 0 time [ RTT ] 0 1 2 3 4 5 24/39
Congestion Control: Slow Start Phase • initialization: cwnd = 10 ∗ MSS , ssthresh • when receiving an ACK: cwnd = cwnd + 1 MSS cwnd [ MSS ] 80 60 40 20 0 time [ RTT ] 0 1 2 3 4 5 24/39
Congestion Control: Slow Start Phase • initialization: cwnd = 10 ∗ MSS , ssthresh • when receiving an ACK: cwnd = cwnd + 1 MSS cwnd [ MSS ] 80 60 40 20 0 time [ RTT ] 0 1 2 3 4 5 24/39
Congestion Control: Slow Start Phase • initialization: cwnd = 10 ∗ MSS , ssthresh • when receiving an ACK: cwnd = cwnd + 1 MSS cwnd [ MSS ] ssthresh 80 or packet loss 60 40 20 0 time [ RTT ] 0 1 2 3 4 5 24/39
Congestion Control: Congestion Avoidance Phase • when receiving an ACK: increase cwnd using a cubic function cwnd [ MSS ] 160 140 120 100 ssthresh 80 time [ RTT ] 0 1 2 3 4 5 25/39
Recommend
More recommend