Top Banner
Services provided by transport layer protocols •Protocols running at the transport layer provide services to upper layers •To enable software applications in higher layers to work over an internetwork • For connections to be established and maintained between software services on possibly distant machines. • To enable applications to send data in a reliable way •without needing to worry about error correction, lost data or flow management, and network-layer protocols, which are
58
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Transport Layer

Services provided by transport layer protocols

•Protocols running at the transport layer provide services to upper layers

•To enable software applications in higher layers to work over an internetwork• For connections to be established and maintained between software services on possibly distant machines.• To enable applications to send data in a reliable way

•without needing to worry about error correction, lost data or flow management, and network-layer protocols, which are often unreliable and unacknowledged.

Page 2: Transport Layer

Adressing at Network and Transport layers

• Internet Protocol (IP) provide addressing function on a TCP/IP network

• Network-layer addresses uniquely identify each network interface– serve as the mechanism by which data is routed to the correct

network on the internetwork

– and then the correct device on that network

• Additional level of addressing occurs at the transport layer in TCP/IP

• TCP and UDP, use the concepts of ports and sockets for virtual software addressing– To enable the Multiplexing and Demultiplexing Using Ports

Page 3: Transport Layer

Multiplexing and de-mutiplexing in TCP/IP

Page 4: Transport Layer

Port numbers• Mux & DeMUX by

– Protocol field included in the header of each IP datagram

– Source Port and a Destination Port• Port number field -16 bit • For example, port #80 is reserved for the Hypertext

Transfer Protocol (HTTP)• Port numbers assignments are managed by IANA • well-known port numbers (0 –1023)• registered port numbers (1024 – 49151) • ( 49152 – 65535 ) that can be used without IANA

registration

Page 5: Transport Layer

Client server ports• Well-known and registered port numbers are needed

for server processes • Client processes don't use well-known or registered

ports • The server must know the port number of client to

send reply• Each client process use temporary port number

called an ephemeral port number.• These port numbers are assigned in a pseudo-

random way

Page 6: Transport Layer

Client Server communication

Page 7: Transport Layer

Applcation, port, protocol• ftp 21/tcp File Transfer [Control]• ftp 21/udp File Transfer [Control]• ssh 22/tcp SSH Remote Login Protocol• ssh 22/udp SSH Remote Login Protocol• telnet 23/tcp Telnet• telnet 23/udp Telnet• tftp 69/tcp Trivial File Transfer• tftp 69/udp Trivial File Transfer• http 80/tcp World Wide Web HTTP• http 80/udp World Wide Web HTTP• kerberos 88/tcp Kerberos• kerberos 88/udp Kerberos• pop3 110/tcp Post Office Protocol - Version

Page 8: Transport Layer

Sockets: Process Identification

• Combination of – The IP address of the host it runs on

– Port number which has been assigned to it

• Notation– <IP Address>:<Port Number>

• Eg: Socket corresponding to the HTTP server would be 41.199.222.3:80

Page 9: Transport Layer

Socket Pairs: Connection Identification

• The exchange of data between a pair of devices consists of a series of messages sent from a socket on one device to a socket on the other

• Each device will normally have multiple such simultaneous

conversations going on • A connection is established for each pair of devices for the

duration of the communication session

• Each connection is uniquely identified using the combination of the client socket and server socket

• An Eg: connection between two devices can be described using this socket pair:(41.199.222.3:80, 177.41.72.6:3022)

Page 10: Transport Layer

UDP

• The User Datagram Protocol (UDP) was developed for use by application protocols that do not require reliability, acknowledgment or flow control features at the transport layer.

• It is designed to be simple and fast, providing only transport layer addressing in the form of UDP ports and an optional checksum capability, and little else.

Page 11: Transport Layer

What UDP Does

• UDP's real task is – to take data from higher-layer protocols – place it in UDP messages– then pass down to the Internet Protocol for

transmission

• The basic steps for transmission using UDP are:

– Higher-Layer Data Transfer– UDP Message Encapsulation– Transfer Message To IP

Page 12: Transport Layer

What UDP Does Not • UDP does not

• Establish connections before sending data. • Provide acknowledgments to show that data was

received. • Provide any guarantees that its messages will

arrive. • Detect lost messages and retransmit them. • Ensure that data is received in the same order

that they were sent. • Provide any mechanism to manage the flow of

data between devices, or handle congestion.

Page 13: Transport Layer

Use of UDP• When an application values timely delivery

over reliable delivery• TCP’s retransmission of lost data would be of

limited or even no value. • A simple Application is able to handle the

potential loss of an IP datagram and other features of TCP are not required.

• UDP is also used for applications that require multicast or broadcast transmissions– TCP is only supported for unicast communication

between two devices.

Page 14: Transport Layer

UDP datagram

Page 15: Transport Layer

UDP pseudo header

Page 16: Transport Layer

TCP• The primary transport layer protocol in the

TCP/IP suite is the Transmission Control Protocol (TCP).

• TCP is a connection-oriented, acknowledged, reliable, fully-featured protocol designed to provide applications with a reliable way to send data using the unreliable Internet Protocol.

Page 17: Transport Layer

TCP

• It allows applications – To send bytes of data as a stream of bytes– Automatically packages them into appropriately-

sized segments for transmission.

• It uses a special sliding window acknowledgment system – To ensure that all data is received by its recipient– To handle necessary retransmissions– To provide flow control for connected devices to

manage the rate at which data is sent.

Page 18: Transport Layer

TCP functions

• Addressing/Multiplexing

• Connection Establishment, Management and Termination

• Data Handling and Packaging

• Data Transfer • Providing Reliability and Transmission Quality

Services

• Providing Flow Control and Congestion Avoidance Features

Page 19: Transport Layer

Functions Not Performed By TCP

• Specifying Application Use

• Providing Security

• Maintaining Message Boundaries

• Guaranteeing Communication

Page 20: Transport Layer

TCP Characteristics

• Connection-Oriented

• Bidrectional • Multiply-Connected and Endpoint-Identified

• Reliable

• Acknowledged

• Stream-Oriented

• Data-Unstructured

• Data-Flow-Managed

Page 21: Transport Layer

TCP Stream

Page 22: Transport Layer

TCP segment

Page 23: Transport Layer

TCP FSM

• The TCP finite state machine describes the sequence of steps taken by both devices in a TCP session as they establish, manage and close the

connection. • Three types of message that control transitions between states

o SYN: A synchronize message, used to initiate and establish a connection. It is so named since one of its functions is to synchronizes sequence numbers between devices.

o FIN: A finish message, which is a TCP segment with the FIN bit set, indicating that a device wants to terminate the connection.

o ACK: An acknowledgment, indicating receipt of a message such as a SYN or a FIN.

Page 24: Transport Layer

The Simplified TCP Finite State Machine

Page 25: Transport Layer

3 way handshake

Page 26: Transport Layer

Sequence number synchronisation

• As part of the process of connection establishment, each of the two devices in a TCP connection informs the other of the sequence number it plans to use for its first data transmission by putting the preceding sequence number in the Sequence Number field of its SYN message.

• The other device confirms this by incrementing that value and putting it into the Acknowledgment Number field of its ACK, telling the other device that is the sequence number it is expecting for the first data transmission.

• This process is called sequence number synchronization.

Page 27: Transport Layer

Sequence number Synchronisation

Page 28: Transport Layer

Additional parameters (opt) exchanged during connection setup

o Window Scale Factor: To specify larger window sizes than would normally the 16-bit size of the TCP Window field.

o Selective Acknowledgment Permitted: To use the optional selective acknowledgment feature to allow only certain lost segments to be retransmitted.

o Alternate Checksum Method: Specify an alternative method of performing checksums Normal Connection Termination than the standard TCP mechanism.

Page 29: Transport Layer

Normal Connection Termination • Device sends a FIN message to tell the other

device that it wants to end the connection• It is s acknowledged by other Device.• When the responding device is ready, it too

sends a FIN.• This response FIN that is acknowledged• After waiting a period of time for the ACK to

be received, the session is closed.

Page 30: Transport Layer

TCP close (connection termination)

Page 31: Transport Layer

The TIME-WAIT State• The TIME-WAIT state is required for two main

reasons.– The first is to provide enough time to ensure that the ACK is

received by the other device, and to retransmit it if it is lost. – The second is to provide a “buffering period” between the

end of this connection and any subsequent ones. If not for this period, it is possible that packets from different connections could be mixed, creating confusion.

• The standard specifies that the client should wait double a particular length of time called the maximum segment lifetime (MSL) before finishing the close of the connection.

Page 32: Transport Layer

Transmission control block• Since each connection is distinct, we must maintain data about each

connection separately.

• TCP uses a special data structure for this purpose, called a transmission control block (TCB).

• Each device maintains its own TCB for the connection.• TCB contains all information about the connection, such as:-

– Two socket numbers that identify it

– Pointers to buffers where incoming and outgoing data are held.

– The TCB is also used to implement the sliding window mechanism. • It holds variables that keep track of the number of bytes received and

acknowledged, • Bytes received and not yet acknowledged• Current window size and so forth

Page 33: Transport Layer

TCB set up

• Before the process of setting up a TCP connection can begin, the devices on each end must perform some “prep work”.

• One of the tasks required to prepare for the connection is to set up the TCB that will be used to hold information about it.

• This is done right at the very start of the connection establishment process, when each device just transitions out of the CLOSED state

Page 34: Transport Layer

TCP requirements

• Two key requirements of the protocol:o Reliability: Ensuring that data that is sent

actually arrives at its destination, and if not, detecting this and re-sending the data.

o Data Flow Control: Managing the rate at which data is sent so that it does not overwhelm the device that is receiving it.

Page 35: Transport Layer

PAR

• Reliability in communications follow a rule – a device to send back an acknowledgment each

time it successfully receives a transmission

• If a transmission is not acknowledged after a period of time, it is retransmitted by its sender

• This system is called positive acknowledgment with retransmission (PAR)

• One drawback: the transmitter cannot send next message until the previous is acknowledged.

Page 36: Transport Layer

PAR

Page 37: Transport Layer

TCP ACK & Retransmission• TCP acknowledgments are cumulative• Tell a transmitter that all the bytes up to the

sequence number indicated in the acknowledgment were received successfully.

• If bytes are received out of order, they cannot be acknowledged until all the preceding bytes are received.

• TCP includes a method for timing transmissions and retransmitting lost segments if necessary.

Page 38: Transport Layer

Managing Retransmissions • Each time a segment is sent, a copy is Placed On

Retransmission Queue• Timer Starts at a predetermined value• Counts down over time• If an acknowledgment is received for a segment before its

timer expires, the segment is removed from the retransmission queue

• If the timer expires before an acknowledgment is received, the segment is retransmitted

• No guarantee that a retransmitted segment will be received• If not, Retransmission timer is reset, the segment will be

retransmitted again and the process repeated

Page 39: Transport Layer

Policies For Dealing with Retransmission

• Retransmit Only Timed-Out Segments

• Retransmit All Outstanding Segments

• TCP selective acknowledgment

Page 40: Transport Layer

Retransmission Time

• Length of time for retransmission timer is very important

• If it is set too low– A segment actually received might be retransmitted

– didn't wait long enough for the acknowledgment

• if it is set too long– waste time waiting for an acknowledgment that will

never arrive

– reducing overall performance

Page 41: Transport Layer

Choosing Retransmission time

• Ideally, the retransmission timer should be of value just slightly larger than the round-trip time (RTT)

• How to determine RTT?– Differences in TCP Connection Distances. – Transient Delays and Variability: The amount of time it

takes to send data between any two devices will vary over time due to various happenings on the internetwork: fluctuations in traffic, router loads and so on.

Page 42: Transport Layer

Adaptive Retransmission Based RTT

• TCP uses a dynamic, or adaptive retransmission scheme

• Average RTT value for the connection• Asmoothing formula:

– New RTT = (a * Old RTT) + ( (1-a) * Newest RTT Measurement); 0 < a < 1

– a ~ 1 -> better smoothing, slow reaction– a ~ 0 -> fast reaction

Page 43: Transport Layer

RTT Calculation by Karn's Algorithm

• Karn's algorithm-Inventor, Phil Karn – Does not use measured round-trip times– Eliminates problem of acknowledgment ambiguity

• Start by setting the timer, based on the current average round-trip time

• On retransmission, the timer is not reset to the same value but is “backed off” (increased) using a multiplier (typically 2) to give the retransmission more time to be received

• The timer continues to be increased until a retransmission is successful, up to a certain maximum value

Page 44: Transport Layer

RTT Calculation by Karn's Algorithm

• The round-trip timer is kept at the longer (backed-off) value until a valid round-trip time can be measured on a segment that is sent and acknowledged without retransmission

• This permits a device to respond with longer timers temporarily, while eventually having the round-trip time settle back to a long-term average when normal conditions resume

Page 45: Transport Layer

TCP sliding window • A variation on the enhanced PAR system • To support TCP’s stream orientation• Each device keeps track of the status of the

byte stream• Dividing Data into four conceptual categories:

– Bytes sent and acknowledged– Bytes sent but not yet acknowledged– Bytes not yet sent but that can be sent

immediately– Bytes not yet sent that cannot be sent until the

recipient signals that it is ready for them.

Page 46: Transport Layer

Data Stream categories

Page 47: Transport Layer

Send, usable windows

• The send window is the key to the entire TCP sliding window system: – it represents the maximum number of

unacknowledged bytes a device is allowed to have outstanding at once.

• The usable window is the amount of the send window that the sender is still allowed to send at any point in time; – it is equal to the size of the send window less the

number of unacknowledged bytes already transmitted.

Page 48: Transport Layer

Send and usable window

Page 49: Transport Layer

Send and usable window

Page 50: Transport Layer

Implementing sliding window

• Three essential fields in the TCP segment– The Sequence Number field indicates the number

of the first byte of data being transmitted. – The Acknowledgment Number is used to

acknowledge data received by the device sending this segment.

– The Window field tells the recipient of the segment the size to which it should set its send window

Page 51: Transport Layer

Window slide

• When a device gets an acknowledgment for a range of bytes, it knows they have been successfully received by their destination.

• It moves them from the “sent but unacknowledged” to the “sent and acknowledged” category.

• This causes the send window to slide to the right, allowing the device to send more data.

Page 52: Transport Layer

TCP window size management

• The receiver on receipt of segment must– Send Acknowledgement– Transfer data from buffer to application

• Receiver delay in transfer can happen

• Danger of buffer overflow

• Varying window size to manage data flow

Page 53: Transport Layer

Flow control

• The TCP sliding window system is used not just for ensuring reliability through acknowledgments and retransmission

• it is also the basis for TCP’s flow control mechanism. • By increasing or reducing the size of its receive window

– a device can raise or lower the rate at which its connection partner sends it data.

– In the case where a device becomes extremely busy, it can even reduce the receive window to zero, closing it

– this will halt any further transmissions of data until the window is reopened

Page 54: Transport Layer

Shrinking window

Page 55: Transport Layer

Silly window syndrome

• Sliding window mechanism does not ensure a min size of segment

• Shrinking window can result in inefficient transmission of small size segment

Page 56: Transport Layer

Silly window syndrome

Page 57: Transport Layer

SWS avoidance algorithm

• Receiver SWS avoidance– Restrict moving right edge of window by too

small amount– Reduce window size to 0– Right edge be moved by half buffer size or

MSS whichever is less

Page 58: Transport Layer

Sender SWS avoidance algorithm

• Nagle’s algorithm – John Nagle– Data can be immediately sent as long as all sent

data is acknowledged– When there is unacknowledged data

• Do not send till all data acknowledged

• Send after accumulating data for full segment