0% found this document useful (0 votes)
3 views

Module 4 Updated

Uploaded by

ppspratik3
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Module 4 Updated

Uploaded by

ppspratik3
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 45

CSE3155 DATA COMMUNICATION AND

COMPUTER NETWORKS

Module-4
Transport Layer and
Applicaton Layer
Protocols
1
Transport Layers
 The transport layer is located between the network layer and the

application layer
 The transport layer is responsible for providing services to the application

layer; it receives services from the network layer


 The first duty of a transport-layer protocol is to provide process-to-

process communication. A process is an application-layer entity (running

program) that uses the services of the transport layer.


 we need to understand the difference between host-to-host

communication and process-to-process communication.


 The network layer is responsible for communication at the computer level

(hostto-host communication).
• A network-layer protocol can deliver the message only to the destination computer. However,
this is an incomplete delivery. The message still needs to be handed to the correct process.
• This is where a transport-layer protocol takes over. A transport-layer protocol is responsible
for delivery of the message to the appropriate process.

• The below figure shows Network layer versus transport layer


Addressing: Port Numbers

• A process on the local host, called a client, needs services from a process
usually on the remote host, called a server.

• A remote computer can run several server programs at the same time, just as
several local computers can run one or more client programs at the same
time. For communication, we must define the local host, local process,
remote host, and remote process.

• The local host and the remote host are defined using IP addresses .

• To define the processes, we need second identifiers, called port numbers. In


the TCP/IP protocol suite, the port numbers are integers between 0 and
65,535 (16 bits).
• It should be clear that the IP addresses and port numbers play different
roles in selecting the final destination of data.
• The destination IP address defines the host among the different hosts in
the world. After the host has been selected, the port number defines one
of the processes on this particular host.
TRANSPORT-LAYER PROTOCOLS
USER DATAGRAM PROTOCOL (UDP)

• The User Datagram Protocol (UDP) is a connectionless, unreliable


transport protocol.

• UDP provides a connectionless service. This means that each user


datagram sent by UDP is an independent datagram. There is no
relationship between the different user datagrams even if they are
coming from the same source process and going to the same destination
program.

• The user datagrams are not numbered. Also, unlike TCP, there is no
connection establishment and no connection termination. This means
that each user datagram can travel on a different path.

• UDP is a very simple protocol using a minimum of overhead. If a process


wants to send a small message and does not care much about reliability,
it can use UDP.


User datagram packet format
Contd…
• Sending a small message using UDP takes much less interaction
between the sender and receiver than using TCP.

• UDP packets, called user datagrams, have a fixed-size header of 8 bytes


made up of four fields, each of 2 bytes (16 bits).

• The format of a user datagram. The first two fields define the source
and destination port numbers, respectively.

• Third field defines the total length of the user datagram, header plus
data.
• The 16 bits can define a total length of 0 to 65,535 bytes.
• However, the total length needs to be less because a UDP user datagram
is stored in an IP datagram with the total length of 65,535 bytes.
• The last field can carry the optional checksum.
Checksum Calculation:
Steps followed in checksum calculation
Example1: Let's understand this by an example
The first thing that we do is to divide and slice it up to 16 bit pieces. Let's
assume we have three 16 bit data as below.

1001101001010110
0000101110001110
0000110111001100

If we add those three 16 bit data using binary addition. We get the below 16
bit data(Its simple binary addition).

1001101001010110 + 0000101110001110 + 0000110111001100


= 1011001110110000
Ones complement of our result 1011001110110000
is 0100110001001111(This is our checksum). So we need to basically send
our data (which is the three binary 16 bit numbers) along with its checksum
to a receiver. The main thing to understand is, the receiver will get the data as
well as the checksum we calculated.
Contd..
The receiver will get the below things.

1 0 0 1 1 0 1 0 0 1 0 1 0 1 1 0 (data)
0 0 0 0 1 0 1 1 1 0 0 0 1 1 1 0 (data)
0 0 0 0 1 1 0 1 1 1 0 0 1 1 0 0 (data)
0 1 0 0 1 1 0 0 0 1 0 0 1 1 1 1 (Checksum)

The reciever will simply add all the above 4 things. Data as well as checksum
are added together. Let's try adding it.

1001101001010110 + 0000101110001110 + 0000110111001100


+ 0100110001001111 = 1111111111111111

If the output of sum of 16 bit data and checksum is 1111111111111111. All


fields will be 1s. Even if there is one 0, then that means errors were
introduced in the data during transit.
Transmission Control Protocol (TCP)
• Transmission Control Protocol (TCP) is a connection-oriented, reliable
protocol.

• TCP explicitly defines connection establishment, data transfer, and


connection teardown phases to provide a connection-oriented service.

• TCP uses a combination of the Go-Back-N (GBN) and Selective-Repeat (SR)


protocols to provide reliability.

• To achieve this goal, TCP uses checksum (for error detection),


retransmission of lost or corrupted packets, cumulative and selective
acknowledgments, and timers.

• At the transport layer, TCP groups a number of bytes together into a packet
called a segment. TCP adds a header to each segment (for control
purposes) and delivers the segment to the network layer for transmission.
Connection-Oriented Service

• TCP offers full-duplex service, where data can flow in both directions at
the same time. Each TCP endpoint then has its own sending and receiving
buffer, and segments move in both directions.

• TCP performs multiplexing at the sender and demultiplexing at the


receiver. However, because TCP is a connection-oriented protocol, a
connection needs to be established for each pair of processes.

• TCP, unlike UDP, is a connection-oriented protocol. When a process at site


A wants to send to and receive data from another process at site B, the
following three phases occur:
• 1. The two TCP’s establish a logical connection between them.
• 2. Data are exchanged in both directions.
• 3. The connection is terminated.
• Note that this is a logical connection, not a physical connection.
• TCP is a reliable transport protocol. It uses an acknowledgment
mechanism to check the safe and sound arrival of data.
TCP segment format
• The segment consists of a header of 20 to 60 bytes, followed by data from
the application program. The header is 20 bytes if there are no options and
up to 60 bytes if it contains options.

• Source port address:This is a 16-bit field that defines the port number of
the application program in the host that is sending the segment.

• Destination port address: This is a 16-bit field that defines the port
number of the application program in the host that is receiving the
segment.

• Sequence number: This 32-bit field defines the number assigned to the
first byte of data contained in this segment.

• Header length: This 4-bit field indicates the number of 4-byte words in
the TCP header. The length of the header can be between 20 and 60 bytes.
• Control field: This field defines six different control bits or flags.One or
more of these bits can be set at a time.

• These bits enable flow control, connection establishment and


termination, connection abortion, and the mode of data transfer in TCP.
Contd…
Window size: This field defines the window size of the sending TCP in bytes.
The length of this field is 16 bits, which means that the maximum size of the
window is 65,535 bytes.
This value is normally referred to as the receiving window (rwnd) and is
determined by the receiver.

Checksum:This 16-bit field contains the checksum.

Urgent pointer:This 16-bit field, which is valid only if the urgent flag is set, is
used when the segment contains urgent data. It defines a value that must be
added to the sequence number to obtain the number of the last urgent byte in
the data section of the segment.

Options: There can be up to 40 bytes of optional information in the TCP


header
A TCP Connection
In TCP, connection-oriented transmission requires three phases: connection
establishment, data transfer, and connection termination.

Three-Way Handshaking :The connection establishment in TCP is called


three-way handshaking.
Sliding Window Protocol

• The Sliding Window Protocol is a method used in computer networks to


manage the flow of data between two devices, ensuring that data is sent
and received in the correct order.

• There are two types of sliding window protocol Go-Back-N (GBN), and
Selective Repeat (SR).
Go-Back-N (GBN)

• In a Go-Back-N (GBN) protocol, the sender is allowed to transmit multiple


packets (when available) without waiting for an acknowledgment, but is
constrained to have no more than some maximum allowable number, N,
of unacknowledged packets in the pipeline.

• For this reason, N is often referred to as the window size and the GBN
protocol itself as a sliding-window protocol.
Contd…
Contd…
• Figure shows the operation of the GBN protocol for the case of a window
size of four packets. Because of this window size limitation, the sender
sends packets 0 through 3 but then must wait for one or more of these
packets to be acknowledged before proceeding.

• As each successive ACK (for example, ACK0 and ACK1) is received, the
window slides forward and the sender can transmit one new packet
(pkt4 and pkt5, respectively).

• On the receiver side, packet 2 is lost and thus packets 3, 4, and 5 are
found to be out of order and are discarded.
Working of Go-Back-N ARQ or(Go-
Back –N)
• Suppose there are a sender and a receiver, and let's assume that there are 11
frames to be sent.

• These frames are represented as 0,1,2,3,4,5,6,7,8,9,10, and these are the


sequence numbers of the frames.

• Mainly, the sequence number is decided by the sender's window size. But, for
the better understanding, we took the running sequence numbers, i.e.,
0,1,2,3,4,5,6,7,8,9,10.

• Let's consider the window size as 4, which means that the four frames can
be sent at a time before expecting the acknowledgment of the first frame.

• Step 1: Firstly, the sender will send the first four frames to the receiver, i.e.,
0,1,2,3, and now the sender is expected to receive the acknowledgment of the
0th frame
Contd..

Let's assume that the receiver has sent the acknowledgment for the 0
frame, and the receiver has successfully received it.
Contd..

The sender will then send the next frame, i.e., 4, and the window
slides containing four frames (1,2,3,4).
Contd..

The receiver will then send the acknowledgment for the frame no 1.
After receiving the acknowledgment, the sender will send the next
frame, i.e., frame no 5, and the window will slide having four frames
(2,3,4,5)
Contd..

Now, let's assume that the receiver is not acknowledging the frame no
2, either the frame is lost, or the acknowledgment is lost. Instead of
sending the frame no 6, the sender Go-Back to 2, which is the first
frame of the current window, retransmits all the frames in the current
window, i.e., 2,3,4,5.
• Example 2: In GB4, if every 6th packet being transmitted is lost and if we
have to spend 10 packets then how many transmissions are required where
N=4.

• Do it yourself
Selective Repeat (SR)
• There are, however, scenarios in which GBN itself suffers from
performance problems.

• In particular, when the window size and bandwidth-delay product are both
large, many packets can be in the pipeline.

• A single packet error can thus cause GBN to retransmit a large number of
packets, many unnecessarily.

• As the probability of channel errors increases, the pipeline can become


filled with these unnecessary retransmissions

• As the name suggests, selective-repeat protocols avoid unnecessary


retransmissions by having the sender retransmit only those packets that it
suspects were received in error (that is, were lost or corrupted) at the
receiver.
Application
Layer:Protocols

1
Domain Name System (DNS)
 To identify an entity, TCP/IP protocols use the IP address, which uniquely
identifies the connection of a host to the Internet. However, people prefer
to use names instead of numeric addresses.

 Therefore, the Internet needs to have a directory system that can map a
name to an address. This is analogous to the telephone network. A
telephone network is designed to use telephone numbers, not names.

 Because the Internet is so huge today, a central directory system cannot


hold all the mapping. In addition, if the central computer fails, the whole
communication network will collapse.

 A better solution is to distribute the information among many computers


in the world. In this method, the host that needs mapping can contact the
closest computer holding the needed information. This method is used by
the Domain Name System (DNS).
How TCP/IP uses a DNS client and a DNS server to
map a name to an address.
 A user wants to use a file transfer client to access the corresponding file transfer
server running on a remote host.
 The user knows only the file transfer server name, such as afilesource.com.
However, the TCP/IP suite needs the IP address of the file transfer server to make
the connection.
Organization of
Domain
Web and HTTP

• web page consists of objects, each of which can be stored on different Web
servers.
• object can be HTML file, JPEG image, Java applet, audio file,…
• web page consists of base HTML-file which includes several referenced objects,
each addressable by a URL,
• e.g.,
HTTP overview

• HTTP: hypertext transfer protocol


• Web’s application layer protocol
• client/server model:
• client: browser that requests, receives, (using HTTP
protocol) and “displays” Web objects
• server: Web server sends (using HTTP protocol)
objects in response to requests
HTTP connections: two types
Non-persistent HTTP

• TCP connection opened


• at most one object sent over TCP connection
• TCP connection closed

• downloading multiple objects required multiple connections


Persistent HTTP

• TCP connection opened to a server


• multiple objects can be sent over single TCP connection between client,
and that server
• TCP connection closed
HTTP Methods
HTTP response status
codes
status code appears in 1st line in server-to-client response message.
some sample codes:
200 OK
request succeeded, requested object later in this message
301 Moved Permanently
requested object moved, new location specified later in this message (in
Location: field)
400 Bad Request
request msg not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
File Transfer Protocol
(FTP)

• FTP or File Transfer Protocol is said to be one of the earliest and also
the most common forms of transferring files on the internet. Located
in the application layer of the OSI model.

• FTP is a basic system that helps in transferring files between a client


and a server.

• It is what makes the FTP unique that the system provides a reliable
and efficient means of transferring files from one system to another
even if they have different file structures and operating systems.
Simple Mail Transfer mechanism (SMTP)
• SMTP is an application layer protocol.

• Simple Mail Transfer mechanism (SMTP) is a mechanism for exchanging


email messages between servers.

• It is an essential component of the email communication process and


operates at the application layer of the TCP/IP protocol stack.

• SMTP is a protocol for transmitting and receiving email messages

• The client who wants to send the mail opens a TCP connection to the
SMTP server and then sends the mail across the connection.
• The SMTP server is an always-on listening mode.

• As soon as it listens for a TCP connection from any client, the SMTP
process initiates a connection through port 25.

• After successfully establishing a TCP connection the client process sends


the mail instantly.
END OF MODULE 4

You might also like