iLab TCP / UDP Florian Wohlfart wohlfart@in.tum.de Lehrstuhl für Netzarchitekturen und Netzdienste Fakultät für Informatik Technische Universität München Lab 4 – 14ws 1
Outline Transport Layer UDP TCP MTCP / SCTP 2
Outline Transport Layer UDP TCP MTCP / SCTP 3
Recap: 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 driver protocol driver driver protocol driver wireless LAN Ethernet 4
Transport Layer Purposes ◮ application addressing ◮ reliable data transfer (optional) ◮ adjustment of transmission rate (optional) 5
Ports transport layer multiplexing / demultiplexing Ports ◮ 16bit number (0..65535) ◮ used for adressing applications on a host Well-known port numbers ◮ HTTP/HTTPS: TCP port 80/443 ◮ FTP: TCP port 20/21 ◮ SSH: TCP port 22 ◮ DNS: UDP and TCP port 53 see: http://www.iana.org/assignments/port-numbers 6
Transport Protocol Implementations User Datagram Protocol (UDP) ◮ unreliable service ("best effort") ◮ lightweight Transmission Control Protocol (TCP) ◮ reliable ◮ connection oriented ◮ flow control and congestion control Other ◮ Multipath TCP (MTCP) ◮ Stream Control Transmission Protocol (SCTP) 7
Outline Transport Layer UDP TCP MTCP / SCTP 8
User Datagram Protocol (UDP) 0 15 16 31 source port destination port length checksum standardized in 1980 (RFC 768) Functions ◮ port multiplexing / demultiplexing ◮ error checking (optional over IPv4) Example Applications ◮ DNS (port 53) ◮ RIP (port 520) ◮ media streaming / realtime communication 9
UDP Summary Pros ◮ simple and lightweight ◮ transaction-oriented ◮ stateless ◮ low latency ◮ supports unidirectional communication Cons ◮ unreliable ◮ unlimited sending rate may harm the network/receiver 10
Outline Transport Layer UDP TCP MTCP / SCTP 11
Transmission Control Protocol (TCP) standardized in 1981 (RFC 793), numerous updates/extensions 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 ◮ e.g. HTTP (port 80) 12
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 13
Reliable Data Transfer in TCP sequence number ◮ initial SN is exchanged during connection establishment ◮ increased with every byte of payload sent ◮ indicates the first data byte of a segment Sender Receiver SEQ=5035 SEQ=6059 SEQ=12 ACK=6059 SEQ=12 ACK=7083 14
Reliable Data Transfer in TCP acknowledgement number ◮ gives the next sequence number that the receiver is expecting ◮ also acknowledges all smaller sequence numbers Sender Receiver SEQ=5035 SEQ=6059 SEQ=12 ACK=6059 SEQ=12 ACK=7083 15
Retransmission after Timeout ◮ timeout at the sender triggers retransmission Sender Receiver SEQ=1 SEQ=2 timeout ACK=2 SEQ=2 16
Fast Retransmit ◮ sender retansmits segment after receiving three duplicate ACKs Sender Receiver S E Q = 1 SEQ=2 2 = K C A S E Q = 3 S E Q = 4 2 = K C A S E Q = 5 2 = K C A = 2 K C A 3 duplicate SEQ=2 ACKs 17
TCP header 0 3 4 6 7 15 16 31 source port destination port sequence number acknowledgement number C E U A P R S F N hdr len resvd window size W C R C S S Y I S R E 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 18
Connection Establishment 3-way-handshake ◮ establish initial sequence number and window size ◮ negotiate options Client Server [ S Y N ] S E Q = 7 8 = K C A 3 1 = Q E S K ] C A , N Y S [ [ A C K ] S E Q = 8 A C K = 1 4 19
Connection Establishment 3-way-handshake ◮ establish initial sequence number and window size ◮ negotiate options ◮ vulnerable to SYN-flood attacks → SYN cookies, TCPCT Client Server [ S Y N ] S E Q = 7 8 = K C A 3 1 = Q E S K ] C A , N Y S [ [ A C K ] S E Q = 8 A C K = 1 4 19
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 Reveiver [ F I N ] ] K C A [ N ] I F [ [ A C timeout K ] 20
Limiting the Sending-rate Sending Window ◮ specifies the amount of data that the sender is allowed to send after the last acknowledged segment ◮ is equal to the number of bytes that can be in transit ◮ sending _ window = min ( receive _ window , cwnd ) Flow Control ◮ prohibits overloading the receiver ◮ receiver announces the current size of the receive _ window in the TCP header ◮ limited by the buffer size at the receiver 21
Background: Network Congestion Jacobson, Van. "Congestion avoidance and control." ACM SIGCOMM Computer Communication Review, 1988. 22
Background: Network Congestion ◮ segments get lost due to full buffers in routers ◮ retransmissions even amplify a congestion Jacobson, Van. "Congestion avoidance and control." ACM SIGCOMM Computer Communication Review, 1988. 22
Background: Network Congestion ◮ segments get lost due to full buffers in routers ◮ retransmissions 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
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
Congestion Control (cont.) MSS = maximum segment size (ususally 1460 Byte) Slow Start Phase ◮ initialization: cwnd = 1 MSS , ssthresh ◮ when receiving an ACK: cwnd = cwnd + 1 MSS Congestion Avoidance Phase ◮ when receiving an ACK: increase cwnd using a cubic function Packet Loss ◮ timeout: assumption: the network is congested → go to slow start, cwnd = 1 MSS , ssthresh = 0 . 8 ∗ last _ cwnd ◮ 3 duplicate ACKs: assumption: only a segment was lost → cwnd = ssthresh + 3 MSS 24
TCP CUBIC 25
TCP Options Window Scaling ◮ window scaling allows to increase the window size up to 4GB ◮ default window size max. 65 KB (16bit field) ◮ Example: 16MBit/s, 150ms RTT, bandwidth-delay product: 16 MBit / s ∗ 0 . 15 s = 2 , 400 Kbit = 300 KB ◮ problem remains: sequence numbers (32bit) still limit the amount of unacknowledged data Selective Acknowledgements (SACK) ◮ allow the receiver to acknowledge ranges of segments ◮ avoid unnecessary retransmissions compared to cumulative ACKs 26
TCP Summary Pros ◮ reliable ◮ stream-oriented ◮ sending-rate limitation Cons ◮ complex and heavyweight ◮ state can be exploited ◮ packet loss in wireless networks interferes with congestion control 27
Outline Transport Layer UDP TCP MTCP / SCTP 28
Other Transport Layer Protocols Multipath TCP (MTCP) ◮ idea: a TCP connection can use paths ◮ goal: maximize resource usage and increase redundancy ◮ compatible with standard TCP Stream Control Transmission Protocol (SCTP) ◮ TCP/UDP hybrid: reliable, optional ordering, message-oriented ◮ other features: multihoming, 4-way-handshake, etc. ◮ problem: lack of support in middleboxes (firewalls, NATs, etc.) 29
Recommend
More recommend