Saturday, 16 April 2016

Routing and Switching Thread..

Routing and Switching Thread..

In my last TCP/IP thread we talked about the TCP/IP stack which describes common ground/platform of network data communication. So as we discussed network layer corresponds to IP addressing scheme provides a virtual numeric area consist of IP address range calculated by subnet.

Before understanding what is Routing and Switching we need to understand IP Addressing scheme.

IP Addressing Concepts..

IP addressing is essential part to perform IP protocol operations, one of them is media independent architecture. IP addressing assigns addresses to individual network interfaces of a device (link-based approach) instead of using a single address for the whole device (host-based approach) This provides us routing capability. The various interfaces of a device are connected to network links that are designated as sub-networks (or subnets) and are assigned subnet addresses.


An interface's IP address is assigned from the subnet address space of the connecting link. The advantage of this link-based addressing approach is that it allows routers to summarize routing information by keeping track of only IP subnets in the routing tables instead of every host on the network. This is advantageous especially for broadcast links such as Ethernet that might have many devices connected at the same time. The Address Resolution Protocol (ARP) is used in IP networking for resolving the IP addresses of directly connected hosts to the corresponding data-link addresses.


Lets take an example here to understand link-based addressing approach.

                                                         

    network link group--10.0.0.0/24--------1(Router)2--------20.0.0.0/24---network link group

This Router is connected to 2 network links, one link resides under sub-network 10.0.0.0/24 and another one in 20.0.0.0/24. The devices which are connected to these network links gets the IP addresses from the range of sub-networks of either 10.0.0.0 or 20.0.0.0 and how many IP address we can actually assign depends on the subnet-mask of that sub-network.

Currently, two types of IP addresses exist: IP Version 4 addresses (IPv4) and IP Version 6 addresses
(IPv6). IPv4 addressing, which was in place before IPv6 was adopted, uses 32 bits to represent each
IP address. This 32-bit addressing scheme provides up to 232 (4,294,967,295) unique host
addresses, mathematically speaking. With the ever increasing size of the global Internet, the 32-bit
IPv4 addressing scheme has turned out to be insufficient for the foreseeable future, prompting the
introduction of the 128-bit IPv6 addressing scheme.

1. IPv4 address classes

As explained in the previous section, the 32-bit IPv4 addressing scheme allows a large number of host addresses in it. However, the link-based addressing scheme adopted by IP requires

network links to be associated with groups of addresses from which the connected hosts are assigned specific addresses. These address groups, described also as address prefixes/network number, are referred to in classical IP terminology as IP network numbers.

Five address classes—A, B, C, D, and E—were defined to enable efficient allocation of IP addresses in one network links group.


IP Address Classes and Representation


Address   Bit pattren of      First Byte               Dotted Decimal host allocation range
Class        first byte              Decimal range

A              0xxxxxxx             1 to 127                   1.0.0.1 to 126.255.255.254


B              10xxxxxx             128 to 191               128.0.0.1 to 191.255.255.254


C             110xxxxx              192 to 223               192.0.0.1 to 223.255.255.254


D             1110xxxx              224 to 239               224.0.0.1 to 239.255.255.254


E             11110xxx              240 to 255               240.0.0.1 to 255.255.255.255


Specific Bit pattern of first byte defines decimal range and than we can defines dotted decimal range but always remember that first IP address is always network prefix and last one is broadcast address.

out of five classes there are only class A, B and C are used for unicast IP addressing and D is for multicast IP address group. E is for testing purpose.

classfull network scheme.

Class A— 8-bit network ID, 24-bit host ID

Class B— 16-bit network ID, 16-bit host ID

Class C— 24-bit network ID, 8-bit host ID

As I said earlier IP address resides under a group called network and to define that group network id is required.

Network part defines the start and end of the boundary and host part is just a number in that boundary. IP addresses use masks to separate host bits from the network number bits.  In classfull network scheme the network bits are predefined and we can not change it. For example class A network scheme first 8 bits are reserved for network id that means from 1 to 126 that number could be anything but you can not change it and rest of the 24 bits are host bits that means there are 232 unique host same goes with other network classes as mentioned above.

How to calculate subnet-mask?

The network bits are actually represent subnet-mask. lets take an example of class C where 24 bits from left to right out of 32 are reserved, and you can select any number in the range from 192 to 223 representing your network bits in classful scheme. To calculate subnet mask we need to understand in dotted decimal architecture of IP addressing scheme, we need to understand dotted decimal scheme.

Dotted decimal architecture divide complete 32 bits into 4 octets separated by dots example 10.10.10.10, Every octet contains 8 bits and 2(8) is 255 starting from 0, So every octet can assign a number from 1 to 255, subnet 0 we do not use these days. subnet mask is calculated on how many bits out of 32 are assigned to network id so lets say for IP address 10.10.10.10 

8 bits are assigned to network id portion that means first octet is reserved for network portion which left 24 bits to select your host portion that means your subnet mask would be 255.0.0.0 because first octet is fully utilized which is represented by 255 (2(8) remember every octet 8 bits) but host octet is free to use. So as you see here how the subnet-mask helps  us to find the network portion and host portion of any IP address. 

example 

        0             8              16            24             32
BIT 00000000.00000000.00000000.00000000
        ---A------                                   
        -----------B-----------
        -------------------------C----------

These bits are either 0 or 1,  0 means not utilised and 1 means utilised.

example..
100.100.100.100 class A mask is 255.0.0.0
150.100.100.100 class B mask is 255.255.0.0
200.100.100.100 class c mask is 255.255.255.0 

Classless IP addressing scheme.


In classless addressing, any IP network number is interpreted as a prefix of any certain length.

There is no boundation as such like classful that only from 1 to 126 number prefix can have  /8 bit subnet mask you can literally use any number out of 1 to 255 for any length out of classful subnet range. example 192.168.0.1/8 or 10.0.0.1/24 this type of scheme is called CIDR and helpful in assigning IP address more efficiently.

With classless inter-domain routing now we can assign any certain length to any network prefix number, but still there are only 3 class of subnet /8, /16 and /24, in order to further divide them into multiple sub-networks we need different approach called VLSM (variable length subnet mask) and to achieve this approach we need to understand sub-netting. 


Sub-netting


IP sub-netting introduces another level of hierarchy into the structure of IP address classes by moving  some of the host bits into the network bis which represent network ID. The extended network ID is referred to as a sub-network number or simply as an IP subnet.


example..


ip address bits of class B 


11111111.11111111.00000000.00000000

------------B-------- 
To further make subnets of this network we need to turn the host bits to network bits.


11111111.11111111.11111111.11111100

---------Subnetted class-------------

so if the ip address prefix is 130.0.0.0/30 since 30 bits are network bits and only 2 bits are available to avail the space for host that means only four IP address fall in this subnet range and out of 4 only 2 can assign to host machines as IP addresses. 

When an IP address is subnetted, the address mask is adjusted to reflect the new demarcation
between the network and host bits.  I have shown the new mask which is derived from class B after subnetting is 255.255.255.252

How this mask is calculated.


11111111.11111111.11111111.11111100

A string of ones in the mask represent the network bits, and the zeros represent the host bits.
1st octet all bits are 1 that means dotted decimal number is 255 and same for the 2nd and 3rd octet but in fourth octet only 6 bits are network bits so to calculate the dotted decimal number try the below formula.

1     1    1   1   1   1  1  1

128 64 32 16  8  4   2  1  add all those = 255 

1  1  1  1  1  1  0  0


128+64+32+16+8+4  = 252 = 30 bits ON


How to calculate the range of IP addresses after subnetting.





How network device communication happens in single IP network.


As we know for Network layer to work we need IP Addressing scheme and for Network connectivity that means we need to follow the rules of  TCP/IP layer headers. 

For example:   (Computer1---ethernet---Computer2)   network 10.1.1.0/24 
                             10.1.1.1                             10.1.1.2
Computer 1 is connected to Computer 2 through Ethernet cable which states we are trying to maintain network connectivity over Ethernet cable ie to reach from 1 to  2 we need to know the physical mac address, IP address and application port numbers of both computer 1 and 2.

How to connect between same network.

When a user on 1 wants to download some data from 2  the application ftp is used on both computers. 
user opens up ftp application on 1 and enter an IP address of 2 in the address bar now 1 knows  the destination ip address of 2 for network layer header information, and for transport header information a well know ftp port number 21 is already hard-coded in the program of ftp application and finally the network interface header to complete we need to run the ARP process on Ethernet for corresponding IP address of 2. 

With all the information provided 1 calculates if the destination IP address falls in 1's network or not if yes then it runs the ARP process to know the destination mac address for 2's NIC. 
and after filling all the information it converts all the data into bit pattern and then physical layer converts into electrical signals and send it over to ether net wire, when 2 receives it confirms all the destination header field in all the layer headers starting from network interface with its own network information since it is expecting to receive its own information in headers from 1. 2 replies the same way by gathering the 1's information in the incoming  headers.

Network layer header information : source IP address (manually configured or learned via DHCP) and destination IP address (manually entered or learned via incoming network layer header)

Network interface header : source mac (hard-coded on NIC) and destination mac (learned via ARP)

Transport header : source port (random no. generated via computer) and destination port no. (well known assigned via IANA)

How network device communication happens in different IP network.

A network host can only communicate to the different network resident host when it is connected to at-least one network device which is equipped with the routing and switching capabilities and connect to both the network prefixes at the same time. The device is called Router.

what is Routing and Switching capability.

Routing means to learn the network/sub-network information on an interface and store it in memory called routing table and Switching means to switch data from ingress to egress interface by considering information learnt in routing table or mac-address-table. 





No comments:

Post a Comment