DHPC stands for Dynamic Host configuration Protocol.
For any device to be part of network, it must have an IP in order to communicate with other devices in the network.
Here device or Host mean the same.

IP Allocation
IP can be assign to a device in two ways:
1. Statically
2. Dynamically

Statically assigning an IP means manually configuring the device. However, this can be very hectic if we have to do for multiple devices. To overcome this tedious work, DHCP come in to picture.

DHCP is a protocol that helps in configuring/assigning the IP to the host dynamically. A host can be any IP device like computer, mobile etc.

Who allocates the Dynamic IP
A server called DHCP Server does all the allocation of IP to the devices. Usually, DHCP server is part of the same LAN network in which all the devices are connected.

DHCP Server can be any router in the network. Even your computer or laptop can also serve as DHCP Server.

Here Dynamic means that there is no guarantee that every time same host will get same IP whenever it is connected with Network. DHCP server allocates the IP based on lease time. This lease time can be 15 min, 30 min etc. After this lease time, if the client/Host does not ask for renewal of its IP, then this IP will be assign to anyone else in the network if anyone requested for an IP.

DHCP Protocol
DHCP is an application layer protocol.
DHCP is based on client–server model i.e. client request for an IP from server and server allocates free IP to the client.
DHCP uses UDP at transport layer.
DHCP server when allocates the IP, it gives below information to client.
1) IP Address
2) Subnet Mask
3) Default Gateway
4) Domain Name
5) DNS Server address

All the above information is necessary for any IP device to work properly.

DHCP Messages

DHCP uses DORA for allocation of IP.

D: Discover Message
O: offer Message
R: Request Message
A: Acknowledge Message

Discover Message
Client (who wants an IP) initiate with discover message. This discover message is a broadcast message because client does not know DHCP Server IP.  Therefore, client will broadcast the message to all the devices in the network.

Discover Message is send on UDP port 68

Source MAC address is set as its own client MAC address and source IP address is set since IP is not assign yet.

Destination MAC is set as FF:FF:FF:FF:FF:FF and destination IP address is set as Both the addresses are broadcast address.

Offer Message
The above discover message is reached to DHCP Server, as other devices will reject the message because it is sent on UDP port 68, which is only for DHCP server.

DHCP server see that it does not have its source IP and hence asking for IP. DHCP Server then sends offer message with IP and all other information on UDP port 67.

Request Message
After receiving the offer message from DHCP server, DHCP client sends the request message. This request message is also broadcast message. Now even though DHCP client now knows DHCP server IP but still it sends broadcast message instead of unicast message.

In the network, it is quite possible that there are more than one DHCP server present. Therefore, DHCP client sends broadcast request message to every DHCP server in the network to indicate that I am going to use this particular IP. All non-intended DHCP servers will get to know that they do not assign this IP and reject this message. Intended DHCP server will eventually accept the message.

Request message is send on UDP port 68.

Acknowledge Message
DHCP server after accepting the request message, sends acknowledge message to confirm to the DHCP client that you can use this IP.

Acknowledge message is send on UDP port 67.

Related posts