Professional Documents
Culture Documents
UNIT-4
BY
PROF. PRITEE .H. RAUT
(MARKS-18)
4.1. INTRODUCTION
The transport layer is the fourth layer in the open system interconnection (OSI) model, and is
responsible for end-to-end communication over a network.
It provides logical communication between application processes running on different hosts
within a layered architecture of protocols and other network components.
Source Port - This 16 bits information is used to identify the source port of the packet.
Destination Port - This 16 bits information, is used identify application level service on destination machine.
Length - Length field specifies the entire length of UDP packet (including header). It is 16-bits field and
minimum value is 8-byte, i.e. the size of UDP header itself.
Checksum -which is used in error checking -- its use is required in IPv6 and optional in IPv4.
UDP application
Here are few applications where UDP is used to transmit data:
UDP Disadvantages:
TCP is connection oriented protocol. TCP established connection or session before sending
actual data.
TCP provides flow control
TCP provides Error control
TCP provides congestion control
TCP is reliable protocol. TCP ensures that the data reaches intended destination in the same
order it was sent.
TCP provides error-checking and recovery mechanism.
TCP provides end-to-end communication.
TCP operates in Client/Server point-to-point mode.
TCP provides full duplex server, i.e. it can perform roles of both receiver and sende
TCP SERVICES(4M)(S-22)
Following are some of the services offered by TCP to the processes at the application layer.:
At the transport layer, TCP groups a number of bytes together into a packet called
segment. TCP adds a header to each segment and delivers the segment to the IP
for transmission.
The segment is encapsulated in IP datagram and transmitted. This entire operation
is transparent to the receiving process. The segments may be received out of
order, lost, or corrupted and resent. All these are handled by TCP with the
receiving process unaware of any activities.
Full duplex service.
TCP offers full-duplex service, in which data can flow in both directions at the
same time. Each TCP then has a sending and receiving buffer, and segments move
in both directions.
When a process at site A wants to send and receive data from another process at
site B, the following occurs:
Unlike UDP, TCP provides connection oriented service. It defines 3 different phases:
Connection establishment
Data transfer
Connection termination
Process-to-Process Communication
TCP provides process-to-process communication using port numbers. The
following table lists some well-known port numbers used by TCP.
FEATURES OF TCP(4m)
A. Connection-oriented
B. Flow Control
C. Error Control
D. Congestion Control
Connection-oriented
It is a connection-oriented service that means the data exchange occurs only after
the connection establishment. When the data transfer is completed, then the
connection will get terminated.
Flow Control
Flow control tells the sender how much data should be sent to the receiver so that it is not lost. This
mechanism makes the sender wait for an acknowledgment before sending the next data.
This will avoid data overflow at the receiver.
There are two ways to control the flow of data:
1. Stop and Wait Protocol
2. Sliding Window Protocol
Error Control
Error Control in the data link layer is a process of detecting and retransmitting the data which has
been lost or corrupted during the transmission of data.
Any reliable system must have a mechanism for detecting and correcting such errors.
Types of error
Single bit Error: When there is a change in only one bit of the sender's data then it is called a single bit error.
Example: If the sender sends 101(5) to the receiver but the receiver receives 100(4) then it is a single bit error.
101(sent bits) → 100(received bits)
Burst Error: When there is a change in two or more bits of the sender’s data then it is called a burst error.
Example: If the sender sends 1011(11) to the sender but the receiver receives 1000(8) then it is a burst error.
1011(sent bits) → 1000(received bits)
Congestion Control (sample-4m)
A state occurring in network layer when the message traffic is so heavy that it slows down
network response time, congestion occurs.
TCP controls congestion by means of Window mechanism. TCP sets a window size telling
the other end how much data segment to send.
Effects of Congestion
1. As delay increases, performance decreases.
2. If delay increases, retransmission occurs, making situation worse
TCP segment consists of data bytes to be sent and a header that is added to the data by TCP
Source Port Address –
16 bit field that holds the port address of the application that is sending the data segment.
Sequence Number –
Sequence number is a 32 bit field.
TCP assigns a unique sequence number to each byte of data contained in the TCP segment.
This field contains the sequence number of the first data byte.
Acknowledgement Number –
32 bit field that holds the acknowledgement number
It contains sequence number of the data byte that receiver expects to receive next from the sender.
It is always sequence number of the last received data byte incremented by 1.
Header Length-
These are 6 1-bit control bits that control connection establishment, connection termination, connection abortion,
flow control, mode of transfer etc.
URG: When URG bit is set to 1,It indicates the receiver that certain amount of data within the current segment is urgent.
ACK: Acknowledgement number is valid( used in case of cumulative acknowledgement)
PSH: Request for push. PSH bit is used to push the entire buffer immediately to the receiving application.
RST: Reset the connection
SYN: Synchronize sequence numbers
FIN: Terminate the connection
Window size –
This field tells the window size of the sending TCP in bytes.
Window size is a 16 bit field.
It contains the size of the receiving window of the sender.
It advertises how much data (in bytes) the sender can receive without acknowledgement.
Thus, window size is used for Flow Control.
Checksum –
This field holds the checksum for error control. It is mandatory in TCP as opposed to UDP.
Checksum is a 16 bit field used for error control.
It verifies the integrity of data in the TCP payload.
Sender adds CRC checksum to the checksum field before sending the data.
Receiver rejects the data that fails the CRC check.
Urgent pointer –
This field (valid only if the URG control flag is set) is used to point to data that is urgently required that needs to reach
the receiving process at the earliest. The value of this field is added to the sequence number to get the byte number of
the last urgent byte. Urgent pointer is a 16 bit field.
This field is considered valid and evaluated only if the URG bit is set to 1 .
Options-
• Options field is used for several purposes.
• The size of options field vary from 0 bytes to 40 bytes.
Padding-
• Addition of dummy data to fill up unused space in the transmission unit and make it conform to the standard
size is called as padding.
• Options field is used for padding.
State the use of 6 flags in TCP header.(winter-19) 2-M
There are 6, 1-bit control bits that control connection establishment,
termination, abortion, flow control etc..
URG: When URG bit is set to 1,It indicates the receiver that certain amount of data within the current segment
is urgent.
PSH: Request for push. PSH bit is used to push the entire buffer
immediately to the receiving application.
When two clients on the same machine connect to the same server, the OS on that machine will generate
distinct TCP port numbers for each connection. It is possible for a client to request a specific TCP port to
connect from using the bind() system call; however, if two clients request the same port, only the first request
will succeed.
TCP Three-Way Handshake Process(W-19) 4M
Three-Way HandShake or a TCP 3-way handshake is a process which is used in a TCP/IP network to
make a connection between the server and client.
It is a three-step process that requires both the client and server to exchange synchronization and
acknowledgment packets before the real data communication process starts.
1.Connection establishment.
2.Data transfer.
3.Connection termination.
TCP CONNECTION ESTABLISHMENT (W-19) 4M
To establish a connection, the three-way (or 3-step) handshake occurs:
SYN:
The active open is performed by the client sending a SYN to the server.
The client sets the segment’s sequence number to a random value J.
SYN-ACK:
In response, the server replies with a SYN-ACK.
The acknowledgment number is set to one more than the received sequence number (J + 1), and the
sequence number that the server chooses for the packet is another random number, (K).
ACK:
Finally, the client sends an ACK back to the server.
The sequence number is set to the received acknowledgement value i.e. (J+1), and the
acknowledgement number is set to one more than the received sequence number i.e. (K+ 1).
CONNECTION ESTABLISHMENT DIAGRAM
At this point, both the client and server have received an acknowledgment of the connection.
The steps 1, 2 establish the connection parameter (sequence number) for one direction and it
is acknowledged.
The steps 2, 3 establish the connection parameter (sequence number) for the other direction
and it is acknowledged. With these, a full-duplex communication is established.
TCP CONNECTION TERMINATION
Both sides of a connection can terminate a TCP connection, and even one-sided termination is also
possible. This is also known as a half-open connection, whereby the other side is still allowed to
transfer data even if one side has already disconnected.
The individual steps of two-way termination (initiated by the client for the sake of simplicity in this
example) can be summarized as follows:
1. The client sends a FIN segment to notify the server that it no longer wants to send data. It sends
its own sequence number M, just as it does when the connection is established.
2. The server acknowledges receipt of the package with an ACK segment that contains the sequence
number plus 1 i.e (M+1).
3. When the server has finished the data transfer, it also sends a FIN packet, to which it adds its
sequence number (N).
4. Now it is the client's turn to send an ACK packet including the sequence number plus 1 i.e (N+1),
which officially terminates the TCP connection for the server.
Note: The red line is for a client; the blue line is for a server
TCP STATE TRANSITION DIAGRAM (6M)W-19
TCP State Transition Diagram
A TCP connection goes through a series of states during its lifetime. Figure shows the state transition
diagram.
Each state transition is indicated by an arrow, and the associated label indicates associated events and
actions.
Connection establishment begins in the CLOSED state and proceeds to the ESTABLISHED state.
Connection termination goes from the ESTABLISHED state to the CLOSED state.
The normal transitions for a client are indicated by thick solid lines, and the normal transitions for a server are
denoted by dashed lines.
Thus when a client does an active open, it goes from the CLOSED state, to SYN_SENT, and then to
ESTABLISHED.
The server carrying out a passive open goes from the CLOSED state, to LISTEN, SYN_RCVD, and then to
ESTABLISHED.
The client normally initiates the termination of the connection by sending a FIN. The associated state goes
from the ESTABLISHED state, to FIN_WAIT_1 while it waits for an ACK, to FIN_WAIT_2 while it waits
for the other side's FIN, and then to TIME WAIT after it sends the final ACK. When the TIME_WAIT 2MSL
period expires, the connection is closed.
Stream Control Transmission Protocol (SCTP)
Multihoming is simply defined as having connection to the Internet through more than one Internet Service
Provider (ISP).
A TCP connection has involves one source and one destination IP address. This means that even if the sender
and receiver is a multihomed (connected to more than one physical address with multiple IP addresses), only
one IP addresses per end can be utilized during the connection .
An SCTP on the other hand supports multihoming service. Multihoming allows two endpoints to set up an
association with multiple IP addresses for each endpoint .Therefore, sending and receiver can define multiple
IP addresses. If one path fails, another interface can be used for data delivery without interpretation.
Like TCP, SCTP offers full-duplex service, in which data can flow in both
directions at the same time. Each SCTP then has a sending and receiving buffer,
and packets are sent in both directions.
Features of SCTP
Some important features of SCTP are as stated below:
The unit of data in TCP is a byte. Data transfer in TCP is controlled by numbering bytes by using a sequence number.
On the other hand, the unit of data in SCTP is a DATA chunk that may or may not have a one-to-one relationship with
the message coming from the process because of fragmentation.
Stream Identifier
In TCP, there is only one stream in each connection. In SCTP, there may be several streams in each association. Each
stream in SCTP needs to be identified by using a stream identifier (SI). Each data chunk must carry the SI in its header
so that when it arrives at the destination, it can be properly placed in its stream. The 51 is a 16-bit number starting from
O.
Stream Sequence Number
When a data chunk arrives at the destination SCTP, it is delivered to the appropriate stream and in the proper order. This
means that, in addition to an SI, SCTP defines each data chunk in each stream with a stream sequence number (SSN).
Packets
In TCP, a segment carries data and control information. Data is carried as a collection of bytes; control information is
defined by six control flags in the header. The design of SCTP is totally different: data is carried as data chunks; control
information is carried as control chunks.
Flow Control
Like TCP, SCTP implements flow control to avoid overwhelming the receiver.
Error Control
Like TCP, SCTP implements error control to provide reliability. TSN numbers and acknowledgement numbers are used for
error control.
Congestion Control
Like TCP, SCTP implements congestion control to determine how many data chunks can be injected into the network.
PACKET
FORMAT
PACKET FORMAT OF SCTP
PACKET FORMAT
The Stream Control Transmission Protocol (SCTP) has a simpler basic packet structure than
TCP. Each consists of two basic sections:
The common header, which occupies the first 12 bytes. In the adjacent diagram.
The data chunks, These chunks can carries user information data or controlled information .
Common Header Fields
Every SCTP packet contains the Common header as seen above. The header contains four
different fields and is set for every SCTP packet.
Source port - This field gives the source port of the packet, which port it was sent from. The same
as for TCP and UDP source port.
Destination port - This is the destination port of the packet, ie., the port that the packet is going
to. It is the same as for the TCP and UDP destination port.
Verification Tag - The verification tag is used to verify that the packet comes from the correct
sender.
Checksum - Uses the cyclic redundancy check (CRC32) algorithm to detect errors that might
have been introduced during data transmission.
Data Chunk Fields
Chunk type:-
Identifies the type of information contained in the Chunk data.
Chunk flags.
This is 8 bit field define special flags that a particular chunk may need.
Chunk length.
This size of the chunk in bytes including the Chunk type, Chunk flags, Chunk length, and Chunk data
fields.
if chunk not carries no information or data the Length field will be set to 4.
Chunk data.
the chunk carries user data.
Receiver Site
The receiver has one buffer (queue) and three variables. The queue holds the
received data chunks that have not yet been read by the process.
The first variable holds the last TSN received, cumTSN.
The second variable holds the available buffer size; winsize.
The third variable holds the last accumulative acknowledgment, lastACK. The
following figure shows the queue and variables at the receiver site.
Flow control at receiver site
1. When the site receives a data chunk, it stores it at the end of the buffer (queue) and
subtracts the size of the chunk from winSize. The TSN number of the chunk is stored
in the cumTSN variable.
2. When the process reads a chunk, it removes it from the queue and adds the size of
the removed chunk to winSize (recycling).
3. When the receiver decides to send a SACK, it checks the value of lastAck; if it is
less than cumTSN, it sends a SACK with a cumulative TSN number equal to the
cumTSN. It also includes the value of winSize as the advertised window size.
Sender Site:
The sender has one buffer (queue) and three variables: curTSN, rwnd, and inTransit, as shown in the
following figure. We assume each chunk is 100 bytes long.
Flow control at sender site
1. The buffer carries the chunks generated by the process which have ready to be sent or have
been sent.
2. The first variable carries CurTSN which refers to the next chunk which is to be sent. The
second variable rwnd contains the last advertised value by the receiver in bytes.
3. The in transit i.e third variable holds number of bytes in transit, bytes which have been sent but
not acknowledged yet.
Error Control in SCTP
SCTP, like TCP, is a reliable transport layer protocol. It uses a SACK chunk to report the state of
the receiver buffer to the sender. Each implementation uses a different set of entities and timers
for the receiver and sender sites.
Receiver Site
The last acknowledgment sent was for data chunk 20. The available window size is
1000 bytes.
Chunks 21 to 23 have been received in order.
The first out-of-order block contains chunks 26 to 28. The second out-of-order block
contains chunks 31 to 34.
A variable holds the value of cumTSN. An array of variables keeps track of the
beginning and the end of each block that is out of order. An array of variables holds
the duplicate chunks received. Note that there is no need for storing duplicate chunks
in the queue and they will be discarded.
Sender Site
At the sender site, it needs two buffers (queues): a sending queue and a retransmission queue. We
also use the three variables rwnd, inTransit, and curTSN as described in the previous section. The
following figure shows a typical design.
1. The sending queue holds chunks 23 to 40. The chunks 23 to 36 have already been sent, but not acknowledged; they are
outstanding chunks.
2. The curTSN points to the next chunk to be sent (37). We assume that each chunk is 100 bytes, which means that 1400
bytes of data (chunks 23 to 36) is in transit. The sender at this moment has a retransmission queue. When a packet is
sent, a retransmission timer starts for that packet (all data chunks in that packet). Some implementations use one single
timer for the entire association, but we continue with our tradition of one timer for each packet for simplification.
3. When the retransmission timer for a packet expires, the chunks in that packet are moved to the retransmission queue to
be resent. These chunks are considered lost, rather than outstanding. The chunks in the retransmission queue have
priority.
SCTP Assosiation