Application Layer1
Application Layer1
The client uses all 0s as the source address and all 1s as the
destination address.
3. The server responds with either a broadcast or a unicast
message using UDP source port number 67 and destination
port number 68.
The response can be unicast because the server knows the IP
address of the client. It also knows the physical address of the
client, which means it does not need the services of ARP for
logical to physical address mapping.
Client and server on two different networks
The DHCP server knows the message comes from a relay agent
because one of the fields in the request message defines the IP
address of the relay agent.
The relay agent, after receiving the reply, sends it to the DHCP
client.
Use of UDP ports
The reason for choosing the well-known port 68 instead of an ephemeral
port is to prevent a problem when the reply, from the server to the client,
is broadcast.
When two hosts are sending DHCP request at the same time , a third
identification number called transaction ID differentiates the clients.
To understand the problem, let us look at a situation where an ephemeral port is
used.
Suppose host A on a network is using a DHCP client on ephemeral port 2017
(randomly chosen).
Host B, on the same network, is using a DAYTIME client on ephemeral port 2017
(accidentally the same).
Now the DHCP server sends a broadcast reply message with the destination port
number 2017 and broadcast IP address FFFFFFFF16.
Every host needs to open a packet carrying this destination IP address. Host A
finds a message from an application program on ephemeral port 2017.
A correct message is delivered to the DHCP client.
An incorrect message is delivered to the DAYTIME client.
The confusion is due to the demultiplexing of packets based on the socket address
(see Chapter 17), which is a combination of IP address and port number. In this
case, both are the same.
The use of a well-known port (less than 1024) prevents the use of the same
two destination port numbers.
Host B cannot select 68 as the ephemeral port because ephemeral port
numbers are greater than 1023.
In this case, the socket address is the same and both clients will receive the
message.
In this situation, a third identification number differentiates the clients. DHCP
uses another number, called the transaction ID, which is randomly chosen for
each connection involving DHCP.
It is highly improbable that two hosts will choose the same ID at the same time.
Using
• Using TFTP
• The server does not send all of the information that a
client may need for booting. In the reply message,
the server defines the pathname of a file in which
the client can find complete booting information. The
client can then use a TFTP message which is
encapsulated in a UDP user datagram, to obtain the
rest of the needed information.
DHCP packet format
Operation code. This 8-bit field defines the type of DHCP packet: request (1) or
reply (2).
Flag format
SELECTING State After sending the DHCPDISCOVER message, the client goes to
the selecting state. Those servers that can provide this type of service respond
with a DHCPOFFER message. In these messages, the servers offer an IP
address. They can also offer the lease duration. The default is 1 hour. The
server that sends a DHCPOFFER locks the offered IP address so that it is not
available to any other clients. The client chooses one of the
Exchanging messages
25
Chapter 19.1 Need for DNS
Outline 19.2 Name Spaces
19.3 DNS in the Internet
19.4 Resolution
19. 5 DNS Messages
19. 6 Types of Records
19. 7 Compression
19. 8 Encapsulation
26
19-1 NEED FOR DNS
27
Figure 19.1 Purpose of DNS
User
1
Host
name
Host
name
2
5
IP address
6 3 Query
IP address
Response 4
Transport layer
28
19-2 NAME SPACE
32
Figure 19.3 Domain names and labels
34
Figure 19.4 FQDN and PQDN
35
Distribution of Name Space
The information contained in the domain name space must be stored.
However, it is very inefficient and also not reliable to have just one computer store such
a huge amount of information.
It is inefficient because responding to requests from all over the world places a heavy
load on the system.
It is not reliable because any failure makes the data inaccessible.
39
Hierarchy of name servers
41
Primary and Secondary Servers
Note
Primary server
• Stores a file about the zone for which it is an authority.
• responsible for creating, maintaining, and updating the zone file.
• It stores the zone file on a local disk.
Secondary server
• Transfers the complete information about a zone from another server (primary
or secondary) and stores the file on its local disk.
• It neither creates nor updates the zone files.
• If updating is required, it must be done by the primary server, which sends the
updated version to the secondary.
42
Primary and Secondary Servers
19-3 DNS IN THE INTERNET(Types of Domain)
44
Figure 19.6 Generic domains
45
46
Figure 19.7 Country domains
47
Figure 19.8 Inverse domain
Reverse query
• The inverse domain is used to map
an address to a name.
• Also called pointer (PTR) query
• To handle a pointer query, the
inverse domain is added to the
domain name space with the first-
level node called arpa ,the second
level is named as in-addr (for
inverse address).
• Rest of the domain defines IP
addresses
48
Inverse Domain
The inverse domain is used to map an address to a name.
To handle a pointer query, the inverse domain is added to the domain name space
with the first-level node called arpa (for historical reasons).
The second level is also one single node named in-addr (for inverse address).
The servers that handle the inverse domain are also hierarchical.
This means the netid part of the address should be at a higher level than the
subnetid part, and the subnetid part higher than the hostid part.
In this way, a server serving the whole site is at a higher level than the servers
serving each subnet.
This configuration makes the domain look inverted when compared to a generic or
country domain.
To follow the convention of reading the domain labels from the bottom to the top,
an IP address such as 132.34.45.121 (a class B address with netid 132.34) is read as
121.45.34.132.in-addr. arpa.
• Registrar
• New domains are added to DNS through a registrar.
• a commercial entity accredited by ICANN( Internet
Corporation for Assigned Names and Numbers).
• A registrar first verifies that the requested domain name is
unique and then enters it into the DNS database. A fee is
charged.
51
Local Name Server
• Each ISP (residential ISP, company, university) has one.
– Also called “default name server”
• Does not strictly belong to hierarchy
• When a host makes a DNS query, query is sent to its local
DNS server
– Acts as a proxy, forwards query into hierarchy.
2: Application Layer
52
Recursive resolution
The client (resolver) can ask for a recursive answer from a name server.
This means that the resolver expects the server to supply the final answer.
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 (the
parent usually) and waits for the response.
If the parent is the authority, it responds; otherwise, it sends the query to yet
another server.
When the query is finally resolved, the response travels back until it finally
reaches the requesting client.
Example root DNS server
(Interaction of various DNS server)
2
• Host at cis.poly.edu 3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu
5
requesting host
cis.poly.edu
gaia.cs.umass.edu
2: Application Layer
55
Iterative Resolution
If the client does not ask for a recursive answer, the mapping can be done
iteratively.
If it is not, it returns (to the client) the IP address of the server that it
thinks can resolve the query.
The client is responsible for repeating the query to this second server.
If the newly addressed server can resolve the problem, it answers the
query with the IP address; otherwise, it returns the IP address of a new
server to the client.
Now the client must repeat the query to the third server.
This process is called iterative because the client repeats the same query
to multiple servers.
Caching
Each time a server receives a query for a name that is not in its domain, it needs to
search its database for a server IP address.
If the same or another client asks for the same mapping, it can check its cache memory
and resolve the problem.
However, to inform the client that the response is coming from the cache memory and
not from an authoritative source, the server marks the response as unauthoritative.
Caching speeds up resolution, but it can also be problematic.
If a server caches a mapping for a long time, it may send an outdated mapping to the
client.
To counter this, two techniques are used. First, the authoritative server always adds
information to the mapping called time-to-live (TTL).
It defines the time in seconds that the receiving server can cache the information.
After that time, the mapping is invalid and any query must be sent again to the
authoritative server. Second, DNS requires that each server keep a TTL counter for
each mapping it caches.
The cache memory must be searched periodically and those mappings with an expired
TTL must be purged
DNS records
59
DNS records
Type=A Type=CNAME
name is hostname name is alias name for some
value is IP address “canonical” (the real) name
(relay1.bar.foo.com, www.ibm.com is alias name
145.37.93.126,A) servereast.backup2.ibm.com
value is canonical name
• Type=NS
– name is domain (e.g. foo.com) Type=MX
– value is the hostname of value is canonical name of mail server
2: Application Layer 60
Steps followed in DNS
The user’s host wants to obtain the IP address of www.someschool.edu. This is
done as follows.
1. The same user machine runs the client side of the DNS application.
2. The browser extracts the hostname, www.someschool.edu, from the URL and
passes the hostname to the client side of the DNS application.
3. The DNS client sends a query containing the hostname to a DNS server.
4. The DNS client eventually receives a reply, which includes the IP address for
the hostname.
5. Once the browser receives the IP address from DNS, it can initiate a TCP
connection to the HTTP server process located at port 80 at that IP address.
19-5 DNS MESSAGES
62
Topics Discussed in the Section
Header
63
Figure 19.9 Query and response messages
64
Figure 19.10 Header format
Identification. This is a 16-bit field used by the client to match the response with
the query. The client uses a different identification number each time it sends a
query. The server duplicates this number in the corresponding response.
flags: query or reply, type of query reverse or forward…..
Number of question records- containing the number of queries in the question section
❑ Number of answer records-containing the number of answer records in the answer
section of the response message.
❑ Number of authoritative records-The authority section contains records of other
authoritative servers.
❑ Number of additional records-containing the number of additional records in the
additional section of a response message.
65
Topics Discussed in the Section
Question Record
Resource Record
66
Question record format
Query type
Query class
67
Resource record format
The server database consists of resource records. Resource records are also
what is returned by the server to the client.
68
Resource record format
• Domain name, Domain type, Domain class : duplication from question record
• Time-to-live: This is a 32-bit field that defines the number of seconds the answer
is valid.
• Resource data: This is a variable-length field containing the answer to the query
(in the answer section) or the domain name of the authoritative server (in the
authoritative section) or additional information (in the additional information
section).
69
Example 19.1
A resolver sends a query message to a local
server to find the IP address for the host
“chal.fhda.edu.”. We discuss the query and
response messages separately.
70
Response message
71
19-8 ENCAPSULATION
72
Nslookup
In UNIX and Windows, the nslookup utility can be used to retrieve address/name
mapping.
FTP: the file transfer protocol
2: Application Layer 75
• client/server model
– client: side that initiates transfer (either to/from remote)
– server: remote host
• FTP establishes two connections between the hosts. One connection
is used for data transfer, the other for control
information .
• FTP uses two well-known TCP ports: Port 21 is used for the control
connection, and port 20 is used for the data connection.
• The control connection remains connected during the entire
interactive FTP session.
• The data connection is opened and then closed for each file
transferred.
2: Application Layer 76
FTP Connection
1. The server issues a passive open on the well-known port 21 and waits for a client.
2. The client uses an ephemeral port and issues an active open.
1. The client, not the server, issues a passive open using an ephemeral port.
2. The client sends this port number to the server using the PORT command
3. The server receives the port number and issues an active open using the wellknown
port 20 and the received ephemeral port number.
The client must define the type of file to be transferred, the structure of the data, and
the transmission mode.
File type : ASCII file, EBCDIC file , Image file
Data Structure : File structure, Record structure, Page structure
Transmission Mode : Stream mode , Block mode, compressed mode
Sample return
commands:
codes
• sent
Each as
command
ASCII text
is over
followed
control
by achannel
reply,sent from server to client
• 331
USERUsername
usernameOK, password required
• 125
PASSdatapassword
connection already open; transfer
• starting
LIST or dir return list of file in the directory of FTP server
• 425 Can’t open data connection
• get filename retrieves (gets) file
• 452 Error writing file
• STOR filename stores (puts) file onto remote host
90
Figure shows an example of using FTP for retrieving a list of items
in a directory.
RRQ
The read request (RRQ) message is used by the client to establish a connection for
reading data from the server.
WRQ
The write request (WRQ) message is used by the client to establish a connection for
writing data to the server.
DATA
The data (DATA) message is used by the client or the server to send blocks of
data.
ACK
The acknowledge (ACK) message is used by the client or server to acknowledge
the receipt of a data block.
The ERROR message is used by the client or the server when a connection
cannot be established or when there is a problem during data transmission.
http://www.someschool.edu/someDept/pic.gif
1 Request
2
Static document
1 Request
2
Dynamic document
For many applications, we need a program or a script to be run at the client site.
These are called active documents.
1 Request
Run the applet
to get the result Applet 2
Result Active document
Server
running
Apache Web
server
time time
request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr
Carriage return,
(extra carriage return, line feed)
line feed
indicates end
of message
2: Application Layer 119
Method types
Post method:
Get method:
• The POST method requests that a web server accepts and
• HTTP GET method
stores the data enclosed in the body of the request message
requests a document from
Put method server
• Sends a document from the server
Headto the client
method
• Requests information
about a document but not
the document itself
Header Lines In Request Message After the request line, we can have zero or more
request header lines. Each header line sends additional information from the client to
the server. For example, the client can request that the document be sent in a special
format. Each header line has a header name, a colon, a space, and a header value
Body In Request Message The body can be present in a request message. Usually, it
contains the comment to be sent.
General format of an HTTP response message
The format of the response message is shown in Figure 22.12. A response message
consists of a status line, header lines, a blank line and sometimes a body.
Status Line
The first line in a response message is called the status line.
There are three fields in this line separated by spaces and terminated by a carriage
return and line feed.
The first field defines the version of HTTP protocol, currently 1.1.
The status code field defines the status of the request. It consists of three digits.
Whereas the codes in the 100 range are only informational, the codes in the 200 range
indicate a successful request. The codes in the 300 range redirect the client to another
URL, and the codes in the 400 range indicate an error at the client site. Finally, the
codes in the 500 range indicate an error at the server site.
The status phrase explains the status code in text form.
Header Lines
In Response Message After the status line, we can have zero or more response header
lines.
Each header line sends additional information from the server to the client.
For example, the sender can send extra information about the document.
Each header line has a header name, a colon, a space, and a header value.
Body
The body contains the document to be sent from the server to the client. The body is
present unless the response is an error message
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection close
Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
header Last-Modified: Mon, 22 Jun 1998 …...
lines Content-Length: 6821
Content-Type: text/html
origin
server
HT Proxy
TP st
req server reque
H ues TP se
client TTP t HT on
res
pon res p
se H TTP
e st
u
req se
P n
HT
T
s po
e
T Pr
HT
client
• SMTP is a push protocol; it pushes the message from the client to the
server.
• To pull the mail from mail server to the client we need another protocol
called POP3 and IMAPv4
– POP3: Post Office Protocol
– IMAP: Internet Mail Access Protocol
• more features (more complex)
From: alice@crepes.fr
MIME version To: bob@hamburger.edu
Subject: Picture of holidays
method used MIME-Version: 1.0
to encode data Content-Transfer-Encoding: base64
Content-Type: image/jpeg
multimedia data
type, subtype, base64 encoded data .....
parameter declaration .........................
......base64 encoded data
encoded data
Protocol functions
TCP port numbers
Push/pull protocol
Clients
Age difference
Supported data formats
• 2. HTTP and FTP clients: The common HTTP client is the browser while
FTP can be accessed via the command line or web browser
• 4. Data Formats: FTP can send data both in ASCII and Binary Format but
HTTP only uses Binary Format.
• 7. Compression Algorithms in HTTP: HTTP provides a way for the client and server
to negotiate and choose among several compression algorithms, algorithms are
not present in FTP.
TELNET is a general-purpose
client-server application program.
Data Characters For data, NVT normally uses NVT ASCII. This is an 8-bit
character set in which the seven lowest order bits are the same as US ASCII and
the highest order bit is 0.
Control Characters: to send control characters between computers, NVT uses
an 8-bit character set in which the highest order bit is set to 1.
c a t f i l e a IAC EC 1