Transport and Application Layer Protocols
Transport and Application Layer Protocols
Transport &
Application
Layer Protocols
CO5:- Analyze the services provided by Transport & Application layers
1
TOPICS
• Port Numbers
• User Datagram Protocol (UDP)
• Transmission Control Protocol (TCP)
• World Wide Web (WWW) & HTTP
• File Transfer Protocol (FTP)
• Telnet
• E-Mail & DNS
Resources:
Behrouz A. Forouzan, “Data Communication & Networking”, 5th edition, 2010.
William Stallings, Data and Computer Communications”, 9th edition, 2010.
2
Transport Layer Protocols
• The transport layer in the TCP/IP suite is located between the application layer and the
network layer. It provides services to the application layer and receives services from the
network layer.
• The transport layer acts as a liaison between a client program and a server program, a
process-to-process connection.
• The transport layer is the heart of the TCP/IP protocol suite; it is the end-to-end logical
vehicle for transferring data from one point to another on the Internet.
• Three Protocols: 1) UDP 2) TCP 3) SCTP
• UDP: UDP is an unreliable connectionless transport-layer protocol used for its simplicity
and efficiency in applications where error control can be provided by the application-layer
process.
• TCP: TCP is a reliable connection-oriented protocol that can be used in any application
where reliability is important.
• SCTP: SCTP is a new transport-layer protocol that combines the features of UDP and
TCP. 3
Port Numbers
• Transport-layer protocol usually has several responsibilities. One is to create a process-to-
process communication; these protocols use port numbers to accomplish this.
• Port numbers provide end-to-end addresses at the transport layer and allow multiplexing
and demultiplexing at this layer, just as IP addresses do at the network layer.
4
USER DATAGRAM PROTOCOL (UDP)
UDP – An Introduction
Connectionless service
Unreliable transport protocol.
No flow control / No Acknowledgement
Process to Process communication
Powerless
It uses minimum of over heads
No reliability is obtained using UDP
Less interaction between sender and receiver
5
UDP (Contd.)
6
UDP Fields
Source Port Number: Length: UDP length=IP length – IP headers Length
• 16 bits long – port ranges from 0- Length field specifies the entire length
65535. of UDP packet (including header).
• This port number will be used by It is 16-bits field and minimum value
the source host for identification. is 8-byte, i.e. the size of UDP header
Destination Port Number: • itself.
• 16 bits long. A user datagram is encapsulated in an
• Used by the process running on IP datagram.
the Destination machine. Checksum:
• Application level service on end • This field is used to detect errors over the
machine entire user datagram (header plus data)
7
Example
8
UDP Services
• Process-to-Process Communication
• UDP provides process-to-process communication using socket addresses, a combination of IP addresses
and port numbers.
• Connectionless Services
• As mentioned previously, 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.
• Flow Control
• UDP is a very simple protocol. There is no flow control, and hence no window mechanism.
• Error Control
• There is no error control mechanism in UDP except for the checksum. This means that the sender does
not know if a message has been lost or duplicated.
• Checksum
• UDP checksum calculation includes three sections: a pseudoheader, the UDP header, and the data coming
from the application layer. 9
Pseudoheader for checksum calculation
10
UDP Services (Contd.)
• Congestion Control
• Since UDP is a connectionless protocol, it does not provide congestion
control. UDP assumes that the packets sent are small and sporadic and
cannot create congestion in the network.
• This assumption may or may not be true today, when UDP is used for
interactive real-time transfer of audio and video.
• Encapsulation and Decapsulation
• To send a message from one process to another, the UDP protocol
encapsulates and decapsulates messages.
• Queuing
• We have talked about ports without discussing the actual
implementation of them. In UDP, queues are associated with ports.
• Multiplexing and Demultiplexing
• In a host running a TCP/IP protocol suite, there is only one UDP but
possibly several processes that may want to use the services of UDP. To
handle this situation, UDP multiplexes and demultiplexes.
11
Queuing in UDP
• At the client site, when a process starts, it requests a
port number from the operating system. Some
implementations create both an incoming and an
outgoing queue associated with each process. Other
implementations create only an incoming queue
associated with each process
The client process can send messages to the
outgoing queue by using the source port number
specified in the request
UDP removes the messages one by one and, after
adding the UDP header, delivers them to IP. An
outgoing queue can overflow
12
Applications of UDP
• Used for simple request response communication when size of data is less
hence there is lesser concern about flow and error control.
• It is suitable protocol for multicasting as UDP supports packet
switching. Following implementations uses UDP as a transport
layer protocol:
• NTP (Network Time Protocol) DNS
(Domain Name Service) BOOTP, DHCP.
• NNP (Network News Protocol) Quote of
the day protocol TFTP, RTSP, RIP, OSPF.
• UDP is null protocol if you remove checksum field.
13
UDP Package
Five Components
Control Block Table (CBT)
Input Queues
Control block Module
Input Module
Output Module
14
UDP Package
Control-Block Table
UDP has a control-block table to keep track of the open
ports.
Each entry in this table has a minimum of four fields: the
state, which can be FREE or IN-USE, the process ID, the port
number, and the corresponding queue number.
Input Queues
Our UDP package uses a set of input queues, one for each
process. In this design, we do not use output queues.
Input Module
The input module receives a user datagram from the IP. It
searches the control-block table to find an entry having the
same port number as this user datagram.
If the entry is found, the module uses the information in the
entry to enqueue the data. If the entry is not found, it
generates an ICMP message..
Output Module 15
The output module is responsible for creating and sending user
UDP at a Glance
• UDP is connectionless
16
TRANSMISSION CONTROL PROTOCOL (TCP)
20
TCP Segment & Header
• 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.
21
TCP Header Fields
1. Source Port- Acknowledgement Number-
• Source Port is a 16-bit field. • Acknowledgment number is a 32-bit field.
• It identifies the port of the sending application. • It contains sequence number of the data byte that
receiver expects to receive next from the sender.
• It is always sequence number of the last received
2. Destination Port- data byte incremented by 1.
• Destination Port is a 16-bit field.
• It identifies the port of the receiving application. Header Length-
• Header length is a 4-bit field.
3. Sequence Number- • It contains the length of TCP header.
• It helps in knowing from where the actual data
• Sequence number is a 32-bit field. begins.
• TCP assigns a unique sequence number to each
byte of data contained in the TCP segment.
Reserved Bits-
• This field contains the sequence number of the
first data byte. • The 6 bits are reserved.
• These bits are not used.
22
TCP Header Fields
Checksum-
SYN Bit- SYN bit is used to synchronize the • Checksum is a 16-bit field used for error control.
sequence numbers. • It verifies the integrity of data in the TCP payload.
• When SYN bit is set to 1, • Sender adds CRC checksum to the checksum field before sending
• It indicates the receiver that the sequence the data.
number contained in the TCP header is the initial • Receiver rejects the data that fails the CRC check.
sequence number. Urgent Pointer-
• Request segment sent for connection • Urgent pointer is a 16-bit field.
establishment during Three way handshake • It indicates how much data in the current segment counting from
contains SYN bit set to 1. the first data byte is urgent.
• Urgent pointer added to the sequence number indicates the end of
FIN Bit- FIN bit is used to terminate the TCP urgent data byte.
connection. • This field is considered valid and evaluated only if the URG bit is set
• When FIN bit is set to 1, to 1.
23
TCP Flow Control
Creates a balance between rate of data production and the rate of data consumption
24
TCP Flow Control
1) Messages are pushed from the Sending application to TCP Client
25
Time-line
diagram for a
common
scenario
26
Send window in TCP
2) The second difference is that, in some implementations, TCP can store data received from the
process and send them later, but we assume that the sending TCP is capable of sending segments
of data as soon as it receives them from its process.
3) Another difference is the number of timers. The theoretical Selective-Repeat protocol may use
several timers for each packet sent, but as mentioned before, the TCP protocol uses only one timer.
27
SCTP
• Stream Control Transmission Protocol (SCTP) is a connection-
oriented network protocol for transmitting multiple streams
of data simultaneously between two endpoints that have established a
connection in a computer network.
• It is similar to TCP, but it also provides message-oriented data transfer,
like User Datagram Protocol (UDP), making it useful for end-to-end
internet communications.
• SCTP is also intended to make it easier to establish connection over
wireless network and managing transmission of multimedia data. SCTP
is a standard protocol (RFC 2960) and is developed by Internet
Engineering Task Force (IETF).
28
SCTP
Advantages of SCTP
[Link] is a full- duplex connection i.e. users can send and receive data
simultaneously.
[Link] allows half- closed connections.
[Link] message’s boundaries are maintained and application doesn’t have to
split messages.
[Link] has properties of both TCP and UDP protocol.
[Link] doesn’t rely on IP layer for resilience of paths.
Disadvantages of SCTP
[Link] of key challenges is that it requires changes in transport stack on node.
[Link] need to be modified to use SCTP instead of TCP/UDP.
[Link] need to be modified to handle multiple simultaneous streams.
29
WWW Architecture
● WWW is a networked information system (repository of information) and it provides distributed client-
server service, in which a client using a browser can access a service using a server.
● Sites
● Web pages (simple / composite)
Request
Client Server
Response
30
Hypertext and Hypermedia
● Hypertext –creating a document that in turn refer to other document. In a
hypertext document, a part of text can be defined as a link to another document.
● Hypermedia is a term applied to document that contains links to other textual
document or documents containing graphics, video, or audio.
31
Web Client (Browser)
● It is an application software that allows us to view and explore information on
the web. User can request for any web page by just entering a URL into address
bar.
● Web browser can show text, audio, video, animation and more. It is the
responsibility of a web browser to interpret text and commands contained in the
web page.
● A variety of vendors offer commercial browsers that interpret and display a Web
document, and all of them use nearly the same architecture. Each browser
usually consists of three parts:
● a controller – receives input from keyboard
● client protocol – access the document
● Interpreters – display document on screen
32
Web Server
● Web site is collection of web pages while web server is a software that respond
to the request for web resources.
● When client sends request for a web page, the web server search for the
requested page if requested page is found then it will send it to client with an
HTTP response.
● If the requested web page is not found, web server will the send an HTTP
response : Error 404 Not found.
● A server can also become more efficient through multithreading or
multiprocessing. In this case, a server can answer more than one request at a
time.
● Some popular Web servers include Apache and Microsoft Internet Information
Server.
33
Uniform Resource Locator (URL)
● A URL (Uniform Resource Locator) is a unique identifier used to locate a
resource on the internet.
35
Dynamic Documents
● A dynamic web document does not exist in a
predefined form.
● When a request arrives the web server runs
an application program that creates the
document.
● The server returns the output of the program
as a response to the browser that requested
the document.
● Since a fresh document is created for each
request, the contents of a dynamic document
can vary from one request to another.
● Technologies involved – PHP, JSP, ASP etc.
● Dynamic documents are sometimes referred
to as server-site dynamic documents.
36
Active Documents
38
HTTP Transaction
● The Hypertext Transfer Protocol (HTTP) is a protocol used mainly to access data
on the World Wide Web.
● HTTP functions as a combination of FTP and SMTP.
● HTTP uses the services of TCP on well-known port 80.
● Request message
● Request Line
39
HTTP Transaction (Cont . . .)
● Format of request message and response message
40
Conditional Request
● Request based on condition is possible.
● If condition is met, server sends it; else client is informed about it.
● Example conditions - time and date the Web page is modified.
○ Request
GET [Link] HTTP/1.1
If-Modified-Since: Thu, Sept 04 [Link] GMT
○ Response
HTTP/1.1 304 Not Modified
Date: Sat, Sept 06 08 [Link] GMT
Server: [Link]
(Empty Body)
41
Persistence
● HTTP version 1.1 specifies a persistent connection by default.
● Connection is left open for more requests.
● Connection will be closed only after a request or if a time-out is reached.
● Length of data is sent by the sender on each response, but if it is unknown
(Dynamic documents) then the server informs client and closes the connection.
42
Cookies
● It is a small piece of data stored in users' system by the browser while browsing
a website.
● When the client receives the response from server on request, the browser
stores the cookie in the cookie directory.
● Next time, when a client sends a request to a server, the browser looks in the
cookie directory to see if it can find a cookie sent by that server.
● If found, the cookie is included in the request.
● Example – e-commerce
43
Web caching: Proxy server
● Proxy server acts as a gateway between client and server.
● It keeps copies of responses to recent requests.
● On receiving the request from client, proxy server checks its cache and if it is not
found then the request is sent to corresponding server.
● This reduces the load on the original server, decreases traffic, and improves
latency.
● However, to use the proxy server, the client must be configured to access the
proxy instead of the target server.
44
HTTP security
● HTTPS provides confidentiality, client and server authentication, and data
integrity.
● HTTP status codes are 3-digit codes most often used to indicate whether an HTTP
request has been successfully completed. Status codes are broken into the following 5
blocks:
○ 1xx Informational
○ 2xx Success
○ 3xx Redirection
○ 4xx Client Error
○ 5xx Server Error
45
DNS(Domain Name System)
● TCP/IP protocols uses IP address.
● Identifies connection of a host to the internet.
● System maps a name to an address
● Host file – only two columns (name, address)
● Single host file – maps the names to address
● Host file would be large to store in every host.
● Impossible to update the changes happens every time to the host file.
Solution 1
● Store the host file in a single system and allow the centralized information access to every system
that needs mapping.
Disadvantage
● Huge amount of traffic to the internet.
Solution 2
● Divide the huge amount of information into smaller parts and store on different systems.
● Host which needs mapping can communicate to the closest system that holds the information.
● This solution is called Domain Name System.
46
Purpose of DNS
Six steps to map host name to an IP address
1. User passes the host name to the file transfer client (FTC).
2. FTC passes the host name to DNS client.
3. DNS client sends a message to the DNS Server. The query gives the
file transfer server name using the known IP address of the DNS
server.
4. DNS server responses back with the IP address of the desired file
transfer server.
5. DNS client passes the IP address to file transfer server.
6. FTC uses the IP address it received to access the file transfer server.
47
Namespace
● Maps the address to the unique names.
● Organized in two ways flat or hierarchical.
Flat Name Space
● Name is assigned to an address, name is the sequence of characters without
structures.
Disadvantage
● Cannot used in large system.
● Centrally controlled to avoid ambiguity and duplications.
Hierarchical Name Space
● Each name is made up of several parts.
● First part – nature of organization
● Second part – name of an organization
● Third part – departments in the organization
● Namespace can be decentralized.
● Suffixes (or prefixes) are added to the name that defines the host or system. 48
Domain Name Space
Hierarchical name space – DNS was designed.
Names are defined in inverted tree structure
with root at top.
Tree have 128 levels – 0 (root) to 127.
Label
Each node in a tree has a label – max of 63
characters.
Domain Name System Root label is a null string.
Children node should have different labels
that will ensure uniqueness in domain names.
Domain Name
Full domain name is the sequence of labels
separated by dots.
Domain names read from nodes up to the root.
Full domain name always ends in a null label.
51
Domain Name Space
Zone
● What a server is responsible for or has authority over
is called zones.
● Zone is the contiguous part of the entire tree.
● If server accepts the responsibility for a domain and
does not divide the domain into smaller domains then
“domain” and “zone” refers the same thing.
Zones and Domains
Root server
● It is the server whose zone consists of the whole tree.
● It does not store any information about the domains
but delegates the authority to other servers, keeping
references to those servers.
52
Domain Name Space
Primary and Secondary Servers
Primary Server
● Server that stores the file about the zone for which it is in authority.
● It is responsible for creating, maintaining and updating the zone files.
● It stores zone file on a local disk.
Secondary Servers
● Server that transfers the complete information about zone from another server
and stores the file on its local disk.
● Secondary server neither creates nor updates the zone files.
53
DNS in the Internet
● In internet the domain name space is divided into three different
sections.
● Generic domains, country domains and the inverse domains.
Generic Domains
● Define registered hosts according to their generic behaviour.
● Each node in a tree defines a domain which is an index to the
domain name space database.
DNS used in internet
Inverse Domain
● It is used to map an address to a name.
Country Domains
● This happens when the server has received a request
from the client.
● Type of query called an inverse or pointer (PTR)
query.
● To handle the pointer query the inverse domain is
added to the domain name space with the first level
node.
● Second level is also one single node named in addr
(for inverse address).
55
Inverse Domain
Resolution
Mapping a name to an address or an address to a name is called name address resolution.
Resolver
● DNS is designed as a client – server application.
● Host that needs to map an address to a name or a name to an address calls a DNS client
called a resolver.
● After the resolver receives the mapping, it interprets the response to see if it is a real
resolution or an error and finally delivers the results to the process that requested it.
Recursive Resolution
● The client can ask for a recursive answer from a name
server.
Recursive resolution ● If the server is the authority for the domain name, it
checks its database and responds.
● If the server is not the authority it sends the request to
another server and waits for the response.
● If the parent is the authority it responds otherwise it
sends the query to another server.
57
Resolution Iterative Resolution
● If server is an authority for the name it sends the answer.
● If not it returns the IP address of the server that thinks it
can resolve the query.
● The client is responsible for repeating the request to the
second server.
● The client repeats the same procedure to next server and so
on
● This process is called iterative because the client repeats
the same query to multiple servers.
Catching
● Each time the server receives the query for a name that is
Iterative Resolution
not in domain it needs to search its database for a server IP
address.
● Reduction in search time would increase the efficiency.
● DNS handles this with the mechanism called catching.
58
Resolution
● Reduction of search time would increase the efficiency.
● DNS handles this with the mechanism called catching.
● Catching speeds up resolution but it can also be problematic.
● If the server catches the mapping for a long time it may send an outdated
mapping to the client.
DNS requires each server keep a TTL counter for each mapping it caches.
59
DNS Messages
● DNS messages are of two types
Query
Response
61
DNS Messages
● AA (Authoritative Answer) – 1 bit subfield
Set to 1 - name server is the authoritative server
Used only in response message.
63
DNS Messages
● Question Section
Consists of one or more question records
It is present in both query and response messages
● Answer Section
Consists of two or more resource records
It is present only on response messages
● Authoritative Section
Consists of two or more resource records
It is present only on response messages
Gives information (domain name) about one or more authoritative servers for the query
● Additional Information Section
Consists of two or more resource records
It is present only on response messages
Gives additional information that helps the resolver
64
FTP
● File Transfer Protocol (FTP) is the standard mechanism provided by TCP/IP
for copying a file from one host to another.
● FTP uses the services of TCP
● The well-known port 21 is used for the control connection
● The well-known port 20 for the data connection.
65
FTP
66
FTP – Data Connection
FTP creates a data connection with the following steps
1. The client issues a passive open using an ephemeral port.
2. The client sends the port number to the server using the PORT command.
3. The server receives the port number and issues an active open using the
well-known port 20 and the received ephemeral port number.
67
FTP – Communication
● Control Connection
68
FTP – Communication
● Data Connection
69
FTP - Commands
70
FTP- Commands
Type of Command Description Example
Access commands commands let the user access USER – Provides user information
the remote system PASS – Password
ACCT – Account Information
REIN – Reinitialize
QUIT – Logout
ABOR – Abort the previous commands
File management commands let the user CWD – Change to another directory
commands access the file system on DELE – Delete a file
the remote computer. LIST – List subdirectories
71
FTP- Commands
Type of Command Description Example
File Transfer commands commands let the user transfer RETR – Retrieve files
files STOR – Store files
APPE – if file exists append the
data
STAT – Return status of files
74
FTP – File Transfer
75
Example Using FTP
for retrieving a list of
items in a directory.
76
Example –
77
Example of how an
image (binary) file is
stored.
78
Anonymous FTP Example - assume that some public data are
available at [Link].
79
Security - FTP
● To be secure, one can add a Secure Socket Layer between the FTP application layer
and the TCP layer - In this case FTP is called SSL-FTP
● Another way to transfer files using a secure channel is to use another independent
protocol called sftp (secure file transfer protocol). This is actually a program in Unix
called sftp that is part of the SSH protocol
80
TFTP
● There are occasions when we need to simply copy a file without the need for
all of the features of the FTP protocol.
● For example, when a diskless workstation or a router is booted, we need to
download the bootstrap and configuration files.
● Trivial File Transfer Protocol (TFTP) is designed for these types of file transfer
● TFTP uses the services of UDP on the well-known port 69.
81
Message categories
The read request (RRQ) message is used by the client to establish a connection for reading data from the server
RRQ format
The write request (WRQ) message is used by the client to establish a connection for writing data to the server
WRQ format
DATA The data (DATA) message is used by the client or the server to send blocks of data.
Data Format
TFTP – Connection Establishment
83
UDP port numbers used by TFTP
84
TFTP - Example
85
Application - Use of TFTP with DHCP
86
REMOTE LOGGING
● It would be impossible to write a specific client/server program for
each demand. The better solution is a general-purpose client/server
program that lets a user access any application program on a remote
computer.
87
TELNET
88
Example of Telnet (Character mode)
89
Image Source: [Link]
Common Features of Telnet
• Telnet is on a single TCP connection to port 23
• Telnet connection is unencrypted
90
Telnet Commands
• telnet [Link]
91
SSH – Secure Shell
• Replacement of old unsecure Telnet program
• Both ends authenticate with each other
• Rely on public key cryptography
• All communication messages are encrypted
• SSH is used also as a secure tunneling channel for other applications
• File transfer
• Port forwarding (such as X window)
• Virtual private network (VPN)
92
SSH – Secure Shell
• Under Unix machine:
• Hidden directory .ssh saves all configuration files
93
SSH Programs and Usages
• private key kept on client, public key stored on server (come to this in later security
chapter)
94
What is Email?
95
How Email works?
96
How Email works?
● Once an email message has been sent, it follows several steps to its final
destination:
● The sender’s mail server, also called a Mail Transfer Agent (MTA), initiates
a Simple Mail Transfer Protocol (SMTP) connection.
● The SMTP checks the email envelope data — the text that tells the server
where to send a message — for the recipient’s email address, then uses
the Domain Name System (DNS) to translate the domain name into an IP
address.
● The SMTP looks for a mail exchange (MX) server associated with the
recipient’s domain name. If one exists, the email is forwarded to the
recipient’s mail server.
● The email is stored on the recipient’s mail server and may be accessed via
the Post Office Protocol (POP)* or Internet Message Access Protocol (IMAP).97
Architecture
98
POP3 & IMAP4
99
Advantages & Disadvantages
Advantages of email:
● Convenient and fast communication with individuals or groups globally.
● Easy to store and search for past messages.
● Ability to send and receive attachments such as documents, images, and videos.
● Cost-effective compared to traditional mail and fax.
● Available 24/7.
Disadvantages of email:
● Risk of spam and phishing attacks.
● Overwhelming amount of emails can lead to information overload.
● Can lead to decreased face-to-face communication and loss of personal touch.
● Potential for miscommunication due to lack of tone and body language in written
messages.
● Technical issues, such as server outages, can disrupt email service.
100