Subnetting

  • It is needed since we have limited IP addresses in IPv4 to allocate
  • Subnetting means network within a network
  • Ref:
  • Subnetting can be done
    • according to host requirements (no. of computers needed)
    • according to network requirements (no. of networks needed)
  • Default subnet can be calculated as number of bits in host part:
    • Class A: 8 (1 octet)
    • Class B: 16 (2 octet)
    • Class C: 24 (3 octet)
  • We specify subnets by separating IP address with /
    • Example: 130.10.0.0/16
    • Here 16 is subnet also known as CIDR (Classless Inter-domain routing)
  • The idea is we can extend the network ID bits to include more bits, and consequently reduce the host bits and reduce the wastage of IP addresses
  • Let’s take example for network ID in class C: 197.10.10.0/26
    • Since it is class C network, we have first 3 octets as network ID octets
    • In other words I have 3 * 8 = 24 network ID bits by default
    • But the above representation says 26 as subnet, which means 2 more bits are taken out of host ID
    • Hence total number of possible bits that can be used for hosts = 8 - 2 = 6 bits
    • Total usable IPs = 2^6 - 2 {Broadcast ID IP and Network ID IP} = 64 - 2 = 62 hosts
    • Subnet Mask = 11111111 11111111 11111111 11000000 = 255.255.255.192

Why class concept is not used in modern times???

Subnet Mask

  • It is a bit-mask which is used to identify which portion of IP address is network ID
  • So if the mask is 255.255.255.192, converting to binary gives:
  • 11111111 11111111 11111111 11000000
  • The 1 bits are part of network ID
  • For a particular subnet mask, we can evaluate how many networks are possible and how many hosts are possible
  • Example:
    • 11111111 11111111 11111111 11000000 = 255.255.255.192
      • possible subnets = permutation of fir 2 bits of last octet = 2^2 = 4
      • possible usable hosts = permutation of host bits = 2^6 - 2 = 62 hosts
    • 11111111 11111111 11111111 11100000 = 255.255.255.224
      • possible subnets = 2^3 = 8
      • possible hosts = 2^5 - 2 = 32 - 2 = 30

Network ID and Router

  • A Router separates networks
  • Hence each network should have different Network ID
  • If you want to connect to the same network then Switch is used