Professional Documents
Culture Documents
Transport Layer: N.Jagadish Kumar
Transport Layer: N.Jagadish Kumar
Transport Layer: N.Jagadish Kumar
N.Jagadish kumar
Assistant Professor
Information Technology Department
Velammal Institute of technology
Difference between Packet& Frame
PACKET FRAME
Encapsulated unit created at the Network Encapsulated unit created at the data link
layer of the OSI model. layer of the OSI
Thus, a packet typically contains logical Thus a frame typically contains physical
address information address information.
Transport Layer
• The Transport layer is responsible for the
delivery of a message from one process to
another.
Process to process means:
It is not just a source to destination delivery i.e
from one computer to another.
It is a delivery from a specific process on one
computer to a specific process on the other.
What a Network layer actually does?
It oversees source-to-destination delivery of
individual packets , it does not recognize any
relationship between those packets.
It treats each one independently , as though
each piece belongs to a separate message.
How transport layer differ from
network layer?
• The transport layer , ensures that the whole
message arrives intact and in order ,
overseeing both error control and flow control
at the source –to-destination level.
Transport Layer
Transport layer protocol
• A transport layer protocol can be either
connectionless or connection-oriented.
• UDP-Connectionless protocol-Simple
• TCP-Connection oriented protocol-Complex
• SCTP-Connection oriented protocol-Designed for
Multimedia application
Sending and receiving processes may not write or read data at the same speed,
TCP needs buffers for storage
….
Sending side:
• The white section contains empty chamber that can be filled by
the sending process.
• The gray area holds bytes that have been sent but not yet
acknowledged.
• The colored area contain byte to be sent by the sending TCP
Receiving side:
• The white area contains empty chamber to be filled by bytes
received from the network
• The colored area contain received bytes that can be read by
the receiving process
• When a byte is read by the receiving process , the chamber is
recycled and added to the pool of empty chamber
Segments
• Although buffering handles the speed between
sending and receiving processes , we need one
more step before we can send data.
• The IP layer in between TCP needs to send data in
packets , not as a stream of bytes.
• So at Transport layer TCP groups number of bytes
together into a packet called a SEGMENT.
• TCP add header to each segment and delivers the
segment to the IP layer for transmission.
• The segments are encapsulated in IP datagram and
transmitted.
TCP Segment
Field Purpose
Source Port Identifies originating application
Destination Port Identifies destination application
Sequence Number Sequence number of first octet in the segment-TCP generates a random no between 0-2^32-1 for the no of first
byte
Acknowledgment # Sequence number of the next expected octet (if ACK flag set)
Len Length of TCP header in 4 octet units-Header length can be between 20 and 60 bytes.
Flags TCP flags: SYN, FIN, RST, PSH, ACK, URG
Window Number of octets from ACK that sender will accept
Checksum Checksum of IP pseudo-header + TCP header + data
Urgent Pointer Pointer to end of “urgent data”
Options Special TCP options such as MSS and Window Scale
Control field
• Sequence Number : In TCP all the data byte is
assigned with a sequence no, so the sequence
no of the first byte in a segment is the
sequence no of the segment too.
• Acknowledgment number: Sequence number
of the next expected octet (if ACK flag set)
• Control fields: control bits or flags .These bits
enable Flow control , connection
establishment and termination , connection
abortion and the mode of data transfer in TCP.
• Checksum : The calculation of checksum is
same as UDP but it is not optional like UDP
,here it is mandatory
………
Urgent pointer:
• If the sending application program wants to send urgent
bytes to the receiver application .
• The sending application program tells the sending TCP
that the piece of data is urgent.
• The sending TCP creates a segment and insert urgent
data at the beginning of the segment. and Set the URG
bit.
• The urgent pointer field in the header defines the end of
the urgent data and the start of normal data.
Window Size:
– Each side of the connection advertises the window size
– Window size is the maximum number of bytes that a
receiver can accept.
– Maximum window size is 216-1= 65535 bytes
TCP Connection Management
TCP connection oriented transmission requires
three phases:
• Connection Establishment
• Data Transfer
• Connection termination
Connection Establishment
TCP transmits data in full-Duplex mode .When two
TCP’s in two machines are connected , they are
able to send segment to each other
simultaneously.
So each party must initialize communication and
get approval from other party before any data are
transferred.
The connection establishment in TCP is called
Three way handshaking
Three way handshaking
Example:
An application program, called the client , wants to
make a connection with another application
program, called the server , using TCP as the
transport layer protocol.
The process starts with server. The server program
tells its TCP that it is ready to accept connection .
this is called request for a passive open.
The client application tells its TCP that it need to
connect to a particular server . this is called request
for active open.
TCP can now starts the three –way handshaking
process.
Connection establishment using three-way handshake
seq: 8000
UAPRS F
SYN
seq: 15000
ack: 8001
nd: 5000
U A P R S F rw
SYN + ACK
seq: 8000
ack: 15001
UAPRS F
rwnd: 10000
ACK
48
………
1.The client sends the first segment , a SYN
segment, in which only the SYN flag is set . This
segment is for synchronization of sequence
numbers.
2.The server sends the second segment , a SYN+ACK
segment , with 2 flag bits set: SYN & ACK . This
segment has dual purpose.
I ) Synchronization of sequence number in the other
direction.
II) Acknowledgment for the client SYN segment
3.The client sends the third segment . this is just an
ACK segment . It acknowledges the receipt of the
second segment with the ACK flag and
Acknowledgment number.
Data Transfer
Connection Termination
51
Connection termination
• Any of the two parties involved in exchanging
data (client or server) can close the connection ,
but usually initiated by client.
1.If the client process wants to stop it send a close
command to the client TCP , after receiving a close
command from the client process, TCP sends a FIN
segment in which the FIN flag is set .
The FIN segment can include last chunk of data
sent by the client.
……..
2.The server TCP ,after receiving the FIN
segment informs its process about the situation
and sends the second FIN segment ,a FIN +ACK
segment, to confirm the receipt of FIN segment
from the client and at the same time to
announce the closing of the connection in other
direction.
This segment can also contain the last chunk of
data from the server.
…..
3.The client TCP sends the last segment ,
an ACK segment , to confirm the receipt of the
FIN segment from the TCP server . this segment
contains the acknowledgment number , which is
1 plus the sequence number received in the FIN
segment from the server.
TCP-FLOW CONTROL
• TCP uses sliding window to handle the flow
control.
• TCP sliding window looks like the Go-Back-N
protocol because it does not use NAKs ; it
looks like selective repeat because the
receiver holds the out of order segment until
the missing one arrives.
Difference between TCP-sliding
window and data link layer sliding
TCP-SLIDING WINDOW
window
DATA LINK LAYER-SLIDING WINDOW
Sliding window of TCP is byte oriented Sliding window of data link layer is frame
oriented
TCP sliding window is variable size Data link layer sliding window is fixed size
Sliding window
• The source does not have to send a full
window’s worth of data.
• The size of the window can be increased or
decreased by the destination
• The destination can send an acknowledgment
at any time
….
• The bytes inside the window are the bytes
that can be transit ; they can be sent without
worrying about acknowledgment
• The window has two wall : one left and one
right
• The window is opened , closed or shrunk . this
activities are in the control of receiver , not
the sender . The sender should obey.
………
• Opening a window means moving the right wall to the
right . This allows more new bytes in the buffer that are
eligible for sending.
• Closing the window means moving the left wall to the
right . This means that some bytes have been
acknowledged and the sender need not worry about
them anymore.
• Shrinking the window means moving the right wall to
the left . this means revoking the eligibility of some
bytes for sending.
• Receiver window( rwnd) : It is the number of bytes the
other end can accept before its buffer overflow
• Congestion window: The value in congestion window is
determined by the network to avoid congestion.
Example of sliding window
Error control
• Error control includes mechanism for:
Detecting corrupted segment , Lost segment ,
out-of-order segments and duplicate segment
. Error control also includes a mechanism for
correcting errors after they are detected.
Error detection and correction in TCP is
achieved through three simple tools:
Checksum , acknowledgment , Time out.
Checksum
• TCP use 16-bit checksum that is mandatory in
every segment.
• The checksum field in a segment is used to
check the corrupted segment . If the segment
is corrupted , it is discarded by the destination
TCP.
Acknowledgment
• TCP uses acknowledgment to confirm the
receipt of data segment.
• Control segment that carry no data but only
the sequence no also acknowledged.
• ACK segment are never acknowledged.
Retransmission
• The heart of the error control mechanism is
retransmission of the segment . when a
segment is corrupted , lost, or delayed , it is
retransmitted.
In recent TCP implementation ,retransmission
is occurs ,when a retransmission timer expires
or when the sender receives three duplicate
ACKs,
Retransmission after RTO
• Recent implementation TCP maintains one
retransmission time-out(RTO) timer for all
outstanding(sent , but not acknowledged)
segments.
• When the timer expires , the earliest outstanding
segment is retransmitted even though lack of ACK
is due to delayed segment , a delayed ACK , or a
lost ACK,
• RTO timer will never set for a segment that
carries only an acknowledgment.
Retransmission after three duplicate
ACK segments
• TCP was originally designed to discard all out –of-
order segments , resulting in retransmission of
the missing segment and then following segment.
• But in today’s implementation out-of-order
segments are not discarded instead they store
them temporarily until the missing arrives , but if
the buffer exceeds problem arise.
• To alleviate this situation , today’s implement
follows three-duplicate-ACK rule and retransmit
the missing segment immediately . This is called
Fast retransmission.