0% found this document useful (0 votes)
42 views59 pages

Chess Class

The document discusses the transport layer in computer networking. It provides information on transport layer addressing using port numbers, functions of the transport layer such as multiplexing and segmenting data, and transport layer protocols including TCP and UDP. TCP provides connection-oriented and reliable data transmission, while UDP is connectionless and unreliable but more efficient for real-time applications. The document also describes TCP and UDP packet formats and how each protocol works.

Uploaded by

ameershaikh5009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views59 pages

Chess Class

The document discusses the transport layer in computer networking. It provides information on transport layer addressing using port numbers, functions of the transport layer such as multiplexing and segmenting data, and transport layer protocols including TCP and UDP. TCP provides connection-oriented and reliable data transmission, while UDP is connectionless and unreliable but more efficient for real-time applications. The document also describes TCP and UDP packet formats and how each protocol works.

Uploaded by

ameershaikh5009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Transport Layer

Transport Layer Addressing


Addresses
•Data link layer → MAC address
•Network layer → IP address
•Transport layer → Port number (choose among multiple processes running on
destination host)

TCP 2
OSI Model Layer 4: Transport Layer
• It decides if data transmission should be on parallel path or single path.

• Functions such as Multiplexing, Segmenting or Splitting on the data are done


by this layer

• It receives messages from the Session layer above it, convert the message into
smaller units and passes it on to the Network layer.

• Transport layer can be very complex, depending upon the network


requirements.

• Transport layer breaks the message (data) into small units so that they are
handled more efficiently by the network layer.
Functions of Transport Layer
• Service Point Addressing: Transport Layer header includes service point address which is
port address. This layer gets the message to the correct process on the computer unlike
Network Layer, which gets each packet to the correct computer.
• Segmentation and Reassembling: A message is divided into segments; each segment
contains sequence number, which enables this layer in reassembling the message.
Message is reassembled correctly upon arrival at the destination and replaces packets
which were lost in transmission.
• Connection Control: It includes 2 types:
• Connectionless Transport Layer : Each segment is considered as an independent packet
and delivered to the transport layer at the destination machine.
• Connection Oriented Transport Layer : Before delivering packets, connection is made
with transport layer at the destination machine.
• Flow Control: In this layer, flow control is performed end to end.
• Error Control: Error Control is performed end to end in this layer to ensure that the
User Datagram Protocol (UDP)

• UDP is a communications protocol that facilitates the exchange of


messages between computing devices in a network.
• In a network that uses the Internet Protocol (IP), it is sometimes referred
to as UDP/IP.
• User Datagram Protocol is an alternative to the transmission control
protocol (TCP)
• UDP enables process-to-process communication, while TCP supports host-
to-host communication.
• It is an unreliable and connectionless protocol. So, there is no need to
establish a connection prior to data transfer.
• Though Transmission Control Protocol (TCP) is the dominant transport layer
protocol used with most of the Internet services; provides assured delivery,
reliability, and much more but all these services cost us additional overhead
and latency.
• For real-time services like computer gaming, voice or video communication,
live conferences; we need UDP.
• UDP permits packets to be dropped instead of processing delayed packets.
• There is no error checking in UDP, so it also saves bandwidth.
• User Datagram Protocol (UDP) is more efficient in terms of both latency and
bandwidth.
Features of UDP Protocol

• UDP is used when acknowledgement of data does not hold any


significance.
• UDP is good protocol for data flowing in one direction.
• UDP is simple and suitable for query based communications.
• UDP is not connection oriented.
• UDP does not provide congestion control mechanism.
• UDP does not guarantee ordered delivery of data.
• UDP is simple and fast. Its used for time sensitive applications where
speed is more important than accuracy.
• UDP is suitable protocol for streaming applications such as VoIP,
multimedia streaming.
UDP Packet Format
1.Source Port: Source Port is a 2 Byte (16 bit)long field used to
identify the port number of the source.
Since it is 16 bit field port number can range from 0 to 65,535.
2.Destination Port: It is a 2 Byte long field, used to identify the port of
the destined packet.
3. Length: Length is the length of UDP including the header and the
data. It is a 16-bits field.
4.Checksum: Checksum is 2 Bytes long field. It is the 16-bit one’s
complement of the one’s complement sum of the UDP header, the
pseudo-header of information from the IP header, and the data, padded
with zero octets at the end (if necessary) to make a multiple of two
octets.
Checksum calculation is not mandatory in the UDP.
Working of UDP protocol

• UDP divides messages into packets called datagrams.


• UDP uses IP to get a datagram from one computer to another.
• UDP works by gathering data in a UDP packet and adding its own
header information to the packet.
• This data consists of the source and destination ports on which to
communicate, the packet length and a checksum.
• After UDP packets are encapsulated in an IP packet, they're sent off to
their destinations.
• In UDP there is no acknowledgement for the packet received.
• So sender need not wait for acknowledgment of the sent packet.
Advantages of UDP

• UDP does not need to require a connection to be established and maintained


• UDP uses a small packet size with a small header. This fewer bytes in the
overhead makes UDP protocol need for less time in processing the packet as
well as needless memory
• UDP uses checksum with all packets for error detection
• UDP can be used in events where a single packet of data needs to be
exchanged between the hosts
• Broadcast and multicast transmission are available with UDP
• UDP makes it faster as it need not have to wait on ACK or need have to data
in memory until they are ACKed
• UDP communication can be more efficient than a guaranteed delivery data
stream
Disadvantages of UDP
• UDP is an unreliable and connectionless protocol.
• UDP has no windowing and no function to ensure data is received in the
same order as it was transmitted
• UDP does not use any error control. So UDP detects an error in the received
packet. It silently drops it
• The router can be careless with UDP. They do not retransmit a UDP
datagram after the collision and will often discard UDP packets before TCP
packets
• There is no flow control and no acknowledgement for received data
• Only the application layer deals with error recovery. Hence applications can
simply turn to the user to send the message again
• UDP has no flow control, congestion control. Implementation is the duty of
the user program
• They are no guaranteed with UDP. So a packet may not be delivered or
delivered twice or delivered must be out of order.
Applications of UDP
• UDP is used in time-sensitive applications & also by servers that respond to
small queries from a bigger client base.
• This is well-suited with packet broadcasts especially for transmitting all over
the network.
• It is also utilized within Voice over IP, online games & Domain Name
Systems.
• This protocol is used in network applications like voice, gaming & video
communications.
• These are used where lossless data transmission is required.
• This protocol is utilized for multicasting as it simply supports packet
switching.
• UDP is used in applications that depend on reliable data exchange but should
include their own techniques to respond to packets.
• UDP is used wherever speed is critical rather than reliability.
Transmission Control Protocol (TCP)
• TCP is a transport layer protocol that facilitates the transmission of packets from
source to destination.
• It is a connection-oriented protocol that means it establishes the connection prior
to the communication that occurs between the computing devices in a network.
• This protocol is used with an IP protocol, so together, they are referred to as
a TCP/IP.
• The main functionality of the TCP is to take the data from the application layer.
• Then it divides the data into a several packets, provides numbering to these
packets, and finally transmits these packets to the destination.
• The TCP, on the other side, will reassemble the packets and transmits them to the
application layer.
• As we know that TCP is a connection-oriented protocol, so the connection will
remain established until the communication is not completed between the sender
and the receiver.
TCP Segment.

• When sending packets using TCP/IP, the data portion of each IP packet is formatted
as a TCP segment.
• Each TCP segment contains a header and data.
• The TCP header contains many more fields than the UDP header and can range in
size from 202020 to 606060 bytes, depending on the size of the options field.
• A TCP segment consists of data bytes to be sent and a header that is added to the
data by TCP.
• The header of a TCP segment can range from 20 – 60 bytes.
• 40 bytes are options.
• If there are no options, a header is 20 bytes else it can be the utmost of 60 bytes.
Source port:
• It defines the port of the application, which is sending the data.
• So, this field contains the source port address, which is 16 bits.

Destination port:
• It defines the port of the application on the receiving side.
• So, this field contains the destination port address, which is 16 bits.

Sequence number:
• Sequence numbers are given to the segments to reassemble the bytes at the
receiver end, even if they arrive in a different order.
• Sequence number of a segment is the byte number of the first byte that is
being sent.
• It is 32 bit field.
• This field contains the sequence number of data bytes in a particular
session.
Acknowledgment number:
When the ACK flag is set, then this contains the next sequence number of the
data byte and works as an acknowledgment for the previous data received.
For example, if the receiver receives the segment number 'x', then it responds
'x+1' as an acknowledgment number.

HLEN:
• It specifies the length of the header indicated by the 4-byte words in the
header.
• The size of the header lies between 20 and 60 bytes. (4byte X 5 = 20 bytes)
• Therefore, the value of this field would lie between 5 and 15.

Reserved:
• It is a 4-bit field reserved for future use, and by default, all are set to zero.
There are six control bits or flags:
Among all the 6 control bits, only one can be set at a time.
• URG: It represents an urgent pointer. If it is set, then the data is
processed urgently.
• ACK: If the ACK is set to 0, then it means that the data packet
does not contain an acknowledgment.
• PSH: If this field is set, then it requests the receiving device to
push the data to the receiving application without buffering it.
• RST: If it is set, then it requests to restart a connection.
• SYN: It is used to establish a connection between the hosts.
• FIN: It is used to release a connection, and no further data
exchange will happen.
Window size
• It is a 16-bit field.
• It contains the size of data that the receiver can accept.
• This field is used for the flow control between the sender and receiver and also determines the amount
of buffer allocated by the receiver for a segment.
• The value of this field is determined by the receiver.

Checksum
• It is a 16-bit field.
• This field is optional in UDP, but in the case of TCP/IP, this field is mandatory.

Urgent pointer
• It is a pointer that points to the urgent data byte if the URG flag is set to 1.
• It defines a value that will be added to the sequence number to get the sequence number of the last
urgent byte.

Options
• It provides additional options.
• The optional field is represented in 32-bits.
• If this field contains the data less than 32-bit, then padding is required to obtain the remaining bits.
TCP Connection
• TCP is a connection-oriented protocol, which means that it first establishes the
connection between the sender and receiver in the form of a handshake.
• After both the connections are verified, it begins transmitting packets. It makes
the transmission process error-free and ensures the delivery of data.
• The transmitter is the server, and the receiver is known as the client.
• We can also say that the data transmission occurs between the server and client.
• TCP is used in most of the high-level protocols, such as FTP (File Transfer
Protocol), HTTP (Hyper Text Transfer Protocol), and SMTP (Simple Mail
Transfer Protocol).
• Handshake refers to the process to establish connection between the client and server.
• Handshake is simply defined as the process to establish a communication link.
• To transmit a packet, TCP needs a three way handshake before it starts sending data.
• The reliable communication in TCP is termed as PAR (Positive Acknowledgement Re-
transmission).
• When a sender sends the data to the receiver, it requires a positive acknowledgement
from the receiver confirming the arrival of data.
• If the acknowledgement has not reached the sender, it needs to resend that data.
• The positive acknowledgement from the receiver establishes a successful connection.
• A 3-way handshake is commonly known as SYN-SYN-ACK and requires both the client
and server response to exchange the data.
• SYN means synchronize Sequence Number and ACK means acknowledgment.
• Each step is a type of handshake between the sender and the receiver.
Step 1: SYN
• SYN is a segment sent by the client to the server.
• It acts as a connection request between the client and server.
• It informs the server that the client wants to establish a connection.
• Synchronizing sequence numbers also helps synchronize sequence numbers
sent between any two devices, where the same SYN segment asks for the
sequence number with the connection request.

Step 2: SYN-ACK
• It is an SYN-ACK segment or an SYN + ACK segment sent by the server.
• The ACK segment informs the client that the server has received the
connection request and it is ready to build the connection.
• The SYN segment informs the sequence number with which the server is
ready to start with the segments.
Step 3: ACK
• ACK (Acknowledgment) is the last step before establishing a
successful TCP connection between the client and server.
• The ACK segment is sent by the client as the response of the received
ACK and SN from the server.
• It results in the establishment of a reliable data connection.

• After these three steps, the client and server are ready for the data
communication process.
• TCP connection and termination are full-duplex, which means that the
data can travel in both the directions simultaneously.
TCP Termination

• To terminate or stop the data transmission, it requires a 4-way handshake.


• The segments required for TCP termination are similar to the segments to
build a TCP connection (ACK and SYN) except the FIN segment.
• The FIN segment specifies a termination request sent by one device to the
other.
• The client is the data transmitter and the server is a receiver in a data
transmission process between the sender and receiver.
Step 1: FIN
• FIN refers to the termination request sent by the client to the server.
• The first FIN termination request is sent by the client to the server.
• It depicts the start of the termination process between the client and
server.

Step 2: FIN_ACK_WAIT
• The client waits for the ACK of the FIN termination request from the
server. It is a waiting state for the client.

Step 3: ACK
• The server sends the ACK (Acknowledgement) segment when it
receives the FIN termination request.
• It depicts that the server is ready to close and terminate the connection.
Step 4: FIN _WAIT_2
• The client waits for the FIN segment from the server.
• It is a type of approved signal sent by the server that shows that the server
is ready to terminate the connection.

Step 5: FIN
• The FIN segment is now sent by the server to the client.
• It is a confirmation signal that the server sends to the client.
• It depicts the successful approval for the termination.

Step 6: ACK
• The client now sends the ACK (Acknowledgement) segment to the server
that it has received the FIN signal, which is a signal from the server to
terminate the connection.
• As soon as the server receives the ACK segment, it terminates the
connection.
Working of TCP

• In TCP, the connection is established by using three-way handshaking.


• The client sends the segment with its sequence number.
• The server, in return, sends its segment with its own sequence number as
well as the acknowledgement sequence, which is one more than the client
sequence number.
• When the client receives the acknowledgment of its segment, then it sends
the acknowledgment to the server.
• In this way, the connection is established between the client and the server.
Step 1: Establish connection
• When two computers want to send data to each other over TCP, they
first need to establish a connection using a three-way handshake.
• The first computer sends a packet with the SYN bit set to 111 (SYN =
"synchronize?").
• The second computer sends back a packet with the ACK bit set
to 111 (ACK = "acknowledge!") plus the SYN bit set to 111.
• The first computer replies back with an ACK.
• The SYN and ACK bits are both part of the TCP header.
• In fact, the three packets involved in the three-way handshake do not
typically include any data.
• Once the computers are done with the handshake, they're ready to
receive packets containing actual data.
Step 2: Send packets of data
• When a packet of data is sent over TCP, the recipient must always
acknowledge what they received.
• The first computer sends a packet with data and a sequence number.
• The second computer acknowledges it by setting the ACK bit and
increasing the acknowledgement number by the length of the received
data.
• Those two numbers help the computers to keep track of which data
was successfully received, which data was lost, and which data was
accidentally sent twice.
Step 3: Close the connection
• Either computer can close the connection when they no longer want to send
or receive data.
• A computer initiates closing the connection by sending a packet with the
FIN bit set to 1 (FIN = finish).
• The other computer replies with an ACK and another FIN.
• After one more ACK from the initiating computer, the connection is closed.
Detecting lost packets

• TCP connections can detect lost packets using a timeout.


• After sending off a packet, the sender starts a timer and puts the packet
in a retransmission queue.
• If the timer runs out and the sender has not yet received an ACK from
the recipient, it sends the packet again.
• The retransmission may lead to the recipient receiving duplicate
packets, if a packet was not actually lost but just very slow to arrive or
be acknowledged.
• If so, the recipient can simply discard duplicate packets.
Most common TCP/IP protocols
• File Transfer Protocol (FTP)
• FTP is a client-server protocol, with which a client requests a file and
the server supplies it.
• FTP runs over TCP/IP -- a suite of communications protocols -- and
requires a command channel and a data channel to communicate and
exchange files, respectively.
• Clients request files through the command channel and receive access
to download, edit and copy the file, among other actions, through the
data channel.
• FTP has grown less popular as most systems began to use HTTP for
file sharing.
• However, FTP is a common network protocol for more private file
sharing, such as in banking.
• Hypertext Transfer Protocol (HTTP)
• Like FTP, HTTP is a file sharing protocol that runs over TCP/IP.
• Although HTTP primarily works over web browsers and is commonly
recognizable for most users. When a user enters a website domain and
aims to access it, HTTP provides the access.
• HTTP connects to the domain's server and requests the site's HTML,
which is the code that structures and displays the page's design.
• Another form of HTTP is HTTPS, which stands for HTTP over Secure
Sockets Layer or HTTP Secure.
• HTTPS can encrypt a user's HTTP requests and webpages.
• This provides more security to users and can prevent common
cybersecurity threats, such as man-in-the-middle attacks.
TCP Services
• TCP services achieved with endpoints called sockets.
• A socket has a socket number, which contains the IP address of the host
and a 16 bit port number.
• For TCP service to be obtained, a connection must be established
between a socket on one machine and a socket on another.
• Sockets can handle multiple connection at a time.
• Port numbers below 1024 are reserved for standard services. They are
called well known ports.
• Ports from 1024 to 49151 can be registered for use but applications can
choose their own ports without registering them.
• TCP connections are full duplex and point to point.
• TCP doesn’t support multicasting or broadcasting.
TCP Services
Process-to-Process Communication:
• TCP provides process-to-process communication.
• That means the transfer of data that takes place between individual processes
executing on end systems.
• This is done using port numbers or port addresses.
• Port numbers are 16 bit long that help identify which process is sending or
receiving data on a host.

Multiplexing:
• TCP does multiplexing and demultiplexing at the sender and receiver ends
respectively as several logical connections can be established between port
numbers over a physical connection.
Transport Layer 2/2

Process-to-process delivery

TCP 44
Multiplexing and Demultiplexing
Multiplexing
Sender side may have several
processes that need to send
packets (albeit only 1 transport-
layer protocol)
Demultiplexing
At receiver side, after error
checking and header dropping,
transport-layer delivers each
message to appropriate process

TCP 45
Stream Delivery Service
• TCP is a stream-oriented protocol.
• It enables the sending process to deliver data as a stream of bytes and
the receiving process to acquire data as a stream of bytes. (in UDP
divides data bits into datagrams or packets)
• TCP creates a working environment so that the sending and receiving
procedures are connected by an imaginary "tube", as shown in the
figure below:
Full-Duplex Service
• TCP offers a full-duplex service where the data can flow in both directions
simultaneously.
• Each TCP will then have a sending buffer and receiving buffer. The TCP
segments are sent in both directions.

Reliable Service
• TCP is a reliable transport protocol.
• TCP is a reliable protocol as it follows the flow and error control
mechanism.
• It also supports the acknowledgment mechanism, which checks the
state and sound arrival of the data.
• In the acknowledgment mechanism, the receiver sends either positive
or negative acknowledgment to the sender so that the sender can get to
know whether the data packet has been received or needs to resend.
Connection-Oriented Service
• TCP is a connection-oriented protocol.
• When a process wants to communicate (send and receive) with another
process (process -2), the sequence of operations is as follows:
• Connection Establishment: TCP of process-1 informs TCP of process-2 and
gets its approval.
• Data Transfer: TCP of process-1 tells TCP of process-2 exchange data in
both directions.
• Connection Termination: After completing the data exchange, when buffers
on both sides are empty, the two TCPs destroy their buffers
• The type of connection in TCP is not physical, but it is virtual.
• The TCP segment encapsulated in an IP datagram can be sent out of order.
• These segments can get lost or corrupted and may have to be resend.
• Each segment may take a different path to reach the destination.
TCP Features
Reliable
• TCP is a reliable protocol as it follows the flow and error control mechanism.
• It also supports the acknowledgment mechanism, which checks the state and
sound arrival of the data.
• In the acknowledgment mechanism, the receiver sends either positive or negative
acknowledgment to the sender so that the sender can get to know whether the data
packet has been received or needs to resend.

Order of the data is maintained


• This protocol ensures that the data reaches the intended receiver in the same order
in which it is sent.
• It orders and numbers each segment so that the TCP layer on the destination side
can reassemble them based on their ordering.
• Data segments are sent with sequence number which is helpful for rearranging
data segments at the destination.
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.

Full duplex
• It is a full-duplex means that the data can transfer in both directions at the
same time.

Stream-oriented
• TCP is a stream-oriented protocol as it allows the sender to send the data in
the form of a stream of bytes and also allows the receiver to accept the data
in the form of a stream of bytes.
• TCP creates an environment in which both the sender and receiver are
connected by an imaginary tube known as a virtual circuit.
• This virtual circuit carries the stream of bytes across the internet.
Advantages of TCP
• TCP provides reliable communication between the communicating
hosts in the network.
• TCP protocol controls the flow of segments.
• TCP protocol controls the error in transmitted segments.
• It provides an error-checking mechanism as well as one for recovery
• TCP includes a congestion control mechanism.
• It makes sure that the data reaches the proper destination in the exact
order that it was sent
• Open Protocol, not owned by any organization or individual
• It assigns an IP address to each computer on the network and a domain
name to each site thus making each device site to be distinguishable
over the network.
Disadvantages of TCP

• TCP is made for Wide Area Networks, thus its size can become an
issue for small networks with low resources.
• All the advantages of TCP produce a large amount of overhead
causing the communication quite slow.
• TCP runs several layers so it can slow down the speed of the network
• It is not generic in nature. Meaning, it cannot represent any protocol
stack other than the TCP/IP suite. E.g., it cannot work with a
Bluetooth connection.
• No modifications since their development around 30 years ago.

You might also like