You are on page 1of 86

COMPUTER NETWORKS

B.Tech III Year – I Sem


Unit 4

Transport Layer

Presented by
Dr. B.Rajalingam
Associate Professor & HOD(AI&DS)
Department of Computer Science and Engineering
St.Martin’s Engineering College
UNIT 4
• Transport Services

• Elements of Transport protocols

• Connection management

• TCP protocols

• UDP protocols

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 2


Transport Layer
• The transport layer is a 4th layer from the top.
• The main role of the transport layer is to provide the communication services
directly to the application processes running on different hosts.
• The transport layer provides a logical communication between application
processes running on different hosts.
• Although the application processes on different hosts are not physically
connected, application processes use the logical communication provided by
the transport layer to send the messages to each other.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 3


• The transport layer protocols are implemented in the end systems
but not in the network routers.
• A computer network provides more than one protocol to the network
applications.
• For example, TCP and UDP are two transport layer protocols that
provide a different set of services to the network layer.
• All transport layer protocols provide multiplexing/demultiplexing
service.
• It also provides other services such as reliable data transfer,
bandwidth guarantees, and delay guarantees.
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 4
• Each of the applications in the application
layer has the ability to send a message by
using TCP or UDP.
• The application communicates by using either
of these two protocols.
• Both TCP and UDP will then communicate
with the internet protocol in the internet layer.
• The applications can read and write to the
transport layer. Therefore, we can say that
communication is a two-way process.
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 5
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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 6


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 7


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 8


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 9


Transport Layer

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 10


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)

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 11


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 12


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…

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 13


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…

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 14


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 15


Types of data delivery

The transport layer is responsible for


10 November 2022
process-to-process delivery.
CN(Unit 4): Dr. B.Rajalingam 16
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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 17


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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 18


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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 19


Socket address
❖ It is a 48 bit address .
It is a combination of both IP Address and port number.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 20


Services provided by the Transport Layer
• The data link layer provides the services within a single network while the
transport layer provides the services across an internetwork made up of many
networks.
• The data link layer controls the physical layer while the transport layer
controls all the lower layers.
The services provided by the transport layer protocols can be divided into
five categories:
• End-to-end delivery
• Addressing
• Reliable delivery
• Flow control
• Multiplexing
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 21
End-to-end delivery:
• The transport layer transmits the entire message to the destination.
• Therefore, it ensures the end-to-end delivery of an entire message
from a source to the destination.
Reliable delivery:
• The transport layer provides reliability services by retransmitting the
lost and damaged packets.
The reliable delivery has four aspects:
• Error control
• Sequence control
• Loss control
• Duplication control
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 22
Error Control

• The primary role of reliability is Error Control.


• In reality, no transmission will be 100 percent error-free delivery.
• Therefore, transport layer protocols are designed to provide error-
free transmission.
• The data link layer also provides the error handling mechanism, but
it ensures only node-to-node error-free delivery.
• However, node-to-node reliability does not ensure the end-to-end
reliability.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 23


• The data link layer checks for the error
between each network. If an error is
introduced inside one of the routers, then
this error will not be caught by the data link
layer.

• It only detects those errors that have been


introduced between the beginning and end of
the link.

• Therefore, the transport layer performs the


checking for the errors end-to-end to ensure
that the packet has arrived correctly.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 24


Sequence Control

• The second aspect of the reliability is sequence control which is


implemented at the transport layer.

• On the sending end, the transport layer is responsible for ensuring


that the packets received from the upper layers can be used by the
lower layers.

• On the receiving end, it ensures that the various segments of a


transmission can be correctly reassembled.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 25


Loss Control

• Loss Control is a third aspect of reliability.

• The transport layer ensures that all the fragments of a transmission


arrive at the destination, not some of them.

• On the sending end, all the fragments of transmission are given


sequence numbers by a transport layer.

• These sequence numbers allow the receiver’s transport layer to


identify the missing segment.
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 26
Duplication Control

• Duplication Control is the fourth aspect of reliability.

• The transport layer guarantees that no duplicate data arrive at the


destination.

• Sequence numbers are used to identify the lost packets; similarly, it


allows the receiver to identify and discard duplicate segments.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 27


Flow Control
• Flow control is used to prevent the sender from
overwhelming(crushing) the receiver.
• If the receiver is overloaded with too much data, then the receiver
discards the packets and asking for the retransmission of packets.
• This increases network congestion and thus, reducing the system
performance.
• The transport layer is responsible for flow control.
• It uses the sliding window protocol that makes the data transmission
more efficient as well as it controls the flow of data so that the
receiver does not become overwhelmed.
• Sliding window protocol is byte oriented rather than frame oriented.
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 28
Multiplexing
• The transport layer uses the multiplexing to
improve transmission efficiency.
• Multiplexing can occur in two ways:
• Upward multiplexing: Upward multiplexing
means multiple transport layer connections
use the same network connection.
• To make more cost-effective, the transport
layer sends several transmissions bound for
the same destination along the same path;
this is achieved through upward
10 November 2022
multiplexing.
CN(Unit 4): Dr. B.Rajalingam 29
Downward multiplexing:
• Downward multiplexing means one
transport layer connection uses the
multiple network connections.

• Downward multiplexing allows the


transport layer to split a connection
among several paths to improve the
throughput.

• This type of multiplexing is used when


networks have a low or slow capacity.
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 30
Addressing
• According to the layered model, the transport layer interacts with the functions
of the session layer.

• Many protocols combine session, presentation, and application layer protocols


into a single layer known as the application layer.

• In these cases, delivery to the session layer means the delivery to the
application layer.

• Data generated by an application on one machine must be transmitted to the


correct application on another machine.

• In this case, addressing is provided by the transport layer.


10 November 2022 CN(Unit 4): Dr. B.Rajalingam 31
• The transport layer provides the user address which is specified as a station or port.

• The port variable represents a particular TS user of a specified station known as a Transport
Service access point (TSAP).

• Each station has only one transport entity.

• The transport layer protocols need to know which upper-layer protocols are
communicating.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 32


Elements of Transport protocols
• Transport protocol similar to data link protocols

• Both do error control and flow control

• However, significant differences exist

a) Environment of Data Link Layer b) Environment of Transport Layer


10 November 2022 CN(Unit 4): Dr. B.Rajalingam 33
Elements of Transport Protocols
Data link layer Transport layer
Communication Directly via physical channel Over the entire network

No need to specify address. Explicit addressing of destination is


Addressing
Just select outgoing line required
Connection
Over a wire is simple More complicated
establishment
Frame either arrives or lost, Packets might be stored for seconds
Delay
Not stored and delayed and delivered later
Buffering and More complicated; large and dynamic
flow control Simpler number of simultaneous connections

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 34


Connection Management
• A TCP connection begins with a client doing an active open to a server.
• Assuming that the server had earlier done a passive open, the two sides
engage in an exchange of messages to establish the connection.
• Only after this connection establishment phase is over do the two sides begin
sending data.
• Likewise, as soon as a participant is done sending data, it closes one direction
of the connection, which causes TCP to initiate a round of connection
termination messages.
• Connection setup is an asymmetric activity (one side does a passive open and
the other side does an active open) connection teardown is symmetric (each
side has to close the connection independently).
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 35
Three-Way Handshake
• A three-way handshake is a method used in a TCP/IP network to create a connection between a local
host/client and server.
• It is a three-step method designed to allow both communicating ends to initiate and negotiate the
parameters of the network TCP socket connection at the same time before data such as HTTP and SSH is
transmitted.
• Multiple TCP socket connections can be transmitted in both directions simultaneously. A three-way
handshake is also known as a TCP handshake or SYN-SYN-ACK, and requires both the client and
server to exchange SYN (synchronization) and ACK (acknowledgment) packets before actual data
communication begins.
• In fact, its name originates from the three messages transmitted by TCP before a session between the two
ends is initiated.
• A three-way handshake is primarily used to create a TCP socket connection to reliably transmit data
between devices.
• For example, it supports communication between a web browser on the client side and a server every
time a user navigates the Internet.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 36


TCP Connection Management

TCP connection oriented transmission requires three phases:


• Connection Establishment
• Data Transfer
• Connection termination

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 37


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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 38


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 39


TCP Connection Management

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 40


Three Steps of a Three-Way Handshake

As soon as a client requests a communication session with the server, a three-way handshake
process initiates TCP traffic by following three steps.

Step 1: A connection between server and client is established.

Step 2: The server receives the SYN packet from the client node

Step 3: Client node receives the SYN/ACK from the server and responds with an ACK packet.
The client node receives the SYN/ACK from the server and responds with an ACK packet. Once
again, each side must acknowledge the sequence number received by incrementing it by one.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 41


Step 1: A connection between server and client is established

• First, a connection between server and client is established, so the target server must have open
ports that can accept and initiate new connections.

• The client node sends a SYN (Synchronize Sequence Number) data packet over an IP network
to a server on the same or an external network.

• This SYN packet is a random sequence number that the client wants to use for the
communication (for example, X).

• The objective of this packet is to ask/infer if the server is open for new connections.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 42


Step 2: The server receives the SYN packet from the client node

• When the server receives the SYN packet from the client node, it responds and returns a
confirmation receipt – the ACK (Acknowledgement Sequence Number) packet or SYN/ACK
packet.
• This packet includes two sequence numbers.
• The first one is ACK one, which is set by the server to one more than the sequence number it
received from the client (e.g. X+1).
• The second one is the SYN sent by the server, which is another random sequence number (for
example, Y).
• This sequence indicates that the server correctly acknowledged the client’s packet, and that is
sending its own to be acknowledged as well.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 43


Step 3: Client node receives the SYN/ACK from the server and
responds with an ACK packet.

• Step 3: Client node receives the SYN/ACK from the server and responds with an ACK packet.
The client node receives the SYN/ACK from the server and responds with an ACK packet.
Once again, each side must acknowledge the sequence number received by incrementing it by
one.
• So now it’s the turn of the client to acknowledge the server’s packet by adding one to the
sequence number (in this case, Y+1), and resend it to the server.
• Upon completion of this process, the connection is created and the host and server can
communicate.
• All these steps are necessary to verify the serial numbers originated by both sides, guaranteeing
the stability of the connection.
• Since both hosts must acknowledge the connection parameters of the other side, a missing or
out-of-order segment can be quickly detected before the actual data transfer process is initiated.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 44


Connection establishment using three-way handshake

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 45


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 46


Data Transfer

Connection Termination

10 November 2022
TCP/IP Protocol Suite CN(Unit 4): Dr.
50 B.Rajalingam 47
Connection termination using three-way handshake

10 November 2022 CN(Unit 4): Dr.


51 B.Rajalingam 48
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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 49


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 50


Difference between TCP- sliding window and data link
layer sliding window

TCP-SLIDING 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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 51


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 52


• 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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 53


Example of sliding window

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 54


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,

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 55


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 56


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.
• Proactive network performance management solutions that detect and diagnose performance
issues are the best way to guarantee ongoing user satisfaction.
• The performance of a network can never be fully modeled, so measuring network performance
before, during, and after updates are made and monitoring performance on an ongoing basis
are the only valid methods to fully ensure network quality.
• While measuring and monitoring network performance parameters are essential, the
interpretation and actions stemming from these metrics are equally important.
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 57
THE RELIABLE , CONNECTION-BASED CHOICE
TRANSMISSION CONTROL PROTOCOL(TCP)

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 58


• 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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 59


TCP Services

1.Process to Process Communication:

Like UDP,TCP also provides process-to- process Communication using port numbers.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 60


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
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 61
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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 62


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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 63


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.
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 64
Sending and Receiving Buffers

Sending and receiving processes may not write or read data at the same speed,
TCP needs buffers for storage

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 65


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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 66


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 67


TCP Segment

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


10 November 2022 CN(Unit 4): Dr. B.Rajalingam 68
TCP Header format

Field Purpose
Source Port Destination Port Identifies originating application Identifies destination application
Sequence Number byte Sequence number of first octet in the segment-TCP generates a random no between 0-2^32-1 for the no of first
Acknowledgment # Len Sequence number of the next expected octet (if ACK flag set)
Flags Window Length of TCP header in 4 octet units-Header length can be between 20 and 60 bytes.
Checksum TCP flags: SYN, FIN, RST, PSH, ACK, URG
Urgent Pointer Options Number of octets from ACK that sender will accept Checksum of IP pseudo-header + TCP header + data Pointer to
end of “urgent data”
Special TCP options such as MSS and Window Scale

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 69


Control field

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 70


• 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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 71


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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 72


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

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 73


User datagram format
• UDP packets , called User datagrams , have a
fixed-size header of 8 byte.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 74


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)
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 75
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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 76


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.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 77


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)

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 78


UDP Checksum
UDP checksum includes three sections:
• A pseudo header
• UDP header
• Data coming from application layer.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 79


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.
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 80
Checksum calculation of a simple UDP user
datagram

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 81


Queues in UDP

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 82


Uses 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)

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 83


Differences between TCP and UDP
S. Key TCP (Transmission Control UDP (User Datagram Protocol)
No. Protocol)

It is a communications protocol,
It is same as the TCP protocol except this
using which the data is transmitted
doesn’t guarantee the error-checking and
between systems over the network.
data recovery.
In this, the data is transmitted into the
1 Definition If you use this protocol, the data will be
form of packets.
sent continuously, irrespective of the
It includes error-checking, guarantees
issues in the receiving end.
the delivery and preserves the order
of the data packets.

TCP is a connection oriented


2 Design UDP is a connection less protocol.
protocol.

10 November 2022 CN(Unit 4): Dr. B.Rajalingam 84


As TCP provides error checking While on other hand UDP does provided
support and also guarantees only basic error checking support using
3 Reliable delivery of data to the destination checksum so the delivery of data to the
router this make it more reliable as destination cannot be guaranteed in UDP
compared to UDP. as compared to that in case of TCP.
In TCP the data is transmitted in a On other hand there is no sequencing of
Data particular sequence which means data in UDP in order to implement
4
transmission that packets arrive in-order at the ordering it has to be managed by the
receiver. application layer.
TCP is slower and less efficient in
performance as compared to UDP. On other hand UDP is faster and more
5 Performance
Also TCP is heavy-weight as efficient than TCP.
compared to UDP.
Retransmission of data packets is
On other hand retransmission of packets is
6 Retransmission possible in TCP in case packet get
not possible in UDP.
lost or need to resend.
10 November 2022 CN(Unit 4): Dr. B.Rajalingam 85
Thank You

Computer Networks:- Unit 3 (Dr. B.Rajalingam)

You might also like