Each device on a network must be uniquely defined. At the Network layer, the packets of the communication need to be identified with the source and destination addresses of the two end systems. With IPv4, this means that each packet has a 32-bit source address and a 32-bit destination address in the Layer 3 header.
These addresses are used in the data network as binary patterns. Inside the devices, digital logic is applied for their interpretation. For us in the human network, a string of 32 bits is difficult to interpret and even more difficult to remember. Therefore, we represent IPv4 addresses using dotted decimal format.
Dotted Decimal
Binary patterns representing IPv4 addresses are expressed as dotted decimals by separating each byte of the binary pattern, called an octet, with a dot. It is called an octet because each decimal number represents one byte or 8 bits.
For example, the address:
10101100000100000000010000010100
is expressed in dotted decimal as:
172.16.4.20
Keep in mind that devices use binary logic. The dotted decimal format is used to make it easier for people to use and remember addresses.
Network and Host Portions
For each IPv4 address, some portion of the high-order bits represents the network address. At Layer 3, we define a network as a group of hosts that have identical bit patterns in the network address portion of their addresses.
Although all 32 bits define the IPv4 host address, we have a variable number of bits that are called the host portion of the address. The number of bits used in this host portion determines the number of hosts that we can have within the network.
Click the labels in the figure to see the different parts of the address.
For example, if we need to have at least 200 hosts in a particular network, we would need to use enough bits in the host portion to be able to represent at least 200 different bit patterns.
To assign a unique address to 200 hosts, we would use the entire last octet. With 8 bits, a total of 256 different bit patterns can be achieved. This would mean that the bits for the upper three octets would represent the network portion.
Note: Calculating the number of hosts and determining which portion of the 32 bits refers to the network will be covered later in this chapter.
To understand the operation of a device in a network, we need to look at addresses and other data the way the device does - in binary notation. This means that we need to have some skill in binary to decimal conversion.
Data represented in binary may represent many different forms of data to the human network. In this discussion, we refer to binary as it relates to IPv4 addressing. This means that we look at each byte (octet) as a decimal number in the range of 0 to 255.
Positional Notation
Learning to convert binary to decimal requires an understanding of the mathematical basis of a numbering system called positional notation. Positional notation means that a digit represents different values depending on the position it occupies. More specifically, the value that a digit represents is that value multiplied by the power of the base, or radix, represented by the position the digit occupies. Some examples will help to clarify how this system works.
For the decimal number 245, the value that the 2 represents is 2*10^2 (2 times 10 to the power of 2). The 2 is in what we commonly refer to as the "100s" position. Positional notation refers to this position as the base^2 position because the base, or radix, is 10 and the power is 2.
Using positional notation in the base 10 number system, 245 represents:
245 = (2 * 10^2) + (4 * 10^1) + (5 * 10^0)
or
245 = (2 * 100) + (4 * 10) + (5 * 1)
Binary Numbering System
In the binary numbering system, the radix is 2. Therefore, each position represents increasing powers of 2. In 8-bit binary numbers, the positions represent these quantities:
2^7 2^6 2^5 2^4 2^32^2 2^1 2^0
128 64 32 16 8 4 2 1
The base 2 numbering system only has two digits: 0 and 1.
When we interpret a byte as a decimal number, we have the quantity that position represents if the digit is a 1 and we do not have that quantity if the digit is a 0, as shown in the figure.
1 1 1 1 1 1 1 1
128 64 32 16 8 4 2 1
A 1 in each position means that we add the value for that position to the total. This is the addition when there is a 1 in each position of an octet. The total is 255.
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
A 0 in each position indicates that the value for that position is not added to the total. A 0 in every position yields a total of 0.
0 0 0 0 0 0 0 0
128 64 32 16 8 4 2 1
0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 = 0
Notice in the figure that a different combination of ones and zeros will yield a different decimal value.
See the figure for the steps to convert a binary address to a decimal address.
In the example, the binary number:
10101100000100000000010000010100
Is converted to:
172.16.4.20
Keep these steps in mind:
Divide the 32 bits into 4 octets.
Convert each octet to decimal.
Add a "dot" between each decimal.
Not only do we need to be able to convert binary to decimal, we also need to be able to convert decimal to binary. We often need to examine an individual octet of an address that is given in dotted decimal notation. Such is the case when the network bits and host bits divide an octet.
As an example, if a host with the 172.16.4.20 were using 28 bits for the network address, we would need to examine the binary in the last octet to discover that this host is on the network 172.16.4.16. This process of extracting the network address from a host address will be explained later.
Address Values are Between 0 and 255
Because our representation of addresses is limited to decimal values for a single octet, we will only examine the process of converting 8-bit binary to the decimal values of 0 to 255.
To begin the conversion process, we start by determining if the decimal number is equal to or greater than our largest decimal value represented by the most-significant bit. In the highest position, we determine if the value is equal to or greater than 128. If the value is smaller than 128, we place a 0 in the 128-bit position and move to the 64-bit position.
If the value in the 128-bit position is larger than or equal to 128, we place a 1 in the 128 position and subtract 128 from the number being converted. We then compare the remainder of this operation to the next smaller value, 64. We continue this process for all the remaining bit positions.
See the figure for an example of these steps. We convert 172 to 10101100.
No comments:
Post a Comment
Your Comment Please
This Blog is Do Follow