18.
1 Introduction
The information that is held in each computer attached to a
TCP/IP internet
Its IP address
Its subnet mask
The IP address of a router
The IP address of a name server
The above information is usually stored in a configuration
file and accessed by the computer during the bootstrap
process
In the case of a diskless computer, the operating system and
networking S/W can be stored in ROM. But the above
information cannot be stored in ROM
Previous Protocol
RARP ( Reverse Address Resolution Protocol)
Provide the IP address for a booted computer
Map a physical address to an IP address
But deprecated today for two reasons
RARP used the broadcast service of the data link layer
So RARP server must be present in each network
RARP can provide only the IP address of the computer
Today, a computer requires IP address, subnet mask, IP address of router, IP
address of name server.
Previous Protocol (cont’)
BOOTP ( Bootstrap Protocol)
Prerunner of DHCP
Client/Server protocol designed
BOOTP server can be anywhere in the Internet
BOOTP can provide all pieces of information
But BOOTP is a static configuration protocol : When a client
requests its IP address, the BOOTP server consults a table that
matches the physical address of the client with its IP address. This
implies that the binding between the physical address and the IP
address of the client already exists. The binding is predetermined.
BOOTP can not support dynamic configuration: example, when a
host moves from one physical network to another, its physical
address changes.
DHCP
Dynamic Host Configuration Protocol
DHCP is a client/server protocol designed to provide the four
pieces of information for a diskless computer or a computer that is
booted for the first time.
Successor to BOOTP and is backward compatible with it
Meaning that a host running the BOOTP client can request a static configuration
to a DHCP server
DHCP provides temporary IP addresses for a limited period of time
UDP port number 67 is the destination port of a server, and UDP port
number 68 is used by the client.
18.2 DHCP Operation
1. A client broadcasts a DHCPDISCOVER message using destination port
67
2. Servers respond with a DHCPOFFER message including an IP address
Offering the duration of the lease - default : one hour
The server that sends a DHCPOFFER locks the offered IP address so that it
is not available to any other clients
If the client receives no DHCPOFER message, it will try four more times,
each with a SPAN of two seconds.
If there is no reply to any of these DHCPDISCOVERs, the client sleeps for
five minutes before trying again
3. The client chooses one of the offers and sends a DHCPREQUEST
message to the selected sever
DHCP Operation (cont’)
4. The server responds with a DHCPACK message and creates the binding
between the client physical address and its IP address
DHCP Operation (cont’)
4. The server responds with a DHCPACK message and creates the binding
between the client physical address and its IP address
5. Before 50 percent of the lease period is reached, the client sends another
DHCPREQUEST and asks for renewal
6. If the server responds with a DHCPACK, the client has a new lease
agreement and can reset its timer. If the server responds with a
DHCPNACK, the client must immediately stop using the IP address and
find another server (step 1)
7. If the sever does not respond, the client sends another DHCPREQUEST
when the lease time reaches 87.5 percent. If the client terminates the lease
prematurely, the client sends a DHCPRELEASE message to the server.
DHCP Operation (cont’)
Client and server on the same network
1. The DHCP server issues a passive open command on UDP port
number 67 and waits for a client
2. A booted client issues an active open command on port number
68.
3. The UDP user datagram, in turn, is encapsulated in an IP
datagram. The reader may ask how a client can send an IP
datagram when it knows neither its own IP address (the source
address) nor the server’s IP address (the destination address). The
client uses all 0s as the source address and all 1s as the
destination address
4. The server responds with either a broadcast or a unicast
message using UDP source port number 67 and destination port
68
DHCP Operation (cont’)
Client and server on the same network
DHCP Operation (cont’)
Client and server on two different networks
DHCP request is broadcast because the client does not know the IP
address of server
Broadcast IP datagram cannot pass through any router
To solve above problem, one of the hosts can be used as a relay,
called relay agent.
Relay agent knows the unicast address of a DHCP server
Listen for broadcast message on port 67
When it receives this type of packet, it encapsulates the message in a unicast
datagram and sends the request to the DHCP server
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.
DHCP Operation (cont’)
Client and server on two different networks
DHCP Operation (cont’)
Use of UDP ports
DHCP Operation (cont’)
Error Control
DHCP uses UDP, which does not provide error control
Therefore, DHCP must provide error control.
DHCP requires that UDP uses the checksum.
Using of the checksum in UDP is optional
The DHCP client uses timers and a retransmission policy if it does not
receive the DHCP reply to a request.
DHCP forces the client to use a random number to set its timers
DHCP Operation (cont’)
Packet Format
Operation code. This 8-bit field defines the type of DHCP packet: request (1) or reply (2).
Hardware type. This is an 8-bit field defining the type of physical network. Each type of network has been assigned
an integer. For example, for Ethernet the
value is 1
Hardware length. This is an 8-bit field defining the length of the physical address in bytes. For example, for
Ethernet the value is 6.
Hop count. This is an 8-bit field defining the maximum number of hops the packet can travel.
Transaction ID. This is a 4-byte field carrying an integer. The transaction identification is set by the client and is
used to match a reply with the request. The server returns the same value in its reply.
Number of seconds. This is a 16-bit field that indicates the number of seconds elapsed since the time the client
started to boot.
Flag. This is a 16-bit field in which only the leftmost bit is used and the rest of the bits should be set to 0s. A
leftmost bit specifies a forced broadcast reply (instead of unicast) from the server. If the reply were to be unicast to
the client, the destination IP address of the IP packet is the address assigned to the client. Since the client does not
know its IP address, it may discard the packet. However, if the IP datagram is broadcast, every host will receive and
process the broadcast message.
DHCP Operation (cont’)
Flag format and optional format
Client IP address. This is a 4-byte field that contains the client IP address. If the client does not have this
information, this field has a value of 0.
Your IP address. This is a 4-byte field that contains the client IP address. It is filled by the server (in the reply
message) at the request of the client.
Server IP address. This is a 4-byte field containing the server IP address. It is filled by the server in a reply message.
Gateway IP address. This is a 4-byte field containing the IP address of a router. It is filled by the server in a reply
message.
Client hardware address. This is the physical address of the client. Although the server can retrieve this address
from the frame sent by the client, it is more efficient if the address is supplied explicitly by the client in the request
message.
Server name. This is a 64-byte field that is optionally filled by the server in a reply packet. It contains a null-
terminated string consisting of the domain name of the server. If the server does not want to fill this field with data,
the server must fill it with all 0s.
Boot filename. This is a 128-byte field that can be optionally filled by the server in a reply packet. It contains a null-
terminated string consisting of the full pathname of the boot file. The client can use this path to retrieve other
booting information. If the server does not want to fill this field with data, the server must fill it with all 0s.
Options. This is a 64-byte field with a dual purpose. It can carry either additional information (such as the network
mask or default router address) or some specific vendor information.The field is used only in a reply message. The
server uses a number, called a magic cookie, in the format of an IP address with the value of 99.130.83.99.When
the client finishes reading the message, it looks for this magic cookie. If present, the next 60 bytes are options. An
option is composed of three fields: a 1-byte tag field, a 1-byte length field, and a variable-length value field. The length
field defines the length of the value field, not the whole option
DHCP Operation (cont’)
Options for DHCP
18.3 Configuration
The DHCP has been devised to provide static and dynamic address allocation
DHCP has two DBs
One for statically binding between physical address and IP address
The other one with a pool of available IP addresses
When a DHCP client requests a temporary IP addresses, the DHCP sever assigns an IP
address from a pool for a negotiable period of time
When a DHCP client sends a request to a DHCP server
At first, checking its static database
If not , selecting an IP address from the available pool
Leasing
The DHCP server issues a lease for a specific period of time
When the lease expires, the client must either stop using the IP address or renew
the lease
Configuration (cont’)
Optional with tag 53
Configuration (cont’)
DHCP client transition diagram
Configuration (cont’)
DHCP client transition diagram
INIT state
First sate of client
The client broadcasts a DHCPDISCOVER message
Selecting state
After sending DHCPDISCOVER message, the client goes to the selecting state.
Server respond with DHCPOFFER message including IP address
Requesting state
After receiving DHCPOFFER message, the client goes to the requesting state.
The client sends a DHCPREQUEST message to the server
The client remains in the requesting state until it receives a DHCPACK message
from the server
Configuration (cont’)
Bound state
After receiving DHCPACK message, the client goes to the bound state
In this state, the client can use IP address until the lease expires
When 50 percent of the lease period is reached, the client sends another
DHCPREQUEST to ask for renewal and goes to renewing state
Renewing state
If the client receive a DHCPACK, it resets its timer and goes back to the bound
state
If a DHCPACK is not received, and 87.5 percent of the lease time expires, the
client goes to the rebinding state
Rebinding state
If the client receive a DHCPNACK or the lease expires, it goes back to the
initializing state
If the client receives a DHCPACK, it goes to the bound state and resets the
timers
Configuration (cont’)
Exchanging message
Summary
Every computer attached to a TCP/IP internet must know its IP address, the IP address of a
router, the IP address of an name server, and its subnet mask. Dynamic Host Configuration
Protocol (DHCP) is a client-server application that deliver vital network information to either
diskless computers or computers at first boot
One DHCP packet format is used for both the client request and the server reply. The DHCP
server waits passively for a client request. A server reply can be broadcast or unicast. A DHCP
request or reply is encapsulated in a UDP user datagram.
When the DHCP client and server are on different networks, a relay agent is used to send local
DHCP request from a client to remote servers
When DHCP acts as static configuration protocol, it uses a table that maps IP addresses to
physical addresses. When DHCP acts as a dynamic configuration protocol, it leases IP addresses
to the requesting clients.
DHCP client is designed as a state machine that uses six main states and three timers to allow a
host to lease an IP address for a specified period time.