Monday, November 9, 2020

IPv4(CIDR) and IPv6

The Internet Protocol (IP) is the principal communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet.

Binary and Hexadecimal number system

128    64    32    16    8    4    2    1

Bace2(Binary) Bace10(Decimal) Bace16(Hexadecimal)

Bace2(0000 0000) Bace10(00) Bace16(00)
Bace2(0000 0001) Bace10(01) Bace16(01)
Bace2(0000 0010) Bace10(02) Bace16(02)
Bace2(0000 0011) Bace10(03) Bace16(03)
Bace2(0000 0100) Bace10(04) Bace16(04)
Bace2(0000 0101) Bace10(05) Bace16(05)
Bace2(0000 0110) Bace10(06) Bace16(06)
Bace2(0000 0111) Bace10(07) Bace16(07)
Bace2(0000 1000) Bace10(08) Bace16(08)
Bace2(0000 1001) Bace10(09) Bace16(09)
Bace2(0000 1010) Bace10(10) Bace16(0A)
Bace2(0000 1011) Bace10(11) Bace16(0B)
Bace2(0000 1100) Bace10(12) Bace16(0C)
Bace2(0000 1101) Bace10(13) Bace16(0D)
Bace2(0000 1110) Bace10(14) Bace16(0E)
Bace2(0000 1111) Bace10(15) Bace16(0F)

[Internet Protocol version 4]

IPv4 uses 32-bit addresses for Ethernet communication in five classes: A, B, C, D and E. Classes A, B and C have a different bit length for addressing the network host. Class D addresses are reserved for military purposes, while class E addresses are reserved for future use. IPv4 uses 32-bit (4 byte) addressing, which gives 2^32 addresses. IPv4 addresses are written in the dot-decimal notation, which comprises of four octets of the address expressed individually in decimal and separated by periods.
Example 10.0.0.1, 192.168.0.1, 150.50.0.1, 255.255.255.255, 1.0.1.1 etc. 

Class A- 1.0.0.0 to 126.255.255.255
Class B- 128.0.0.0 to 191.255.255.255
Class C- 192.0.0.0 to 223.255.255.255
Class D- 224.0.0.0 to 239.255.255.255
Class E- 240.0.0.0 to 255.255.255.255
Loopback Address- 127.0.0.0 to 127.255.255.255
APIPA Address- 169.254.0.0 to 169.254.255.255
Routed Address- 10.0.0.0, 192.0.0.0, 172.0.0.0

CIDR Table
CIDR       Subnet Mask
/0              0.0.0.0
/1              128.0.0.0
/2              192.0.0.0
/3              224.0.0.0
/4              240.0.0.0
/5              248.0.0.0
/6              252.0.0.0
/7              254.0.0.0
/8              255.0.0.0

/9              255.128.0.0
/10            255.192.0.0
/11            255.224.0.0
/12            255.240.0.0
/13            255.248.0.0
/14            255.252.0.0
/15            255.254.0.0
/16            255.255.0.0

/17            255.255.128.0
/18            255.255.192.0
/19            255.255.224.0
/20            255.255.240.0
/21            255.255.248.0
/22            255.255.252.0
/23            255.255.254.0
/24            255.255.255.0

/25            255.255.255.128
/26            255.255.255.192
/27            255.255.255.224
/28            255.255.255.240
/29            255.255.255.248
/30            255.255.255.252
/31            255.255.255.254
/32            255.255.255.255

IPv4 CIDR(Class-less Inter Domain Routing)

Classless Inter-Domain Routing is a method for allocating IP addresses and for IP routing. The Internet Engineering Task Force introduced CIDR in 1993 to replace the previous classful network addressing architecture on the Internet.
192.0.0.1/24
IP Address/CIDR Value

[Prefix Length = CIDR Value - Default NID Bit]


For Class A

Default Subnet = 255.0.0.0
11111111.00000000.00000000.00000000
NNNNNNNN.HHHHHHHH.HHHHHHHH.HHHHHHHH
NID = 8 , HID = 24
[Prefix Length for class A = CIDR Value - 8]

For Class B

Default Subnet 255.255.0.0
11111111.11111111.00000000.00000000
NNNNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHHH
NID = 16 , HID = 16
[Prefix Length for class B = CIDR Value - 16]

For Class C

Default Subnet 255.255.255.0
11111111.11111111.11111111.00000000
NNNNNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH
NID = 24 , HID = 8
[Prefix Length for class C = CIDR Value - 24]

Question. 11.0.0.0/20...
Answer. 11.0.0.0 is class 'A' IP.
Default Subnet mask = 255.0.0.0
[Prefix length = CIDR Value - 8]
Prefix length = 20 - 8
Prefix length = 12

Default Subnet mask
255.0.0.0
11111111.00000000.00000000.00000000
New subnet mask
11111111.11111111.11110000.00000000
   NID     Prefix length
New Subnet mask is 255.255.240.0

According to Valid IP Table subnet for /20 is 255.255.240.0. 


[Number of Network = 2 power n]

where n is Prefix Length(4,096)

[Number of Host = (2 power n) -2]

where n is HID in New Subnet mask and -2 for 1 for NIP and other BIP(4,094)

{Block Size = Magic No - New Subnet Mask}

256 - 240 = 16

Valid IP Table

11.0.0.0        11.0.16.0        11.0.32.0        Network IP
11.0.0.1        11.0.16.1        11.0.32.1        Host IP
11.0.0.2        11.0.16.2        11.0.32.2        Host IP
11.0.0.3        11.0.16.3        11.0.32.3        Host IP
11.0.0.4        11.0.16.4        11.0.32.4        Host IP
11.0.0.5        11.0.16.5        11.0.32.5        Host IP
----------------------------------------------------------------
----------------------------------------------------------------
11.0.15.251   11.0.31.251    11.0.47.251    Host IP
11.0.15.252   11.0.31.252    11.0.47.252    Host IP
11.0.15.253   11.0.31.253    11.0.47.253    Host IP
11.0.15.254   11.0.31.254    11.0.47.254    Host IP
11.0.15.255   11.0.31.255    11.0.47.255    Broadcast IP

[Internet Protocol version 6]

IP v6 was developed by Internet Engineering Task Force (IETF) to deal with the problem of IP v4 exhaustion. IP v6 is 128-bits address having an address space of 2^128, which is way bigger than IPv4. In IPv6 we use Colon-Hexa representation. There are 8 groups and each group represents 2 Bytes.
Example 
1) 2001:0db8:85a3:0000:0000:8a2e:0370:7334
2) 2a03:2880:f11c:8183:face:b00c::25de
3) ::1

Address Type

Unicast (Support IPv4 & IPv6)

Unicast is the communication that there is only one receiver. This is one-to-one communication.


Multicast (Support IPv4 & IPv6)

Multicast is the communication that there is one more receiver. Only the members of the multicast group receive the multicast traffic.


Broadcast (Only Support IPv4)

Broadcast is also the communication that there is one more receiver but this time, all the receivers receive broadcast traffic.


Anycast (Only Support IPv6)

Anycast is the communication that is developed with IPv6. With anycast, the traffic is received by the nearest receiver in a group of the receivers that has the same IP.



1 comment: