The Embedded New Testament

The "Holy Bible" for embedded engineers


Project maintained by theEmbeddedGeorge Hosted on GitHub Pages — Theme by mattgraham

IPV4 addressing

Each IP address is 32 bits long (equivalently, 4 bytes), and there are thus a total of 232 possible IP addresses.

The boundary between the host and the physical link is called an interface. The boundary between the router and any one of its links is also called an interface. A router thus has multiple interfaces, one for each of its links. Because every host and router is capable of sending and receiving IP datagrams, IP requires each host and router interface to have its own IP address. Thus, an IP address is technically associated with an interface, rather than with the host or router containing that interface.

interface connection

In IP terms, this network interconnecting three host interfaces and one router interface forms a subnet. IP addressing assigns an address to this subnet: 223.1.1.0/24, where the /24 notation, sometimes known as a subnet mask, indicates that the leftmost 24 bits of the 32-bit quantity define the subnet address.

interface connection with subnets

The x most significant bits of an address of the form a.b.c.d/x constitute the network portion of the IP address, and are often referred to as the prefix (or network prefix) of the address.

Obatining a host address: the DHCP protocol

Host addresses can also be configured manually, but more often this task is now done using the Dynamic Host Configuration Protocol (DHCP)

DHCP allows a host to obtain (be allocated) an IP address automatically. In addition to host IP address assignment, DHCP also allows a host to learn additional information, such as its subnet mask, the address of its first-hop router (often called the default gateway), and the address of its local DNS server.

Because of DHCP’s ability to automate the network-related aspects of connecting a host into a network, it is often referred to as a plug-and-play protocol. As the hosts join and leave, the DHCP server needs to update its list of available IP addresses. Each time a host joins, the DHCP server allocates an arbitrary address from its current pool of available addresses; each time a host leaves, its address is returned to the pool.

DHCP is a client-server protocol. A client is typically a newly arriving host wanting to obtain network configuration information, including an IP address for itself.

DHCP client server

For a newly arriving host, the DHCP protocol is a four-step process (DORA):

DHCP protocol

DHCP message format

DHCP message format

Here is a detailed explanation of DHCP packet fields

Reference

http://www.tcpipguide.com/free/t_DHCPMessageFormat.htm

https://www.geeksforgeeks.org/how-dhcp-server-dynamically-assigns-ip-address-to-a-host/

https://www.youtube.com/watch?v=k4t-NJrKLgM&ab_channel=HowTo