Transport Layer: N.Jagadish Kumar

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 66

TRANSPORT LAYER

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

Ex: IP-Packet Ex:Ethernet Frame


Packet contains Source and destination IP Frame contains Source and destination MAC
address along with Top layer data address along with Top layer data.

Segment is encapsulated with in a packet. packet is encapsulated within a frame.


Hence segment is the data part Hence packet is the data part

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

• (Stream control transport protocol)


PDU(SEGMENT)
• In the Transport layer a message is normally
divided into transmittable segment.
• UDP treats each segment separately
• TCP creates a relationship between the
segments using sequence numbers.
Connectionless transport layer
• A connectionless transport layer treats each
segment as an independent packet and
delivers it to the transport layer at the
destination machine.
• The packets are not numbered ; they may be
delayed or lost or may arrive out of sequence.
• There is no acknowledgement either.
• UDP is connectionless…
Connection –oriented transport layer
• A connection oriented transport layer makes a
connection with the transport layer at the
destination machine first before delivering the
packets.
• After all the data is transferred , the
connection is terminated.
• TCP and SCTP are Connection oriented…
Reliable versus unreliable
Transport layer service can be reliable or unreliable
• If the application layer program needs reliability,
TCP &SCTP protocol will implement flow and
error control at the transport layer . But it is
slower and more complex service.
• If the application layer program does not need
reliability, it means most real-time application
does not demand flow and error control,but it
demand fast service. So unreliable protocol UDP
is used.
Question arises?
• If the data link layer is reliable and has flow
and error control , do we need this at
transport layer too?
Answer
YES
• Reliability at the data link layer is
between two nodes ;
• we need reliability between two ends .
• Because the network layer in the
internet is unreliable.
• So we need to implement reliability at
the transport layer.
Types of data delivery

The transport layer is responsible for


process-to-process delivery.
Addressing
• At the Data link layer, we need a MAC address
to choose ONE node among SEVERAL node.
• At the Network layer we need an IP address to
choose one Host among Millions.
• At the Transport layer we need a transport
layer address called a PORT NUMBER ,to
choose among multiple processes running on
the destination host.
• Destination port number for delivery; source port no for the reply
Port number
• Port number for a client host program defines
itself randomly by the transport layer. at this is
called ephemeral port number ranging from
49,152 to 65,535
• Port number for servers are universally
assigned by (internet assigned number
authority) called well-known port number
ranging from0 to 1023
Socket address
• Process to process delivery needs two
identifiers , IP address and port number at
each end to make a connection.
• The combination of IP address and a Port
number is called a socket address
• Client socket address defines the client process uniquely.
• Server socket address defines the server process uniquely
Socket address
It is a 48 bit address .
It is a combination of both IP Address and port number.
UDP
• The User Datagram Protocol (UDP) is called a
connectionless , unreliable transport protocol.
• UDP is so powerless , it perform process to
process communication with very limited
error checking.
• If a process wants to send a small message
and does not care much about reliability , it
can use UDP
Well-known ports used by UDP
Port Protocol Description
7 Echo Echoes a received datagram back to the sender
9 Discard Discards any datagram that is received
11 Users Active users
13 Daytime Returns the date and the time
17 Quote Returns a quote of the day
19 Chargen Returns a string of characters
53 Nameserver Domain Name Service
67 Bootps Server port to download bootstrap information
68 Bootpc Client port to download bootstrap information
69 TFTP Trivial File Transfer Protocol
111 RPC Remote Procedure Call
123 NTP Network Time Protocol
161 SNMP Simple Network Management Protocol
162 SNMP Simple Network Management Protocol (trap)
User datagram format
• UDP packets , called User datagrams , have a
fixed-size header of 8 byte.
1. Source Port Number :
• This is the Port number used by the process
running on the machine
• It is 16 bit long ,means port number can range
from 0 to 65,535.
• If the source host is client an ephemeral port
number is chosen by the UDP for that particular
process requested.
• If the source host is server the port number is a
well-known port number.
2.Destination Port Number:
• This port number used by the process
running on the destination host.
• It is also 16 bit long
• If the destination host is a server(client
sending a request)the port number ,is a well
known port number most case.
• If the destination host is the client(a server
sending a response),the port number is an
ephemeral port number most case.
3.LENGTH :
• This is a 16 bit field that defines the total
length of the user datagram , Header plus
Data.
4.CHECKSUM
• This field is used to detect errors over the
entire user datagram(header plus data)
UDP Checksum
UDP checksum includes three sections:
• A pseudo header
• UDP header
• Data coming from application layer.
Pseudo Header:
• It is a part of the IP packet header in which
user datagram is encapsulated.
• The reason for including Pseudo Header in
checksum is to save IP header from corrupt.
Protocol :
• The protocol field is added to ensure that the
packet belongs to UDP , not to other transport
layer protocol . value of UDP is 17.
• If this value changes during transmission , the
checksum calculation at the receiver will detect
it and UDP drops the packet . It is not delivered
to the wrong protocol.
Checksum calculation of a simple
UDP user datagram
Queues in UDP
Use of UDP
• UDP is suitable for a process that requires
simple request-response communication with
little concern for flow and error control.
• UDP is suitable transport protocol for
multicasting
• UDP is used for management process such as
SNMP
• UDP is used for some route updating protocols
such as (RIP)
THE RELIABLE , CONNECTION-BASED CHOICE

TRANSMISSION CONTROL PROTOCOL


like udp
Tcp also process to process protocol.
Tcp also uses port number
unlike udp
Tcp is a connection oriented protocol
it creates virtual connection between two
tcp’s to send data.
Tcp uses flow and error control
mechanism at transport level
TCP SERVICES
1.Process to Process Communication:
Like UDP,TCP also provides process-to-
process Communication using
port numbers.
Well-known ports used by TCP
Port Protocol Description
7 Echo Echoes a received datagram back to the sender
9 Discard Discards any datagram that is received
11 Users Active users
13 Daytime Returns the date and the time
17 Quote Returns a quote of the day
19 Chargen Returns a string of characters
20 FTP, Data File Transfer Protocol (data connection)
21 FTP, Control File Transfer Protocol (control connection)
23 TELNET Terminal Network
25 SMTP Simple Mail Transfer Protocol
53 DNS Domain Name Server
67 BOOTP Bootstrap Protocol
79 Finger Finger
80 HTTP Hypertext Transfer Protocol
111 RPC Remote Procedure Call
Stream Delivery service
In case of UDP delivery the message from a
process is added with its own header and
deliver them to IP for transmission . Each
message is called user datagram.
Neither IP nor UDP recognize any relationship
between the datagram
…….
• But in case of TCP
• It allows the sending process to send data as a
stream of bytes and allow the receiving
process to receive as a stream of bytes.
• TCP creates an virtual “tube” that carries their
data across the internet
Sending and Receiving Buffers
• Sending process Writes to stream of bytes ,
and the receiving process reads from them.
• But the sending and receiving process may not
write or read data at the same speed.
• So TCP need buffers for storage, a sending
buffer and receiving buffer.
• A circular array of 1-byte location is one way
of implementing buffer.
• These buffers also necessary for flow and
error control mechanisms.
Sending and Receiving Buffers

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

TCP groups a number of bytes together into packet called a segment


TCP Segment format

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

TCP/IP Protocol Suite 50


Connection termination using three-way handshake

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.

You might also like