Binary Code and IP Addressing

Introduction: Definition

The IP address is the address that the router uses to route a packet.

The Bit and Byte Structure of the IP Address

IP addresses consist of four bytes. Each byte consists of 8 bits. That makes 32 bits total.

The bits are binary. That is they can be either a 0 or a 1, either on or off basically (though it's not quite that simple, electrically, but that's all you need to know for the CISCO).

The value of the bits is equal to either 0 or 1 times the place value. The place values are incremented, from right to left, as powers of 2--that is, the value doubles as you move from bit to bit (going from right to left). The lowest place value--the place value of the rightmost bit--is equal to 1. The next lowest place value--the place value of that bit that is just to the left of the rightmost bit--is equal to 2. The third lowest place value--the value of the third bit from the right--is equal to 4. And so on!

As noted there are eight bits in a byte, four bytes in a standard (IP version 4) IP address, and so there are thirty-two bits in a standard IP address.

The total value of each byte ranges from 0 to 255! You can calculate the value of any byte by adding up the values of each bit in the byte. The table below shows the place value of each bit in a byte. To calculate the value of a binary byte . . .
in, for example, 01101111 . . .

128's 64's 32's 16's 8's 4's 2's 1's
               

The Network and the Host Parts of the Address

The ip address is, for the purposes of addressing, divided into two parts. The network or subnet part of the address gives the ip address of the network or subnet. The host part of the address distinguishes a particular host (computer terminal) from other hosts on the same network or subnet.

Packet Routing

As noted above, the ip address is important in the routing of packets.

If the network part of the ip address header on a packet indicates that the packet's destination is in a different network (or subnet--that is, if the network or subnet address is different than network/subnet address of the network/subnet where the packet is being sent from), the packet is routed to the default gateway for the network (or subnet). The default gateway is a router attached to the network (with an address that is on the same network or subnet).

If the network part of the ip address header on a packet indicates that the packet's destination is in the same network (or subnet), then the packet is not routed to the default gateway. Instead, it must be routed to the appropriate MAC (hardware) address within that same network (or subnet).
(NOTE: A packet is never sent to a MAC address outside of the network or subnet where it currently is. Devices in a network (or subnet) do not keep track of MAC addresses except those for their own network [or subnet].)

The IP Address versus the MAC Address

IP Addresses and Broadcasting

Sometimes messages are sent to every ip address on a subnet or network. This is done using a broadcast address. In a broadcast address, the host part of the address is all 1's. How and why using all 1's works in broadcasting will be explained next.