Wednesday, 12 July 2017

The IPv4 Prefix Length, Host and Broadcast Addresses

The Prefix Length


Expressing network addresses and host addresses with the dotted decimal subnet mask address is very difficult. So there is an alternate method of identifying a subnet mask called the prefix length. The prefix length is the number of bits set to 1 in the subnet mask. It is written in “slash notation”, which is a “/” followed by the number of bits set to 1 in the subnet mask. Therefore, count the number of bits in the subnet mask and write slash followed by the number of bits set to 1.


The table in the figure illustrates the slash notation. The first column lists various subnet masks that can be used with a host address. The second column displays the converted 32-bit binary address. The last column displays the resulting prefix length.






























































































































The Subnet Mask



32-bit address



Prefix-length



255.0.0.0



11111111.00000000.00000000.00000000



/8



255.128.0.0



11111111.10000000.00000000.00000000



/9



255.192.0.0



11111111.11000000.00000000.00000000



/10



255.224.0.0



11111111.1110000.00000000.00000000



/11



255.240.0.0



11111111.11110000.00000000.00000000



/12



255.248.0.0



11111111.11111000.00000000.00000000



/13



255.252.0.0



11111111.11111100.00000000.00000000



/14



255.254.0.0



11111111.11111110.00000000.00000000



/15



255.255.0.0



11111111.11111111.00000000.00000000



/16



255.255.128.0



11111111.11111111.10000000.00000000



/17



255.255.192.0



11111111.11111111.11000000.00000000



/18



255.255.224.0



11111111.11111111.11100000.00000000



/19



255.255.240.0



11111111.11111111.11110000.00000000



/20



255.255.248.0



11111111.11111111.11111000.00000000



/21



255.255.252.0



11111111.11111111.11111100.00000000



/22



255.255.254.0



11111111.11111111.11111110.00000000



/23



255.255.255.0



11111111.11111111.11111111.00000000



/24



255.255.255.128



11111111.11111111.11111111.00000000



/25



255.255.255.192



11111111.11111111.11111111.11000000



/26



255.255.255.224



11111111.11111111.11111111.11100000



/27



255.255.255.240



11111111.11111111.11111111.11110000



/28



255.255.255.248



11111111.11111111.11111111.11111000



/29



255.255.255.252



11111111.11111111.11111111.11111100



/30



Host Address


The host address is a unique IP addresses which is assigned to hosts and devices. The host portion always contains various 0s and 1s but never all 0s or all 1s.


First Host Address


The first available host IP address in that network which has all 0s and end with a 1 in the host portion. It is also called first usable IP address.


Example




















 Dotted Decimal Notation Binary
Network IP Address172.16.16.0/2010101100.00010000.00010000.00000000
First Usable IP address172.16.16.110101100.00010000.00010000.00000001

Last Host Address


The last available host IP address in that network which has 1s and ends with a 0 in the host portion.It is also called last usable IP address.


Example




















 Dotted Decimal Notation Binary
Network IP Address172.16.16.010101100.00010000.00010000.00000000
Last Usable IP Address172.16.31.25410101100.00010000.00011111.11111110

Broadcast Address


This is a special address that communicates with all hosts in a network. For example, when a host sends a packet to the network broadcast address, all hosts in the network will receive the packet. The broadcast address uses the highest address in the network range. The broadcast address has all 1s in the host portion.


Example




















 Dotted Decimal Notation Binary  
Network IP Address172.16.16.010101100.00010000.00010000.00000000  
Broadcast IP address172.16.31.25510101100.00010000.00011111.11111111

 

Sunday, 9 July 2017

ANDing – Determining Network Address

Inside network devices, digital logic is applied for their interpretation of the addresses. When creating an IPv4 packet, the destination network address must be extracted from the destination address. This is done by a logic called ANDing. ANDing is the basic binary operation to determine network address. There is two other process that is also used in data networking but not used for determining IP address. The other two are OR and NOT operation.  The IPv4 address is logically ANDed with its subnet mask to determine the network address to which the is associated. When ANDing between the address and the subnet mask is performed, the result gives the network address.


AND Operation


A Logic AND Gate is a type of digital logic gate that has an output which is usually at logic level “0” and only goes “HIGH” to a logic level “1” when ALL of its inputs are at logic level “1”


The output state of a “Logic AND Gate” return “LOW” when any of its inputs are at a logic level “0”. In other words for a logic AND gate, any LOW input will give a LOW output.


The logic expression given for a digital logic AND gate is that for Logical Multiplication which is denoted by a single dot or full stop symbol, ( . ) giving us the Boolean expression of  A.B = X


Logical AND is the operation of two bits that gives the following result.


0 AND 0 = 0


0 AND 1 = 0


1 AND 0 = 0


1 AND 1 = 1


So Anything ANDed with a 0 produces a 0. These characteristics of ANDing are used with the subnet mask to “mask” the host bits of an IPv4 address. Each bit of the address is ANDed with the parallel bit to the subnet mask. As we learn in previous lessons that all bits of the subnet mask that represent host bits are 0s, the host portion of the resultant network become all 0s. Remember that all 0 in the host portion of IPv4 address mean that this is the network address. As we know that all bits of subnet mask in network portion are all 1s. when each of these 1s ANDed with a parallel bit of the address, the resulting bits are identical to the original address bits.


So to identify the network address of an IPv4 host, the IPv4 address is logically ANDed, bit by bit, with the subnet mask. ANDing between the address and the subnet mask produce the network address.


Example 1: Find out what the network ID for the following IP address.
IP address:          192.168.100.150
IP subnet mask: 255.255.255.0


The binary equivalent for IP address 140.12.26.128:



  • 192 binary is 11000000

  • 168 binary is 10101000

  • 100 binary is 01100100

  • 50 binary is 00110010


So the binary for this IP address is:  11000000.10101000.01100100.00110010


Now look at the binary equivalent for the subnet mask 255.255.255.0:



  • 255 binary is 11111111

  • 255 binary is 11111111

  • 240 binary is 11111111

  • 0 binary is 00000000


So the binary for the subnet mask is 11111111. 11111111. 11111111. 00000000
Now subtract the binary IP address from the binary subnet mask
And then convert it to decimal.


Binary IP Address:         11000000.10101000.01100100.00110010
Binary subnet mask:    11111111. 11111111. 11111111.00000000
                                              ====================================
Binary Result                   11000000. 10101000.01100100.00000000
Decimal result:                    192.             168.            100.              0


So the network ID for this IP/subnet is 192.168.100.0. Lets check the network ID for 172.16.31.240 IP address which subnet mask is 255.255.248.0


Example -2


IP address:          172.16.31.240
IP subnet mask: 255.255.248.0


The binary for this IP address is:  10101100.00010000.00011111.11110000 and the binary equivalent for the subnet mask 255.255.248.0
The binary for the subnet mask is 11111111. 11111111. 11110000. 00000000
now subtract binary subnet mask from binary IP address.


Binary IP Address:          10101100.00010000.00011111.11110000
Binary subnet mask:     11111111. 11111111. 11110000.00000000
                                             ====================================
Binary Result                10101100.00010000.00010000.00000000
Decimal result:                    172.             16.            16.          0

Thursday, 6 July 2017

Network and Host Portion of IPv4 Address

Each network running with TCP/IP must have a unique network number, and every machine on the network must have a unique IP address. It is very important to know how IP addresses are constructed and what is the structure of IP addresses. The IPv4 address is a 32-bit number that uniquely identifies a network interface on a machine. An IPv4 address is typically written in decimal digits, formatted as four 8-bit fields separated by periods. Each 8-bit field represents a byte of the IPv4 address. This form of representing the bytes of an IPv4 address is often referred to as the dotted-decimal format.


The understanding binary notation is very important to understand IP address and its portions. The IPv4 address is a hierarchical address that is made up of a network portion and a host portion. When determining the network portion vs the host portion, it is important to look at the 32-bit stream of IPv4 address. Within the 32-bit stream, a portion of the bits identify the network portion, and a portion of the bits identify the host portion.


The bits within the network portion of the address must be the same for all devices that exist in the same network. The bits within the host portion of the address must be unique to identify a specific host within a network. If two hosts have the same bit-pattern in the specified network portion of the 32-bit stream, those two hosts will be located in the same network. The subnet mask is used to identify the host portion and network portion of the IP address.


The Subnet Mask


Three important parameters must be configured for an each host in a network which is following.



  • Host Unique IPv4 address– Unique IPv4 address of the host which identify the host number on the network.

  • Subnet mask- Used to identify the network portion and host portion of the IPv4 address.

  • Host Default gateway– Host default gateway used to Identifies the local gateway to reach other networks.


Understanding of the subnet mask is very important to determine the network portion and host portion of the IP address. The network address represents all the devices on the same network.


Figure 1 displays the dotted decimal address and the 32-bit subnet mask. Important to remember host portionthat Network bets must be all 1s and host bits must be all 0s in the subnet mask. As you can see in figure 2 in the subnet mask a sequence of 1 bits followed by a sequence of 0 bits. So To identify the network and host portions of an IPv4 address, the subnet mask is compared to the IPv4 address bit, from left to right as shown in Figure 2.host portion The 1s in the subnet mask identifies the network portion while the 0s in the subnet mask identify the host portion.  The process that is used to identify the network portion and host portion are called ANDing. The ANDing will be explained in text lesson.

Wednesday, 28 June 2017

Converting Between Decimal and Binary

Conversion of binary to decimal (base-2 to base-10) numbers and back is an important concept to understand as the binary numbering system forms the basis for all computer and digital systems. To understand IP address and IP address subnetting it is very important to learn conversion between binary and decimal. 


Binary to Decimal Conversion


The binary system is the internal language of the computer. For understanding IP addressing and subnetting, you should understand how to convert from binary to decimal and back. There are several ways to convert from binary to decimal. Here we will understand conversion from binary to decimal and then from decimal to binary.


Conversion Using Positional Notation


We have already learned positional notation in the previous lesson. This is one of the most used methods for conversion from binary to decimal. Let's we want to convert the binary number 101111102 to decimal base 10 system using the positional system notation. See figure 1, First, write down the positional value from right to left. Then right binary number in the next row below the positional values. Next, multiply the binary with its positional value in the next row. Now add them up you will get the decimal number which is 189.


binary conversion


We can just sample this method by writing positional values from right to left. The positional value is going double from right to left. For example from right to left first positional value is 1, the next one is 2, which is double of 1, the third position value is 4 which is double of the 2nd position value. We can write positional value by this method according to the digits of binary.


Now, just write the binary numbers below the positional values and map them up. Draw a line below these 2 lines. Now If the digit is a 1, write its corresponding positional value below the line, under the digit. If the digit is a 0, write a 0 below the line, under the digit. Now, add up the numbers written below the line. This is the decimal equivalent of the binary number. See figure 2 for this method.


binary conversion


Now that you understand the basic conversion from binary to decimal, try out converting a binary IPv4 address to its dotted-decimal equivalent. First, divide 32 bits of the IPv4 address into four 8-bit octets. Then calculate the binary positional value to the first octet binary number and calculate all others accordingly.


For example, consider that 11010100.10101111.00101011.01001010 is the binary IPv4 address of a host. You need to convert the binary address to decimal, start with the first octet as shown in Figure 3. Enter the 8-bit binary number under the positional value of row 1 and then calculate to produce the decimal number for the first octet of the dotted decimal notation. Next convert the other 3 octets accordingly see figure 4, figure 5 and figure 6. And write down the full IP address in dotted decimal notation.


binary conversion


 


binary conversion


 


binary conversion


 


binary conversion


Decimal to Binary Conversion


Decimal to binary conversion is also very necessary to understand, how to convert a dotted decimal IPv4 address to binary. For converting from decimal to binary, positional value table is very useful. Figure 7 illustrates the decimal to the binary conversion process. For example, we want to convert figure 212 into binary.


Step-1 -if the decimal number (212) is equal to or greater than the most-significant bit (128). If no, then enter binary 0 below the 128 positional value. If yes, then add a binary 1 below the 128 positional value and subtract 128 from the decimal number.


Step- 2 -Compare if the remainder (84) is equal to or greater than the next-most-significant bit (64). If no, then add a binary 0 below the 64 positional value, if not add binary 1 and subtract 64 from the decimal remainder (84).


Step- 3 Compare if the remainder (20) is equal to or greater than the next-most-significant bit (32). If no, then add a binary 0 in the 32 positional value, otherwise, add binary 1 and subtract 32 from the decimal. Here we can see that the reminder is not greater than 32. So we will add 0 below the positional value and forward the remainder (20) to step 4.


Step- 4 -Compare if the remainder (20) is equal to or greater than the next-most-significant bit (16). If no, then add a binary 0 below the 16 positional value, if not add binary 1 and subtract 16 from the decimal remainder (20).


Step- 5 -Compare if the remainder (4)  is equal to or greater than the next-most-significant bit (8). If no, then add a binary 0 below the 8 positional value, if not add binary 1 and subtract 8 from the decimal remainder (4).


Step- 6 -Compare if the remainder (4) of step 4 is equal to or greater than the next-most-significant bit (4). If no, then add a binary 0 below the 4 positional value, if not add binary 1 and subtract 4 from the decimal remainder (4).


binary conversion

Tuesday, 27 June 2017

Positional Number System

A positional Number system is a system which represents numbers by an ordered set of numerals symbols called digits,  in which the value of numbers depends on its position. So This system gives a different meaning to the same symbol depending on its position.  Our daily life number system, decimal numbering system (base 10) is an example of a Positional Number System. The position in which the digit appears affects the value of that digit.


For example, the number 4321 has a very different value than the number 1234; although the same digits are used in both numbers. In a positional number system, the value of each digit is determined by which place it appears in the full number. The lowest place value is the rightmost position, and each successive position to the left has a higher place value. So, the rightmost position represents the "ones" column, the next position represents the "tens" column, the next position represents "hundreds" and the next position represents the “thousand” etc. Therefore, the number 4321 represents 4 thousand 3 hundred and 2 tens and 1 one, whereas the number 1234 represents 1 thousand 2 hundred and 3 tens and 4 ones.  Any “base” system, base 2 (binary), octal (base 8) and hexadecimal (base 16) is an example of a Positional Number System.


Decimal Positional Notation


The decimal positional notation system work as described in Figure 1. Description for each row is given below the table. To use the positional system, match a given number to its positional value. The example in Figure 2 and figure 3 illustrates how positional notation is used with the decimal number 1234 and 4321.


positional number system


Radix


The identifies the number base.  The decimal notation system is based on 10, therefore the radix is 10.


Position in


This describes the position of the decimal number. The position in is starting from right to left. So 0 is the 1st position 1 is the 2nd position, 2 is the 3rd position, 3 is the 4th position and so on. These numbers also represent the exponential value that will be used to calculate the positional value of the 4th row.


Calculate


The 3rd row is used to calculates the positional value by taking the radix and raising it by the exponential value of its position. Important is that n0 is always = 1.


Position Value


The first row of the table shows the number base or radix. So the value listed, from left to right, represents units of thousands, hundreds, tens, and ones.


positional number system


positional number system


Binary Positional Notation


Similarly, the binary positional notation operates as shown in figure 4. Binary has also a Radix, Position, which is from right to left; Calculation and positional value as describe for decimal.The Radix for Binary is 2. The Figure 5 illustrates how a binary number 11101001 convert to the decimal number 233.


positional number system


positional number system

Sunday, 11 June 2017

IP Address Classes

In the previous lesson, we learn that It is not easy to identify the network and the host portion of any dotted decimal IP address for the reason that the IP addresses are not actually four numbers. They actually consist of 32 different numbers or 32 bits. We learn that an IP address classes used to define the network and host portions. IPv4 addresses were grouped into five separate classes that are Class A, B, C, D, and E. Chart illustrate all important figures of IP address classes. 



Class A 


This network is 8-bit network prefix. The most significant bit of class A network is set to 0, this most significant bit is also called high order bit(HOB). This class contains a 7-bit network number and a 24-bit host number. Figure illustrate Class A, address bit distribution.


IP Address Classes


If the first bit (most significant bit) of the first octet of an IP address is a binary 0, the address is a Class A address.  With that first bit being a 0, the lowest number is 00000000; decimal 0 and the highest number is 01111111, decimal 127. Any address that starts with a value between 0 -127  in the first octet is a Class A address. These two numbers, 0 and 127, are reserved and cannot be used as a network address. 0 and 127 will be explained later in this article.


Class A network can accommodate very large networks, so only the first octet is used to represent the network number. The other three octets or 24 bits are used to represent the host portion of the network. Each network of this class supports a maximum of 16,777,214 (2 24 -2) hosts per network. The two is subtracted because the lowest and highest addresses are reserved for the special purpose. The lowest address is 24, 0s in host portion and the highest address is 24, 1s in host portion.


Each network requires a network identification number that is used to refer to the entire range of hosts when building routing tables. The address that contains all 0s in the host portion is used as the network identification number. So address that has all 0s in host portion cannot be used with the individual host. 10.0.0.0 is a Class A Address. If we see the host portion which contains all 0s, so it is a network identification. Also, every network requires a broadcast address that can be used to send a message to each host on a network. This address contains all 1s on the host portion. For example, a broadcast address for network 10.0.0.0 would be 10.255.255.255.


As we learn that only the first octet is used as a network number, and it contains a value between 0 and 127; in which 0 and 127 are reserved, so 126 Class A networks exist. Each of the 126 Class A network has almost 17 million host addresses that make up 50 % of the entire IPv4 address space.


0.0.0.0 address is reserved for default route, the default route will be explained later. 127.0.0.1 address is reserved for the local loopback address, which is why Class A network range is from 1 – 126 and Class B addresses start from the address of 128.0.0.0.


A Class A network provides many possibilities for any organization or a company. Class A network provide a huge global network with those many hosts, the hosts in such a network could not function as members of the same logical group.


Network administrators require smaller logical groupings to control broadcasts, apply policies, and troubleshoot problems. This can be possible by applying subnet mask which allows subnetting. A subnetting breaks a large block of addresses into smaller groups called subnetworks. Subnetting avoids a waste of IP address and it's also helpful for better efficiency.Default subnet mask for class A IP address is 255.0.0.0. Private IP address range for class A is 10.0.0.0 to 10.255.255.255.


Class B 


Most significant bit or high order bit of class B addresses are starts with a binary 10 in the first 2 bits of the first octet. So, the lowest number of class B address is 10000000, decimal 128 and the highest number is 10111111, decimal 191. In the other words, class B IP address range in the first octet is from 128 - 191. Any address that starts with this range is class B IP address.


Class B network can accommodate medium size networks. So, the first two octets are used to represent the network, and the other two octets represent the host portion of the address. Class B has 16384 (214) Network addresses and 65534 (216-2) Host addresses. Remember that two, the lowest and highest values, which are reserved for special purposes. So, each Class B network can support up to 65,534 hosts. As you can see,  that it is much smaller than the networks of Class A. Just like Class A networks, Class B addresses are also subnetted to improve network efficiency. The figure illustrates 32 bits distribution of Class B network.


IP Address Classes


 As we can see in the above figure that the first 2 bits of a Class B address are always 10, So 14 bits are left in the network portion of the address, resulting in 214 or 16,384 Class B networks. The first octet of a Class B address has 64 possibilities that are from 128 to 191. The second octet has 256 possibilities, that are from 0 to 255. That give 16,384 networks. We can simply multiply 64 with 256 that will total possible network in class B.


Default subnet mask for class B IP addresses is 255.255.0.0. Class B addresses are also a private IP address range. Which is from 172.16.0.0 to 172.31.255.255


Class C


The high order bits for class C address are binary 110. So, the lowest number that starts with binary 110 is 11000000, which decimal is 192. The highest number that starts with binary 110 is 11011111, which decimal is 223. So IPv4 address the range of class C is from 192 to 223 in the first octet. Class C addresses were initially planned for a small network. The first three octets of a Class C address represent the network portion of IP address. The last octet represents the host number. The figure illustrates class C address bits distribution.


IP Address Classes


As we learn that the first 3 bits of a Class C address are always 110, So 21 bits are left in the network portion of the address, which results in 221 or 2,097,152 Class C networks. Each network containing a 254 (28 -2) hosts each. The two is reserved for network identification and broadcasting. Address with all-0s and all 1s in the host portion are subtracted, therefore only 254 hosts may be addressed on a Class C network.


Default subnet mask for class C IP addresses is 255.255.255.0. Class C addresses are also a private IP address range. Which is 192.168.0.0 to 192.168.255.255


Class D


A Class D address begins with binary 1110 in the first octet. So, the lowest number is binary 11100000 which decimal is 224 and the highest number is 11101111 which decimal is 239. So the range of class D addresses is from 224-239 in the first octet.Class D addresses are not used to address any individual host. Instead of individual host, each Class D address can be used to with a group of hosts called a host group. That group of host called multicast group.


When a single message is sent to several selected recipients that are called a multicast or multicasting. Class D addresses are also called multicast addresses which are used to send a message to a group of several. A multicast is different from a broadcast. Every device on a logical network must process a broadcast, whereas only devices configured to listen for a Class D address receive a multicast.


Class E


The first octet of class E IP address begins with 1111, the range of this class is starting with 11110000, decimal 240 and end with 11111111, decimal 255. So the range of class E is from 240 to 255 in the first octet. Class E addresses are reserved for experimental purposes and should not be used to address hosts or multicast groups.


 

Saturday, 3 June 2017

IPv4 Addressing

IPv4 is the fourth revision of the IP and a widely used protocol for data communication over different kinds of networks. IPv4 is defined and specified in IETF publication RCF 791. It is used in packet-switched link layer in the OSI model. A connectionless protocol provides the logical connection between network devices and providing identification for each device. There are many ways to configure IPv4 addresses on the network devices - including manual and automatic configurations - depending on the network type.IPv4 uses 32-bit addresses for Ethernet communication in five classes, which is A, B, C, D and E. Classes. 


Address Architecture of the Internet


While TCP/IP was introduced in the 1980s, at that time internet uses a two-level addressing scheme. At the time, this scheme offered sufficient scalability. The 32-bit-long IPv4 address identifies a network number and a host number, Figure- illustrate the 32-bit address in the 1980s.



Currently, the IPv4 address has also 32 bit and it also contains two portions, network portion, and host portion. Network portion identifies the network of the host and host portion show the number of the host in the network. Host portion is used to identify the device or the host. The router uses the network portion of the address to make routing decisions and to facilitate communication between hosts that belong to different networks.


Like routers and computer, humans can’t work with strings of 32,  1s and 0s. Therefore, 32-bit IP addresses are written using dotted-decimal notation. Each 32-bit address is divided into four groups of eight, called octets. An octet is ranging from 000000000 to 11111111. Each octet is converted to decimal and then separated by decimal points or dots. The range of each octet in decimal is from 0 to 255.  


A 32-bit IP address:


11101101010111011000001000010101



  • The four octets of the 32-bit address



  • 11101101 01011101 10000010 00010101



  • Decimal of each octet:


237 93 130 21



  • The address was written in dotted decimal notation:


237.93.130.21


Classes of IP Address


It is very difficult to identify the network portion and host portion of any dotted decimal IP address because that IP addresses are not actually four numbers. They actually consist of 32 different numbers or 32 bits.


In the early days of TCP/IP, a class of IP address was used to define the network and host portions. IPv4 addresses were grouped into five separate classes. This was done according to the value of the first few bits in the first octet of the address. These bits are called high order bits(HOB). Although the class system can still be applied to IP addresses, networks today often ignore the rules of class in favor of a classless IP scheme.


In a class system, IP addresses can be grouped into five different classes:



  • A

  • B

  • C

  • D

  • E


Where A, B, and C have a different bit length for addressing the network host. Class D addresses are reserved for multicasting, while Class E addresses are reserved for future use.


Each of the four octets of an IP address represents the network portion or the host portion, depending on the address class. The network and host portions of the respective Class A, B, C, and D addresses are shown in Figure 2



The first three classes A, B, and C are used to address actual hosts on IP networks. Class D addresses are used for multicasting. Class E addresses are reserved for experimentation in labs and medical equipment and are not shown in Figure 2.