Download presentation
Presentation is loading. Please wait.
Published byMolly Miller Modified over 9 years ago
1
Transport Layer3-1 Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer m flow control m congestion control r learn about transport layer protocols in the Internet: m UDP: connectionless transport m TCP: connection-oriented transport m TCP congestion and flow control
2
Transport Layer3-2 Recap: Internet protocol stack r application: supporting network applications m FTP, SMTP, HTTP r transport: process-process data transfer m TCP, UDP r network: host-host data transfer m IP r link: data transfer between neighboring network elements m PPP, Ethernet r physical: bits “on the wire” application transport network link physical
3
Transport Layer3-3 message segment datagram frame source application transport network link physical HtHt HnHn HlHl M HtHt HnHn M HtHt M M destination application transport network link physical HtHt HnHn HlHl M HtHt HnHn M HtHt M M network link physical link physical HtHt HnHn HlHl M HtHt HnHn M HtHt HnHn HlHl M HtHt HnHn M HtHt HnHn HlHl M HtHt HnHn HlHl M router switch Encapsulation
4
Transport Layer3-4 TL: Outline r 3.1 Transport-layer services r 3.2 Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP r 3.4 Principles of reliable data transfer r 3.5 Connection-oriented transport: TCP m segment structure m reliable data transfer m flow control m connection management r 3.6 Principles of congestion control r 3.7 TCP congestion control
5
Transport Layer3-5 Transport services and protocols r provide logical communication between app processes running on different hosts r transport protocols run in end systems m send side: breaks app messages into segments, passes to network layer (Multiplexing) m rcv side: reassembles segments into messages, passes to app layer (DeMultiplexing) r more than one transport protocol available to apps m TCP and UDP application transport network data link physical application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical logical end-end transport
6
Transport Layer3-6 Transport vs. network layer r network layer: logical communication between hosts r transport layer: logical communication between processes m relies on, enhances, network layer services m Constrained by network layer service: e.g. bounded delay m Enhancement: e.g. reliable data transfer, encryption to guarantee message secrecy Household analogy: 12 kids sending letters to 12 kids r processes = kids r app messages = letters in envelopes r hosts = houses r transport protocol = Ann and Bill: mail service to collect/distribute mails m Susan/Harvey can provide another type of mail service r network-layer protocol = postal service
7
Transport Layer3-7 Internet transport-layer protocols r IP service model m Host-to-host best-effort delivery service, datagram m Unreliable serivce r UDP: unreliable, unordered delivery m Proc to proc segment delivery: no- frills extension of “best-effort” IP (Multiplexing /demultiplexing) m Error checking r TCP: m reliable, in-order delivery: flow control, sequence number, ack, timer, etc m congestion control to prevent TCP connection from swamping the links and switches r services not available in either TCP or UDP: m delay guarantees m bandwidth guarantees application transport network data link physical application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical logical end-end transport
8
Transport Layer3-8 Multiplexing/demultiplexing (encode/decode) application transport network link physical P1 application transport network link physical application transport network link physical P2 P3 P4 P1 host 1 host 2 host 3 = process= socket The job of delivering received transport-layer segments to correct socket. Each socket has a unique identifier (a set of fields in each segment) Demultiplexing at rcv host: The job of gathering data from different sockets, enveloping data with header (later used for demultiplexing) and passing the data to the network layer. Multiplexing at send host:
9
Transport Layer3-9 How demultiplexing works r host receives IP datagrams m each datagram has source and destination IP addresses m each datagram carries 1 transport-layer segment m each segment has source, destination port number (ranges from 0-65535) m 0~1023 well-known ports r host/OS uses IP addresses & port numbers to direct segment to appropriate socket source port #dest port # 32 bits application data (message) other header fields TCP/UDP segment format Note the naming convention: IP datagrams vs TCP/UDP segments
10
Transport Layer3-10 Connectionless demultiplexing r Create UDP sockets with port numbers; the OS assigns ports if not specified by programmer: DatagramSocket mySocket1 = new DatagramSocket(99111); DatagramSocket mySocket2 = new DatagramSocket(); r UDP socket is identified by two-tuple: ( dest IP address, dest port number) r When host/server receives UDP segment: m checks destination port number in segment m directs UDP segment to socket with that port number r IP datagrams with different source IP addresses and/or source port numbers directed to same socket
11
Transport Layer3-11 Connectionless demux (cont) DatagramSocket serverSocket = new DatagramSocket(6428); Client IP:B P2 client IP: A P1 P3 server IP: C SP: 6428 DP: 9157 SP: 9157 DP: 6428 SP: 6428 DP: 5775 SP: 5775 DP: 6428 SP = Source Port, DP = Destination Port Source Packet provides “return address” that destination host can use to reply port 9157 port 6428port 5775 One Server Socket
12
Transport Layer3-12 Connection-oriented demux r TCP socket identified by 4- tuple: m source IP address m source port number m dest IP address m dest port number r recv host uses all four values to direct segment to appropriate socket r Server host may support many simultaneous TCP sockets: m each socket identified by its own 4-tuple m TCP server appl has a “welcome socket”, waiting for conneciton-setup requests r Web servers have different sockets for each connecting client m non-persistent HTTP will have different socket for each request because it re- connects at each request.
13
Transport Layer3-13 Recap: Client/server TCP socket interaction wait for incoming connection request connectionSocket = welcomeSocket.accept() create socket, port= x, for incoming request: welcomeSocket = ServerSocket() create socket, connect to hostid, port= x clientSocket = Socket() close connectionSocket read reply from clientSocket close clientSocket Server (running on hostid ) Client send request using clientSocket read request from connectionSocket write reply to connectionSocket TCP connection setup
14
Transport Layer3-14 Connection-oriented demux (Web Server example 1) Client IP:B P1 client IP: A P1P2P4 server IP: C SP: 9157 DP: 80 SP: 9157 DP: 80 P5P6P3 D-IP:C S-IP: A D-IP:C S-IP: B SP: 5775 DP: 80 D-IP:C S-IP: B SP = Source Port, DP = Destination Port, S-IP = Source IP, D-IP = Destination IP Three Server Sockets
15
Transport Layer3-15 Connection-oriented demux: (Web Server example 2) Client IP:B P1 client IP: A P1P2 server IP: C SP: 9157 DP: 80 SP: 9157 DP: 80 P4 P3 D-IP:C S-IP: A D-IP:C S-IP: B SP: 5775 DP: 80 D-IP:C S-IP: B
16
Transport Layer3-16 Transport Layer: Outline r 3.1 Transport-layer services r 3.2 Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP r 3.4 Principles of reliable data transfer r 3.5 Connection-oriented transport: TCP m segment structure m reliable data transfer m flow control m connection management r 3.6 Principles of congestion control r 3.7 TCP congestion control
17
Transport Layer3-17 UDP: User Datagram Protocol [RFC 768] r “no frills,” “bare bones” Internet transport protocol r “best effort” service, UDP segments may be: m lost m delivered out of order to app r connectionless: m no handshaking between UDP sender, receiver m each UDP segment handled independently of others Why is there a UDP? r no connection establishment (which can add delay) r simple: no connection state (parameters,buffers) at sender, receiver r small segment header, 8 bytes for UDP vs 20 bytes for TCP per segment. r Finer application control on what and when to send data.no congestion control.
18
Transport Layer3-18 Internet Applications that use UDP r Domain Name Service (DNS): m DNS would be much slower if it ran over TCP r Network Management Applications: using Simple Network Management Protocol (SNMP): m they often run when the network is in a stressed state and TCP and its overhead is difficult to achieve. r Multimedia appl: Internet phone, real-time video conf. that can tolerate small packet loss and is sensitive to transfer rates. m reliability can be built into the application that have their own acknowledgements and retransmissions techniques. But UDP senders may crowd out TCP sessions
19
Transport Layer3-19 UDP Segment Structure r UDP segment has an 8 byte header. r Length of UDP segment, in bytes, including header. r Minimum length is 8 and maximum is 64k. source port #dest port # 32 bits Application data (message) UDP segment format length (16-bit) checksum (16-bit)
20
Transport Layer3-20 UDP checksum Sender: r treat segment contents as sequence of 16-bit integers (words) r checksum: 1’s complement of the addition of all segment words with overflow wrapped around r sender puts checksum value into UDP checksum field Receiver: r compute sum of all 16-bit words including checksum in received segment r check if computed sum equals all 1’s: m NO - error detected m YES - no error detected. Goal: detect “errors” due to noise or router storage (e.g., flipped bits) in transmitted segment. A damaged packet is sometimes passed to the appl. with a warning or sometime discarded. All 1-bit errors will be detected but two-bit errors can be undetected
21
Transport Layer3-21 Internet Checksum: Sender Example r Note m When adding numbers, a carryout from the most significant bit needs to be added to the result r Segment has two 16-bit integers and the checksum r Add the two 16-bit integers r compute the checksum by taking the 1’s complement of the sum. 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 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 wraparound: add carry to LSB sum checksum
22
Transport Layer3-22 r Compute the sum of all 16-bit words including the checksum. r If All 1’s then no error 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 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 wraparound: add carry to LSB sum checksum Internet Checksum: Receiver Example - no errors 1 1 1 1 1 1 1 1 sum (All 1s)
23
Transport Layer3-23 r Compute the sum of all 16-bit words including the checksum. r If All 1’s then no error 1 1 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 wraparound: add carry to LSB sum checksum Checksum: Receiver Example - 1 bit error 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 Flipped bit sum (not all 1s)
24
Transport Layer3-24 r Compute the sum of all 16-bit words including the checksum. r If All 1’s then no error ! 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 sum checksum Checksum: Receiver Example - 3 bit error undetected 1 1 1 1 1 1 1 1 sum (All 1s) Flipped bits circled
25
Transport Layer3-25 Why Checksum at TL layer r No guarantee that all the links between src and dest provide error checking r Bit errors may be introduced in a router’s memory r An example of end-to-end design principle m End-to-end data transfer with error detection
26
Transport Layer3-26 Summary r Transport layer vs Network layer m logical communication between processes vs between hosts r Transport Layer minimum services: m Multiplexing and DeMultiplexing of application layer packets m Data error handling via checksums. r Difference between Multiplexing at send host vs Demultiplexing at rcv host r UDP Socket vs TCP Socket identification parameters m (dest-IP, dest-port) vs (source-IP, source-port, dest-IP, dest- port) r UDP Advantages over TCP and what type of applications use it. r UDP Segment Structure and the checksum calculation for handling 1- bit errors
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.