Thursday 28 August 2014

Basics of IP and Sub-netting Short-cut.

                                                                                             

IPv4 - Overview



MAC-Address - The physical address that is imprinted on the                           device, where a device can be an NIC card,                             Ethernet interface, Serial interface or any                             physical device (which can be touched and felt).

IP-Address - The logical address, assigned to particular host,                      for communication and sharing of resources. 
             ( It is not a fixed address for the host, i can                        randomly be assigned and  changed at any point                          of time according to our requirement.)



 1) Common question when we have a MAC address why do                       we need IP address ?
 A) Mac-address is the unique identification of the device,                 where as ip-address is used for the communication. 

                

IPv4 - Addressing


Each device that connects to the Internet needs a unique identifying number with which it communicate, called an IP address. IP stands for Internet Protocol.
There are two versions of IP that currently co-exist in the global Internet, IP version 4 (IPv4) and IP version 6 (IPv6). They will both be used for the foreseeable future, during the transition from IPv4 to IPv6. However, these two protocols cannot interact with each other directly. Systems that can use both protocols are called "dual stack", and provide facilities for exchanging data between IPv4 and IPv6.
Internet Protocol Addresses are made up of binary values and drive the routing of all data over the Internet. IPv4 addresses are 32 bits long, and IPv6 addresses 128 bits long. Since it is difficult for people to remember long sequences of numbers, the Domain Name System (DNS) was designed to provide a distributed directory of alphabetical names that correspond to these numbers.

The encapsulated data is referred to as IP Payload. IP header contains all the necessary information to deliver the packet at the other end.

IP Header

IP header includes many relevant information including Version Number, which, in this context, is 4. Other details are as follows:
  • Version: Version no. of Internet Protocol used (e.g. IPv4)
  • IHL: Internet Header Length, Length of entire IP header
  • DSCP: Differentiated Services Code Point, This is Type of Service.
  • ECN: Explicit Congestion Notification, carries information about the congestion seen in the route.
  • Total Length: Length of entire IP Packet (including IP header and IP Payload)
  • Identification: If IP packet is fragmented during the transmission, all the fragments contain same identification no. to identify original IP packet they belong to.
  • Flags: As required by the network resources, if IP Packet is too large to handle these ‘flags’ tell that if they can be fragmented or not. In this 3-bit flag, the MSB is always set to ‘0’.
  • Fragment Offset: This offset tells the exact position of the fragment in the original IP Packet.
  • Time to Live: To avoid looping in the network, every packet is sent with some TTL value set, which tells the network how many routers (hops) this packet can cross. At each hop, its value is decremented by one and when the value reaches zero, the packet is discarded.
  • Protocol: Tells the Network layer at the destination host, to which Protocol this packet belongs to, i.e. the next level Protocol. For example protocol number of ICMP is 1, TCP is 6 and UDP is 17.
  • Header Checksum: This field is used to keep checksum value of entire header which is then used to check if the packet is received error-free.
  • Source Address: 32-bit address of the Sender (or source) of the packet.
  • Destination Address: 32-bit address of the Receiver (or destination) of the packet.
  • Options: This is optional field, which is used if the value of IHL is greater than 5. These option may contain values for options such as Security, Record Route, Time Stamp etc.



IPv4 supports three different type of addressing modes:


Unicast Addressing Mode:

In this mode, data is sent only to one destined host. The Destination Address field contains 32- bit IP address of the destination host. Here client sends data to the targeted server:
Unicast Addressing


Broadcast Addressing Mode:

In this mode the packet is addressed to all hosts in a network segment. The Destination Address field contains special broadcast address i.e. 255.255.255.255. When a host sees this packet on the network, it is bound to process it. Here client sends packet, which is entertained by all the Servers:
Broadcast Addressing


Multicast Addressing Mode:

This mode is a mix of previous two modes, i.e. the packet sent is neither destined to a single host nor all the host on the segment. In this packet, the Destination Address contains special address which starts with 224.x.x.x and can be entertained by more than one host.
Multicast Addressing
Here a server sends packets which is entertained by more than one Servers. Every network has one IP address reserved for network number which represents the network and one IP address reserved for Broadcast Address, which represents all the host in that network.

 Subnet Mask


Identification of the Network Bits and Host bits.



so the default subnet mask values for the classes would be :                                                                 

Class A --        255.0.0.0                N.H.H.H
Class B --        255.255.0.0              N.N.H.H
Class C --        255.255.255.0            N.N.N.H
Class D --        
Class E --        Class D & E are called as FLAT NETWORKS, in                             which every ip address is an individual                                 address




The subnet mask is always an AND operation as represented in the diagram above.


Important  Note : 1) Two or more Ip-address are said to be in                                same address if both the Ip-addresses                                  NETWORK bits are common.
                     
                  2) Slash notation always represents the number                            of NETWORK bits. 


                                     

IPv4 - Subnetting


All the subnet mask values --



If we observer carefully the same values repeats again again and again in any subnet mask values but only differs only in case of position.


                       Values             A       B       C
and the values are       .0              /8      /16     /24
                         .128            /9      /17     /25
                         .192            /10     /18     /26
                         .224            /11     /19     /27                                     .240            /12     /20     /28
                         .248            /13     /21     /29
                         .252            /14     /22     /30
                         .254            /15     /23


These values.  Appear in the 4th Octet in case of classC
               Appear in the 3th Octet in case of classB  
               Appear in the 2th Octet in case of classA

Once you remember these values the entire sub-netting is done.

For example class C



To get no.of valid host per network :- 

 From the same values of  0,128,192,224,240,248,252.......
-->simply subtract to 254 .( As we all know 1st is network-id and                              the last is broadcast-id )


For example class B
    
Almost same concept applies here as well to know how many host per subnet.  

((256 - Values) * 256) - 2
                
i.e /23 value would be 254
         
                       ((256-254)*256) - 2 = 510


Note: In real time we can always approximate.(Multiply with 250)

The following table represents the values of class B





And the same rule applies for the class A                                                                                                                                              





Thank You Guys for the support.