CS 4390 Computer Networks UT D data Session 07 Transport Layer Overview and UDP Adapted from Computer Networking a Top-Down Approach 1996-2012 by J.F Kurose and K.W. Ross, All Rights Reserved Transport Services and Protocols provide logical communication between app processes running on different hosts Apps require different services protocols run in end systems send side: breaks app messages into segments, passes to layer receive side: reassembles segments into messages, passes to app layer more than one protocol available to apps Internet: TCP and UDP data data 2 1
Challenges for Transport Layer Develop algorithms and techniques for protocols that address requirements imposed by programs for Datagram service connection-less Byte stream service connection-oriented Take into account limitations of underlying layers ( and below) Network layer services and protocol limitations Underlying data transmission limitations, e.g. higher bit-error rate in wireless channels 3 Transport Service Requirements Supports multiple processes on a host Supports arbitrarily large messages Guarantees message delivery Guarantees no errors in delivered messages Delivers at most one copy of each message Delivers messages in the same order they were sent Ensures that messages not overwhelm the receiver Delivers messages with minimum delay 4 2
Limitations of Underlying Layers Bit-errors in messages Vary depending on channels, can be high in wireless Messages are lost e.g. discarded by routers due to buffer overflow Messages are delivered out-of-order Packet switching: packets may traverse different paths from sender to receiver Duplicated messages Duplicated copies of the same messages may be received (due to retransmission) Limited message size Ethernet frames: 1.5 KB, IP: 64 KB Delayed delivery due to congestion... 5 Transport Layer Topics our goals: understand principles behind layer services: multiplexing, demultiplexing reliable data transfer flow control congestion control learn about Internet layer protocols: User Datagram Protocol (UDP): connectionless Transmission Control Protocol (TCP): connectionoriented reliable TCP congestion control 6 3
Transport vs. Network Layer layer: logical communication between hosts layer: logical communication between processes relies on, enhances, layer services household analogy: 12 kids in Ann s house sending letters to 12 kids in Bill s house: hosts = houses processes = kids app messages = letters in envelopes protocol = Ann and Bill who demux to inhouse siblings -layer protocol = postal service 7 Internet Transport-layer Protocols reliable, in-order delivery: TCP congestion control flow control connection setup unreliable, unordered delivery: UDP no-frills extension of best-effort IP services not available: data data data data data data data data data delay guarantees bandwidth guarantees 8 4
Multiplexing & Demultiplexing multiplexing at sender: handle data from multiple sockets, add header (later used for demultiplexing) demultiplexing at receiver: use header info to deliver received segments to correct socket P3 P1 P2 P4 socket process 9 How Demultiplexing Works? host receives IP datagrams each datagram has source IP address, destination IP address each datagram carries one -layer segment each segment has source, destination port number host uses IP addresses & port numbers to direct segment to appropriate socket 32 bits source port # dest port # other header fields data (payload) TCP/UDP segment format 10 5
Connectionless Demultiplexing (UDP) recall: created socket has host-local port #: mysocket1 = new (12534); recall: when creating datagram to send into UDP socket, must specify destination IP address destination port # when host receives UDP segment: checks destination port # in segment directs UDP segment to socket with that port # IP datagrams with same dest. port #, but different source IP addresses and/or source port numbers will be directed to same socket at dest 11 Connectionless Demux Example mysocket2 = new (9157); P3 serversocket = new (6428); P1 mysocket1 = new (5775); P4 source port: 6428 dest port: 9157 source port:? dest port:? source port: 9157 dest port: 6428 source port:? dest port:? 12 6
Connection-oriented Demux (TCP) TCP socket identified by a 4-tuple: source IP address source port number dest IP address dest port number demux: receiver uses all four values to direct segment to appropriate socket server host may support many simultaneous TCP sockets: each socket identified by its own 4-tuple web servers have different sockets for each connecting client non-persistent HTTP will have different socket for each request 13 Connection-oriented Demux Example P3 P4 P5 P6 server: IP address B P2 P3 host: IP address A source IP,port: B,80 dest IP,port: A,9157 source IP,port: A,9157 dest IP, port: B,80 three segments, all destined to IP address: B, dest port: 80 are demultiplexed to different sockets source IP,port: C,5775 dest IP,port: B,80 source IP,port: C,9157 dest IP,port: B,80 host: IP address C 14 7
Connection-oriented Demux Example threaded server P3 P4 server: IP address B P2 P3 host: IP address A source IP,port: B,80 dest IP,port: A,9157 source IP,port: C,5775 dest IP,port: B,80 host: IP address C source IP,port: A,9157 dest IP, port: B,80 source IP,port: C,9157 dest IP,port: B,80 15 UDP: User Datagram Protocol [RFC 768] no frills, bare bones Internet protocol best effort service, UDP segments may be: lost delivered out-of-order to app connectionless: no handshaking between UDP sender, receiver each UDP segment handled independently of others UDP use: streaming multimedia apps (loss tolerant, rate sensitive) DNS SNMP reliable transfer over UDP: add reliability at layer -specific error recovery! What are two main functions does UDP add to IP? 13 8
UDP: Segment Header source port # dest port # length 32 bits data (payload) checksum UDP segment format length, in bytes of UDP segment, including header why is there a UDP? no connection establishment (which can add delay) simple: no connection state at sender, receiver small header size no congestion control: UDP can blast away as fast as desired 17 UDP Checksum Goal: detect errors (e.g., flipped bits) in transmitted segment sender: treat segment contents, including header fields, as sequence of 16-bit integers checksum: addition (1- complement sum) of segment contents sender puts checksum value into UDP checksum field All 0s means no checksum receiver: (If the received checksum is not all 0s) compute checksum of received segment check if computed checksum equals checksum field value: NO - error detected YES - no error detected. (But maybe errors nonetheless? More later). What if the sender wants to add checksum and the calculated checksum is all 0s? 18 9
Internet Checksum Algorithm 1. Break the data (e.g. the UDP message, including header) as a series of 16-bit integers 2. Add them together using 1-complement arithmetic The negative number of an integer N is obtained by reverting all bits of N For example, N = 7, binary: 0111 -> -N = -7, binary: 1000 If there is a carry-over, add 1 to the result 3. Take 1-complement of the result (i.e. reverting all bits) to get the checksum for the data 19 Internet Checksum Example Message is two 16-bit integers 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Carry-over 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1-complement sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 20 10
Pointers to Corresponding Sections of Textbook 6 th edition Chapter 3, up to and including 3.3 7 th edition Chapter 3, up to and including 3.3 21 11