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.