Obtaining an IP Address

Before communicating with a device over a local network, we need to join the network. The router creates a local network and controls access to it. It has the job of allocating and assigning the IP addresses used on its local network. When a device connects to a network, it will automatically request an IP address from the router.

The following steps show a simplified TCP/IP transaction to get an IP address.

  1. PC Generates Request for IP Address
  2. IP Address Request Received in Router
  3. Router offers an IP address to the PC
  4. PC receives IP address from router
  5. PC configures its IP address

1 PC Generates Request for IP Address

Note that the PC’s IP Address is 0.0.0.0 before it is assigned. Also note the PC and the router are physically connected together with an Ethernet cable. The end of every Ethernet cable or WIFI antenna is connected to a network PHY. This PHY is a transceiver responsible for generating and driving the signals that propagate on the wire. It will also receive and decode signals generated by the PHY at the other end of the connection.

ipaddr_1.png
  • The MAC address has been intentionally left out of this slide to simplify it. We will discuss level 2 (MAC) addressing when switches are introduced.
  • The broadcast IP address is 255.255.255.255.

2 IP Address Request Received in Router

The router receives the packet and finds it has been sent to everyone on the network. It, therefore, has to pay attention to the packet. The router sees the sender of the packet needs an IP address assigned to it. That’s the router's job, so it creates a new IP address for it. All other hosts on the local network will eventually discard the packet once they discover the content of the message and realize they cannot provide an IP address.

3 Router offers an IP address to the PC

The router allocates a new IP address for the PC and generates a broadcast message containing this IP address.

ipaddr_2.png

Question:
Why does the router use the broadcast IP address instead of sending it directly to the PC’s IP address?
Answer:
It can’t send it to the PC because the PC doesn’t know its IP address yet and therefore doesn’t have the ability to filter packets based on its IP address.

As a side note, this frame sent by the router will include the destination MAC address of the PC. The IP address is a broadcast address, but the frame also includes the specific destination MAC address of the PC. A switch will use the MAC address to forward this frame to the PC only.
The MAC address is the physical address of a network node. This will be covered in more detail when we describe how a switch works.

4 PC receives IP address from router

The PC receives a packet that has been broadcast to everyone on the network. It opens the packet and finds it contains a message for someone requesting to have an IP address assigned to it. This is the message it has been waiting for!!

5 PC configures its IP address

The PC uses the IP address contained in the message to configure its network interface. It is now able to communicate on the network with it.

ipaddr_3.png
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.