Sie sind auf Seite 1von 24

The Transport Layer

The Transport Layer

First end-to-end layer Communication from source to destination host. Only hosts run transport-level protocols. Independent of application Independent of network being used Reliable data exchangeNo error In sequence No losses No duplicates Quality of service Parameters are-connection establishment time , throughput ,transit delay , residual error ratio , protection , priority etc

Services Provided to the Upper Layers

Source host Application Layer Transport Entity Network Layer TPDU Destination host Application Layer Transport Entity Network Layer

Types of Transport Services

-Provided to the application layer. Connection-less versus connection-oriented

service: No logical connections, no flow or error control. Connection-oriented: Based on logical connections: connection setup, data transfer, connection teardown. Flow and error control. Reliability and in-order delivery.

The Internet Transport Protocols: TCP and UDP

UDP: user datagram protocol

Connection-less protocol. Connection-oriented protocol.

TCP: transmission control protocol.

Reliable end-to-end communication. Each machine supporting TCP has TCP

transport entity:

Interfaces to the IP layer. Manages TCP streams.

Accepts user data, breaks it down and sends it as separate IP datagrams. At receiver, reconstructs original byte stream from IP datagrams.

Features of TCP
Connection oriented: An application requests a
connection to destination and uses connection to transfer data

IP does not uses connections - each datagram is sent independently!

Point-to-point: A TCP connection has two endpoints

(no broadcast/multicast)

Reliability: TCP provides reliable delivery, recovering

Lost packets Duplicate packets Delayed packets Corrupted data Source/destination mismatches Congestion

Features of TCP (contd)

Full duplex: Endpoints can exchange data in both directions simultaneously Reliable connection startup: TCP guarantees reliable, synchronized startup between endpoints (using three-way handshake) Graceful connection shutdown: TCP guarantees delivery of all data after endpoint shutdown

Delivering TCP Segments

TCP segments travel in IP datagrams.
TCP segment IP header Payload

Internet routers only look at IP header to forward datagrams.

Delivering TCP
TCP at destination interprets TCP messages

The TCP Protocol

Every byte on a TCP connection has its own 32-bit

sequence number. Data is exchanged in the form of segments. A segment consists of two sections: header (20 bytes plus optional part) data The TCP s/w decides how big the segments should be. Two limits restrict the segment size: Each segment must fit in the 65,535 byte IP payload. Each n/w has a maximum transfer unit (MTU) ,each segment must fit in the MTU.

TCP Segment Header

Source port Sequence number Acknowledgment number Header length UA P R S F Checksum Window size Destination port

Urgent pointer Options (0 or more 32-bit words) Data

Source port and Destination port -identify the local end points of the connection. Sequence number -This is used for representing the sequence number of the segment.(32 bit long) Acknowledgement number -If the ACK flag is set then the value of this field is the sequence number the sender expects next. The TCP Header Length This 4-bit field specifies the size of the TCP header in 32-bit words. The minimum size header is 20 bytes and the maximum is 60 bytes Reserved 6-bit reserved field for future use and should be set to zero.

Flags (Control bits) - This field contains 6 bit flags: URG - Set to 1 if Urgent pointer field is significant . ACK - Set to 1 if Acknowledgement field is significant ,if 0 ACK is ignored. PSH - This bit indicate PUSHed data-receiver is requested to deliver data to application upon arrival,not to buffer it. RST- Reset the connection-used to reject an invalid segment or refuse to open connection. SYN - Used to establish connections - denote connection request and connection accepted.(req is syn=1 & ack=0 and accept is syn=1 & ack=1) FIN - Used to release the connection-it specifies no more data from sender

Window size The number of bytes that may be sent. (ack=1 and window is 0 doesnt accept any more data.) Checksum The 16-bit checksum field is used for error-checking of the header and data.

Urgent pointer If the URG flag is set, then this 16-bit field is used to indicate a byte offset from the current sequence number at which the urgent data are to be found.

Option - Provide a way to add extra facilities. It allow each host to specify the maximum TCP payload it is willing to accept. Data The last field is not a part of the header.

Provides connection-less, unreliable service.

No delivery guarantees. No ordering guarantees. No duplicate detection. No connection establishment/teardown. Example: client-server applications.

Low overhead.

Suitable for short-lived connections.

UDP Segment Format

0 Source port Length Data Source and destination ports: identify the end points. Length: 8-byte header+ data. Checksum: optional; if not used, set to zero. 15 Destination port Checksum 31


TCP provides end-to-end communication. It takes care of reliable, error-free transfer of data, and insequence delivery UDP has less overhead compared to TCP, but does not guarantee transfers
TCP is preferred to transfer files UDP is preferred to transfer audio/video streams

Both protocols support multiplexing, i.e. they allow several distinct streams of data between two hosts

TCP service:
connection-oriented: setup

UDP service:
unreliable data transfer

required between client and server processes reliable transport between sending and receiving process flow control: sender wont overwhelm receiver congestion control: throttle sender when network overloaded does not provide: timing, minimum bandwidth guarantees

between sending and receiving process does not provide: connection setup, reliability, flow control, congestion control, timing, or bandwidth guarantee

TCP Connection Setup

3-way handshake.

Host 1

) K=x+1 ,AC SEQ=y SYN(

Host 2

(SEQ=x+1, ACK=y+1)

TCP Transmission
Sender process initiates connection. Once connection established, TCP can start

sending data. Sender writes bytes to TCP stream. TCP sender breaks byte stream into segments. Each byte assigned sequence number. Segment sent and timer started. If timer expires, retransmit segment. After retransmitting segment for maximum number of times, assumes connection is dead and closes it.

How it works?
AT senders side: To establish a connection, one side, the server waits for an incoming connection by executing the LISTEN and ACCEPT primitive. The other side, the client executes a CONNECT primitive, specifying the IP address and port to which it wants to connect, the maximum TCP size its willing to accept and optionally some user data. The CONNECT primitive sends a TCP segment with the SYN bit on and ACK bit OFF & waits for a response.

At receivers side:
When this segment arrives at the destination, the

TCP entity there checks to see if there is a process that has done the LISTEN on the port given in the destination port field. If not then it sends a reply with RST bit on to reject the connection. If some process is listening to the port, the process is given the incoming TCP segment . It can either accept or reject the connection. If it accepts ,an acknowledgement segment is sent back.

Thank you.