Sie sind auf Seite 1von 64

Chapter 6

The Transport Layer

The Transport Service

Services Provided to the Upper Layers Transport Service Primitives Berkeley Sockets An Example of Socket Programming:
a) An Internet File Server

Services Provided to the Upper Layers

The network, transport, and application layers.

Transport Service Primitives

The primitives for a simple transport service.

Transport Service Primitives (2)

The nesting of TPDUs, packets, and frames.

Transport Service Primitives (3)

A state diagram for a simple connection management scheme. Transitions labeled in italics are caused by packet arrivals. The solid lines show the client's state sequence. The dashed lines show the server's state sequence.

Berkeley Sockets

The socket primitives for TCP.

Elements of Transport Protocols

Addressing Connection Establishment Connection Release Flow Control and Buffering Multiplexing Crash Recovery

Transport Protocol

(a) Environment of the data link layer. (b) Environment of the transport layer.


TSAPs, NSAPs and transport connections.

Connection Establishment

How a user process in host 1 establishes a connection with a time-of-day server in host 2.

Connection Establishment (2)

(a) TPDUs may not enter the forbidden region. (b) The resynchronization problem.

Connection Establishment (3)

Three protocol scenarios for establishing a connection using a three-way handshake. CR denotes CONNECTION REQUEST. (a) Normal operation, (b) Old CONNECTION REQUEST appearing out of nowhere. (c) Duplicate CONNECTION REQUEST and duplicate ACK.

Connection Release

Abrupt disconnection with loss of data.

Connection Release (2)

The two-army problem.

Connection Release (3)

6-14, a, b

Four protocol scenarios for releasing a connection. (a) Normal case of a three-way handshake. (b) final ACK lost.

Connection Release (4)

6-14, c,d

(c) Response lost. (d) Response lost and subsequent DRs lost.

Flow Control and Buffering

(a) Chained fixed-size buffers. (b) Chained variable-sized buffers. (c) One large circular buffer per connection.

Flow Control and Buffering (2)

Dynamic buffer allocation. The arrows show the direction of transmission. An ellipsis () indicates a lost TPDU.


(a) Upward multiplexing. (b) Downward multiplexing.

Crash Recovery

Different combinations of client and server strategy.

Transport services and protocols

a)provide logical communication between app processes running on different hosts b)transport protocols run in end systems a) send side: breaks app messages into segments, passes to network layer b) rcv side: reassembles segments into messages, passes to app layer c)more than one transport protocol available to apps a) Internet: TCP and UDP

Transport vs. network layer

a)network layer: logical communication between hosts b)transport layer: logical communication between processes
a) relies on, enhances, network layer services

Household analogy: 12 kids sending letters to 12 kids a)processes = kids b)app messages = letters in envelopes c)hosts = houses d)transport protocol = Ann and Bill e)network-layer protocol = postal service

Internet transport-layer protocols

a)reliable, in-order delivery (TCP) a) congestion control b) flow control c) Acks and timers d) connection setup b)unreliable, unordered delivery: UDP a) no-frills extension of best-effort IP b) Error-checking c)services not available: a) delay guarantees b) bandwidth guarantees d)IP a) Best-effort delivery b) Does not guarantee segment delivery c) Doest not guarantee orderly delivery d) Doest not guarantee the integrity


UDP and TCP extend IPs delivery service between two end systems to a delivery service between two processes running on the end systems

Chapter 3 outline
a)3.1 Transport-layer services b)3.2 Multiplexing and demultiplexing c)3.3 Connectionless transport: UDP d)3.4 Principles of reliable data transfer a)3.5 Connection-oriented transport: TCP
a) b) c) d) segment structure reliable data transfer flow control connection management

b)3.6 Principles of congestion control c)3.7 TCP congestion control

Multiplexing and Demultiplexing

a) Extending host-to-host delivery service provided by the network layer to a process-to-process delivery service for applications running on the hosts


How demultiplexing works

a)host receives IP datagrams a) each datagram has source IP address, destination IP address b) each datagram carries 1 transport-layer segment c) each segment has source, destination port number (recall: well-known port numbers for specific applications) b)host uses IP addresses & port numbers to direct segment to appropriate socket

Connectionless demultiplexing
a)When host receives UDP segment: a)Create sockets with port numbers:
DatagramSocket mySocket1 = new DatagramSocket(99111); DatagramSocket mySocket2 = new DatagramSocket(99222);

a) b)

checks destination port number in segment directs UDP segment to socket with that port number

a)UDP socket identified by two-tuple: (dest IP address, dest port number)

b)IP datagrams with different source IP addresses and/or source port numbers directed to same socket

Connectionless demux (cont)

DatagramSocket serverSocket = new DatagramSocket(6428);

Connection-oriented demux
a)TCP socket identified by 4-tuple:
a) b) c) d) source IP address source port number dest IP address dest port number

a)Socket clientSocket = new Socket(server, 6789) b)Socket conSocket =servSock.accept() c)Server host may support many simultaneous TCP sockets:
a) each socket identified by its own 4tuple

b)recv host uses all four values to direct segment to appropriate socket c)Two arriving TCP segments with different source IP addresses or source port numbers will be directed to two different sockets

d)Web servers have different sockets for each connecting client

a) non-persistent HTTP will have different socket for each request

Connection-oriented demux (cont)

Connectionless vs connection-oriented

Connection-oriented demux: Threaded Web Server

The Internet Transport Protocols: UDP

Introduction to UDP Remote Procedure Call The Real-Time Transport Protocol

UDP: User Datagram Protocol [RFC 768]

a)no frills, bare bones Internet transport protocol b)best effort service, UDP segments may be: a) lost b) delivered out of order to app c)connectionless: a) no handshaking between UDP sender, receiver b) each UDP segment handled independently of others

Why is there a UDP?

a)no connection establishment (which can add delay) b)simple: no connection state(receive and send buffers, congestion-control parameters, sequence and ack nos.) at sender, receiver c)small segment header(TCP-20bytes, UDP-8bytes) d)Finer application-level control over what data is sent, and when: no congestion control: UDP can blast away as fast as desired

UDP and TCP usage

Application E-mail Remote terminal access Web File Transfer Remote File Server Streaming multimedia Internet telephony Network Management Routing Protocol Name translation Application-layer protocol SMTP Telnet HTTP FTP NFS proprietary proprietary SNMP RIP DNS Transport Protocol TCP TCP TCP TCP UDP UDP UDP UDP UDP UDP

UDP: more
a) often used for streaming multimedia apps a) loss tolerant b) rate sensitive

b) other UDP uses

a) DNS b) SNMP c) reliable transfer over UDP: add reliability at application layer a) application-specific error recovery! UDP length field includes the 8byte header and the data

UDP checksum
Goal: detect errors (e.g., flipped bits) in transmitted segment

a)treat segment contents as sequence of 16bit integers b)checksum: addition (1s complement sum) of segment contents c)sender puts checksum value into UDP checksum field

a)compute checksum of received segment b)check if computed checksum equals checksum field value: a) NO - error detected b) YES - no error detected. But maybe errors nonetheless? More later .

Internet Checksum Example

a) Note a) When adding numbers, a carryout from the most significant bit needs to be added to the result Example: add 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 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

Introduction to UDP

The UDP header.

Remote Procedure Call

Steps in making a remote procedure call. The stubs are shaded.

Remote Procedure Call

a) b) allows programs to call procedures located on remote hosts When a process on machine 1 calls a procedure on machine 2, the calling process on 1 is suspended and execution of the called procedure takes place on 2. Information can be transported from the caller to the callee in the parameters and can come back in the procedure result. No message passing is visible to the programmer client stub - represents the server procedure in the client's address space (client program must be bound with this library procedure) server stub - server is bound with this procedure


d) e)

Remote Procedure Call

Step 1 is the client calling the client stub. This call is a local procedure call, with the parameters pushed onto the stack in the normal way. Step 2 is the client stub packing the parameters into a message and making a system call to send the message. Packing the parameters is called marshaling. Step 3 is the kernel sending the message from the client machine to the server machine. Step 4 is the kernel passing the incoming packet to the server stub. Finally, step 5 is the server stub calling the server procedure with the unmarshaled parameters. The reply traces the same path in the other direction.

The Real-Time Transport Protocol

(a) The position of RTP in the protocol stack. (b) Packet nesting.

a) b)

real-time multimedia applications use UDP. Internet radio, Internet telephony, music-on-demand, videoconferencing, video-on-demand, and other multimedia applications

The Real-Time Transport Protocol (2)

a) Version ( 2 bits), - 2 b) P (1 bit) - packet has been padded to a multiple of 4 bytes c) CC (4-bits) - how many contributing sources are present, from 0 to 15 d) M(1 bit) - an application-specific marker bit. It can be used to mark the start of a video frame, the start of a word in an audio channel e) Payload type (7 bits) - which encoding algorithm has been used (e.g., uncompressed 8-bit audio, MP3, etc.). f) Sequence number (16 bits) a counter that is incremented on each RTP packet sent g) timestamp is produced by the stream's source to note when the first sample in the packet was made h) Synchronization source identifier tells which stream the packet belongs to i) Contributing source identifiers streams being mixed listed here - mixer(source identifier)

The RTP header.

The Real-Time Transport Protocol

a) b) RTCP (Realtime Transport Control Protocol). It handles feedback, synchronization, and the user interface but does not transport any data

The Internet Transport Protocols: TCP

Introduction to TCP The TCP Service Model The TCP Protocol The TCP Segment Header TCP Connection Establishment TCP Connection Release TCP Connection Management Modeling TCP Transmission Policy TCP Congestion Control TCP Timer Management Wireless TCP and UDP Transactional TCP

The TCP Service Model

Port 21 23 25 69 79 80 110 119 Protocol FTP Telnet SMTP TFTP Finger HTTP POP-3 NNTP Use File transfer Remote login E-mail Trivial File Transfer Protocol Lookup info about a user World Wide Web Remote e-mail access USENET news

TCP connection has two end point (sender and receiver) - sockets Sockets IP address and Port Number TCP connections are full duplex and point to point TCP connection is a byte stream not message stream TCP may send the data immediately (PUSH) or buffer it TCP urgent data (URGENT ) - receiving host is interrupted and stops what it was doing and read the urgent data

The TCP Service Model (2)

(a) Four 512-byte segments sent as separate IP datagrams. (b) The 2048 bytes of data delivered to the application in a single READ CALL.

The TCP Segment Header

TCP Header.

The TCP Segment Header

a) b) c) d) e) f) Source port (16 bits) Destination port (16 bits) fields identify the local end points of the connection Sequence number(32 bits) Acknowledgement number (32 bits) - specifies the next byte expected - every byte of data is numbered in a TCP stream TCP header length (4 bits)- how many 32-bit words are contained in the TCP header 6-bit field that is not used

The TCP Segment Header

a) six 1-bit flags
a) URG is set to 1 if the Urgent pointer is in use. The Urgent pointer is used to indicate a byte offset from the current sequence number at which urgent data are to be found ACK bit is set to 1 to indicate that the Acknowledgement number is valid PSH bit indicates PUSHed data. The receiver is hereby kindly requested to deliver the data to the application upon arrival and not buffer it until a full buffer has been received RST bit is used to reset a connection that has become confused due to a host crash or some other reason SYN bit is used to establish connections. FIN bit is used to release a connection.

b) c)

d) e) f)


The Window size(16 bits) - how many bytes may be sent starting at the byte acknowledged used in flow control

The TCP Segment Header (2)

a) b)

The pseudoheader included in the TCP checksum. Checksum is also provided for extra reliability It checksums the header, the data, and the conceptual pseudoheader

TCP Connection Establishment


(a) TCP connection establishment in the normal case. (b) Call collision.

TCP Connection Management Modeling

The states used in the TCP connection management finite state machine.

TCP Connection Management Modeling (2)

TCP connection management finite state machine. The heavy solid line is the normal path for a client. The heavy dashed line is the normal path for a server. The light lines are unusual events. Each transition is labeled by the event causing it and the action resulting from it, separated by a slash.

TCP Transmission Policy

Window management in TCP.

TCP Transmission Policy (2)

Silly window syndrome.

TCP Congestion Control

(a) A fast network feeding a low capacity receiver. (b) A slow network feeding a high-capacity receiver.

TCP Congestion Control (2)

An example of the Internet congestion algorithm.

TCP Timer Management

(a) Probability density of ACK arrival times in the data link layer. (b) Probability density of ACK arrival times for TCP.