Salta al contenuto
Note per Studenti Subnetting, VLSM and Supernetting Report

Subnetting, VLSM and Supernetting

In questa pagina 3
In questa pagina 3

This note uses prefix, mask, network and broadcast addresses as defined in Network Layer and IPv4 AddressingThe network layer delivers datagrams host to host through routers (encapsulation, routing, forwarding); an IPv4 address is 32 bits split into a network prefix and a host suffix, and modern classless addressing (CIDR) gives a block of 2^(32-n) addresses from a.b.c.d/n, with network and broadcast addresses computed through the netmask.Network Layer and IPv4 Addressing →. In classless addressing the NetID/HostID boundary can move in either direction: moving it right gives subnetting, moving it left gives supernetting.

Subnetting

Definition. An organisation (or ISP) given a block can divide it into subnets, and each subnet can be divided again. This adds a level of hierarchy: NetID, SubnetID, HostID. The subnet mask has more 1 bits than the original mask (bits borrowed from the HostID). Each subnet is a full CIDR block with its own network and broadcast addresses.

Formula. From a network with prefix nn, borrowing ss bits for the SubnetID gives new prefix n′=n+sn'=n+s, 2s2^s subnets, each with 232−n′2^{32-n'} addresses, i.e. 232−n′−22^{32-n'}-2 usable hosts.

Example. 147.162.0.0/16147.162.0.0/16 with mask 255.255.255.0255.255.255.0 (n′=24n'=24): s=8s=8, so up to 28=2562^8=256 subnets of 28−2=2542^8-2=254 hosts, instead of one network with 216−2=65 5342^{16}-2=65\,534 hosts.

Worked examples.

  1. 100.0.0.25/28100.0.0.25/28. First byte 100: class A, n=8n=8. The mask says 28, so only 32−28=432-28=4 bits are real host bits (24−2=142^4-2=14 hosts) and the SubnetID has 28−8=2028-8=20 bits (220=1 048 5762^{20}=1\,048\,576 subnets). 25=00011001→00010000=1625=00011001\to00010000=16: subnet 100.0.0.16/28100.0.0.16/28, broadcast 100.0.0.31100.0.0.31.
  2. Subnets of at least 500 hosts from 132.78.0.0132.78.0.0 (class B). 500+2=502≤29=512500+2=502\le2^9=512, so 9 host bits; SubnetID 16−9=716-9=7 bits (up to 128 subnets); mask has 32−9=2332-9=23 ones: 255.255.254.0255.255.254.0; 29−2=5102^9-2=510 hosts per subnet.
  3. At least 1000 subnets from 128.234.0.0128.234.0.0 (class B). 29=512<1000≤2102^9=512<1000\le2^{10}, so s=10s=10 bits; remaining host bits 16−10=616-10=6 (62 hosts); mask has 16+10=2616+10=26 ones: 255.255.255.192255.255.255.192. More subnets means fewer hosts per subnet, since the total is fixed.

Design rules (variable-length masks, VLSM)

  1. The number of addresses MM of each subnet is a power of 2: for HH hosts take the smallest power of 2 with M≥H+2M\ge H+2 (network and broadcast are lost).
  2. Prefix length n=32−log⁡2Mn=32-\log_2M.
  3. The start address of a subnet must be divisible by MM. To guarantee this, assign subnets from the largest to the smallest: each size divides all the previous ones, so the running sum of sizes is automatically a multiple of the next size. Starting from small subnets wastes addresses.

Formula. M=2⌈log⁡2(H+2)⌉M=2^{\lceil\log_2(H+2)\rceil},  n=32−log⁡2M\ n=32-\log_2M,  broadcast=network+M−1\ \text{broadcast}=\text{network}+M-1.

100 hosts: 102→M=128102\to M=128, n=25n=25, broadcast == network +127+127. Read the text: "10 addresses" means M=16M=16; "60 hosts" needs M≥62M\ge62 so 64; 63 hosts need 128 (63+2=65>6463+2=65>64).

Full design: 14.24.74.0/2414.24.74.0/24 into subnets for 120, 60 and 10 hosts (the block has 256 addresses). Start from the largest:

  • 120 hosts: 122→M=128122\to M=128, n=25n=25: 14.24.74.0/2514.24.74.0/25, broadcast 14.24.74.12714.24.74.127.
  • 60 hosts: 62→M=6462\to M=64, n=26n=26: 14.24.74.128/2614.24.74.128/26 (128128 is a multiple of 64), broadcast .191.191.
  • 10 hosts: 12→M=1612\to M=16, n=28n=28: 14.24.74.192/2814.24.74.192/28 (192192 is a multiple of 16), broadcast .207.207.
  • Free: .208.208 to .255.255 (48 addresses).
prefix mask addresses NN hosts N−2N-2
/20 255.255.240.0 4096 4094
/21 255.255.248.0 2048 2046
/22 255.255.252.0 1024 1022
/23 255.255.254.0 512 510
/24 255.255.255.0 256 254
/25 255.255.255.128 128 126
/26 255.255.255.192 64 62
/27 255.255.255.224 32 30
/28 255.255.255.240 16 14
/29 255.255.255.248 8 6
/30 255.255.255.252 4 2

A /30 is the typical choice for a point-to-point link between two routers (2 usable hosts, no waste); a /31 would have 0 hosts.

Supernetting

Definition. The dual of subnetting: several small contiguous blocks are merged into one larger block by shortening the prefix. In routing tables this is route aggregation.

Property. 2j2^j blocks of prefix nn can be replaced by one block of prefix n−jn-j if and only if they are (a) contiguous, (b) exactly 2j2^j in number, (c) the first address is a multiple of the aggregate size 232−(n−j)2^{32-(n-j)}.

Example. 193.23.136.0/24193.23.136.0/24, .137.0/24.137.0/24, .138.0/24.138.0/24, .139.0/24.139.0/24 are contiguous, j=2j=2, and 136136 is a multiple of 4: they merge into 193.23.136.0/22193.23.136.0/22 (mask 255.255.252.0255.255.252.0, 210=10242^{10}=1024 addresses). In binary the third bytes are 100010xx100010xx, so the two low bits become host bits.

Counterexample. 193.23.137.0/24193.23.137.0/24 and 193.23.138.0/24193.23.138.0/24 are contiguous but cannot become a /23: 137137 is not a multiple of 2 (the /23 blocks are 136136-137137 and 138138-139139).

Example. 195.13.17.128/26195.13.17.128/26 and 195.13.17.192/26195.13.17.192/26 (j=1j=1, 128128 multiple of 128) merge into 195.13.17.128/25195.13.17.128/25, from .128.128 to .255.255 (126 hosts).

With aggregation an ISP announces one line (e.g. 190.100.0.0/16190.100.0.0/16) instead of one per customer; routing still works thanks to the longest prefix match (Forwarding and Routing TablesForwarding moves each packet one hop at a time toward its destination; it is direct when the destination is on a local network (ARP gives its MAC) and indirect otherwise (the packet goes to the next hop or default gateway given by the routing table). With netmasks, delivery is direct on interface x if the destination AND the mask equals the interface address AND the mask; otherwise the table is scanned from the longest mask (longest prefix match) and the default route 0.0.0.0/0 always matches; route aggregation shortens tables.Forwarding and Routing Tables →).

Versione ripasso

Mask, network, broadcast: Network Layer and IPv4 AddressingThe network layer delivers datagrams host to host through routers (encapsulation, routing, forwarding); an IPv4 address is 32 bits split into a network prefix and a host suffix, and modern classless addressing (CIDR) gives a block of 2^(32-n) addresses from a.b.c.d/n, with network and broadcast addresses computed through the netmask.Network Layer and IPv4 Addressing →.

Subnetting

  • Block divided into subnets: NetID, SubnetID, HostID; mask gets more 1 bits.

Borrow ss bits: n′=n+sn'=n+s, 2s2^s subnets of 232−n′2^{32-n'} addresses (232−n′−22^{32-n'}-2 hosts).

  • 147.162.0.0/16147.162.0.0/16 with /24/24: s=8s=8, 256 subnets of 254 hosts.
  • 100.0.0.25/28100.0.0.25/28: real host bits 4 (14 hosts), SubnetID 20 bits; subnet 100.0.0.16/28100.0.0.16/28, broadcast .31.31.
  • 500 hosts from 132.78.0.0132.78.0.0: 512 addresses, 9 host bits, /23/23 (255.255.254.0255.255.254.0), 510 hosts, 128 subnets.
  • 1000 subnets from 128.234.0.0128.234.0.0: s=10s=10, /26/26 (255.255.255.192255.255.255.192), 62 hosts.

VLSM rules

  1. M=2kM=2^k smallest with M≥H+2M\ge H+2. 2. n=32−log⁡2Mn=32-\log_2M. 3. Start address divisible by MM: assign largest first.

M=2⌈log⁡2(H+2)⌉M=2^{\lceil\log_2(H+2)\rceil}, n=32−log⁡2Mn=32-\log_2M, broadcast == network +M−1+M-1.

  • 14.24.74.0/2414.24.74.0/24 for 120, 60, 10 hosts: 14.24.74.0/2514.24.74.0/25 (bc .127.127), 14.24.74.128/2614.24.74.128/26 (bc .191.191), 14.24.74.192/2814.24.74.192/28 (bc .207.207); free .208.208-.255.255.
  • Host versus address wording: 10 addresses →16\to16; 60 hosts →64\to64; 63 hosts →128\to128.
  • /30 for point-to-point links; /31 has 0 hosts. Sizes: /24 254, /25 126, /26 62, /27 30, /28 14, /29 6, /30 2 hosts.

Supernetting

  • Merge contiguous blocks, shorten prefix (route aggregation).

2j2^j blocks of prefix nn merge into prefix n−jn-j iff contiguous, exactly 2j2^j, first address multiple of the aggregate size.

  • 193.23.136.0/24193.23.136.0/24 to .139.0/24.139.0/24 gives 193.23.136.0/22193.23.136.0/22 (j=2j=2, 136 multiple of 4). 193.23.137.0/24193.23.137.0/24 plus .138.0/24.138.0/24 do not make a /23. 195.13.17.128/26195.13.17.128/26 plus .192/26.192/26 give /25/25.
  • Typical errors: mixing hosts and addresses; forgetting the 2 reserved addresses; assigning small subnets first; aggregating unaligned blocks.

Teoria collegata