IP Addressing and Subnetting Study Notes

Prerequisites and Fundamental Concepts

  • Binary-to-Decimal Conversion Principles:

    • Computer network addressing relies heavily on converting between binary (base-2) and decimal (base-10) representations.

    • In an 8-bit binary octet, the positional bit values corresponding to powers of 22 from right to left are:

    • Bit 0 (202^0): 11

    • Bit 1 (212^1): 22

    • Bit 2 (222^2): 44

    • Bit 3 (232^3): 88

    • Bit 4 (242^4): 1616

    • Bit 5 (252^5): 3232

    • Bit 6 (262^6): 6464

    • Bit 7 (272^7): 128128

    • Conversion Example:

    • Binary representation: 101021010_2

    • Calculation: (1×23)+(0×22)+(1×21)+(0×20)=8+0+2+0=1010(1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (0 \times 2^0) = 8 + 0 + 2 + 0 = 10_{10}

    • Decimal output: 101010_{10}


Binary to Decimal Conversion Chart

Internet Protocol (IP) Fundamentals

  • Definition:

    • The Internet Protocol (IP) is the primary network-layer method or protocol by which data is routed and sent from one computer host to another across the Internet.

  • Host Identification:

    • Every computer connected to the Internet is designated as a host.

    • Each host possesses at least one unique IP address that globally distinguishes it from all other interconnected machines.

  • Packetization:

    • Data transmitted across the network (such as web pages or e-mail messages) is partitioned into discrete segments called packets or datagrams.

    • Every packet carries header information containing both the source host IP address and the destination host IP address.

  • Layered Communication and Protocol Data Units (PDUs):

    • Network communications operate via a layered architecture.

    • As data moves down the protocol stack on the sending host, each layer encapsulates upper-layer payloads by prepending specific header control information.

    • As data moves up the protocol stack on the receiving host, each layer strips off its corresponding header and processes the payload according to header instructions.

    • Encapsulation Stack Order (Top to Bottom):

    • Upper Layer Message: Contains Upper Layer Headers and Application Data.

    • Transport Layer Message: Encapsulates application data with a TCP or UDP Header.

    • IP Datagram (Network Layer): Encapsulates TCP/UDP messages with an IP Header.

    • Layer 2 Frame (Data Link Layer): Encapsulates the IP datagram with a Layer 2 Header and a Layer 2 Frame Footer.

    • Layer 1 (Physical Layer): Transmits the frame as a continuous physical bitstream (11s and 00s).


IPv4 Datagram Structure and Header Fields

  • Structure Overview:

    • The IPv4 datagram consists of a structured control header followed by the variable-length payload/data section.

    • Header fields are aligned across 32-bit (4 bytes4\text{ bytes}) words.


  • Detailed Field Specifications:

    • Version (4 bits4\text{ bits}): Indicates the IP protocol version being utilized (e.g., IPv4 vs. IPv6).

    • Internet Header Length / IHL (4 bits4\text{ bits}): Specifies the total length of the IP header expressed as a multiple of 32-bit (4 bytes4\text{ bytes}) words. The minimum length for a standard header without options is 55 words (20 bytes20\text{ bytes}).

    • Type of Service / ToS (8 bits8\text{ bits}): Defines service quality specifications to facilitate packet prioritization and traffic management.

    • Total Length (16 bits16\text{ bits}): Specifies the complete size of the datagram, including both header and payload, measured in bytes.

    • Identification (16 bits16\text{ bits}): A unique identifier assigned to a datagram to enable the target host to reassemble fragmented pieces into the original structure.

    • Flags (3 bits3\text{ bits}): Control bits used to manage datagram fragmentation:

    • Reserved Bit: Must remain set to 00

    • Don't Fragment (DF): If set to 11, prohibits routers from fragmenting the datagram.

    • More Fragments (MF): If set to 11, indicates that additional fragments follow; if set to 00, marks the final fragment.

    • Fragment Offset (13 bits13\text{ bits}): Indicates the relative position of the fragment's payload data relative to the beginning of the unfragmented datagram payload, measured in 8-byte (64 bits64\text{ bits}) blocks. All fragments except the final one must contain payload sizes that are exact multiples of 8 bytes8\text{ bytes}.

    • Time to Live / TTL (8 bits8\text{ bits}): A counter decremented by each router hop along the transmission path. Prevents persistent looping by discarding the datagram when the value reaches 00

    • Protocol (8 bits8\text{ bits}): Identifies the transport-layer protocol recipient of the payload data (e.g., TCP protocol code 66, UDP protocol code 1717

    • Header Checksum (16 bits16\text{ bits}): Provides error detection for header integrity during transit. Recomputed and verified at every intermediate hop.

    • Source Address (32 bits32\text{ bits}): Contains the globally unique IPv4 address of the originating sender host.

    • Destination Address (32 bits32\text{ bits}): Contains the globally unique IPv4 address of the intended receiver host.

    • Options (Variable length): Optional operational settings including explicit routing constraints, timing markers, or security controls.

    • Padding (Variable length): Zero-fill bits appended to guarantee that the IP header length terminates precisely on a 32-bit boundary.

    • Payload / Data: The actual user information originating from upper-layer transport protocols.

IPv4 Fragmentation and Reassembly

  • Path Maximum Transmission Unit (MTU):

    • Different physical underlying link-layer technologies enforce varying limits on the maximum size of a frame payload, known as the Maximum Transmission Unit (MTU).

    • Token Ring LAN MTU: 4000 bytes4000\text{ bytes}

    • Ethernet LAN MTU: 1500 bytes1500\text{ bytes}

  • Fragmentation Mechanics:

    • When a datagram encounters a network link with an MTU smaller than the datagram's total size, intermediate access gateways or routers split the datagram into smaller, manageable fragments.

    • Reassembly Execution: Fragment reassembly is performed exclusively at the final destination host, never at intermediate access gateways.

  • Comprehensive Path Walkthrough:

    • A Source Host application generates 7000 bytes7000\text{ bytes} of payload user data.

    • Transmission across Token Ring LAN (MTU=4000 bytes\text{MTU} = 4000\text{ bytes}):

    • Datagram Fragment 1 User Payload: 3024 bytes3024\text{ bytes}

    • Datagram Fragment 2 User Payload: 3976 bytes3976\text{ bytes}

    • Combined initial transmission: 3024+3976=7000 bytes3024 + 3976 = 7000\text{ bytes}

    • Transit through global internetwork access gateways to Ethernet LAN (MTU=1500 bytes\text{MTU} = 1500\text{ bytes}):

    • Standard IP Header Size = 20 bytes20\text{ bytes}

    • Maximum allowable user payload per Ethernet frame: 1500−20=1480 bytes1500 - 20 = 1480\text{ bytes}

    • The 3024 bytes3024\text{ bytes} payload segment is split into:

      • Ethernet Fragment 1: 1480 bytes1480\text{ bytes} payload

      • Ethernet Fragment 2: 1480 bytes1480\text{ bytes} payload

      • Ethernet Fragment 3: 1016 bytes1016\text{ bytes} payload (3024−1480−1480=64 bytes3024 - 1480 - 1480 = 64\text{ bytes} remaining plus header adjustment, totaling 1016 bytes1016\text{ bytes} payload block)

    • The 3976 bytes3976\text{ bytes} payload segment is split into:

      • Ethernet Fragment 4: 1480 bytes1480\text{ bytes} payload

      • Ethernet Fragment 5: 1480 bytes1480\text{ bytes} payload

      • Ethernet Fragment 6: 64 bytes64\text{ bytes} payload (3976−1480−1480=1016 bytes3976 - 1480 - 1480 = 1016\text{ bytes} block split down to final remainder 64 bytes64\text{ bytes})

    • Reassembly at Destination Host:

    • The receiving host aggregates all arriving payloads:       1480 B+1480 B+1016 B+1480 B+1480 B+64 B=7000 bytes1480\text{ B} + 1480\text{ B} + 1016\text{ B} + 1480\text{ B} + 1480\text{ B} + 64\text{ B} = 7000\text{ bytes}

    • The complete 7000 bytes7000\text{ bytes} message is passed up to the destination application layer.


IP Datagram Fragmentation across Network MTUs

Class-Based IP Addressing Architecture

  • Address Formatting:

    • IPv4 addresses consist of a 32-bit sequence divided into four distinct 8-bit groupings known as octets.

    • Expressed in dotted-decimal notation: w.x.y.zw.x.y.z

    • An address is divided logically into two components:     IPv4 Address=NetID+HostID\text{IPv4 Address} = \text{NetID} + \text{HostID}

    • NetID: Identifies the specific network to which the host belongs.

    • HostID: Identifies the individual endpoint device on that network.

  • Address Classification System:


Classful Addressing Bit Structures
  • Class A Addresses:

    • Leading Bits: Fixed binary 0 (1 bit1\text{ bit}).

    • NetID Allocation: 7 bits7\text{ bits}.

    • HostID Allocation: 24 bits24\text{ bits}.

    • Type: Unicast addressing.

    • First Octet Decimal Range: 00 to 127127

    • Total Theoretical Networks: 27=1282^7 = 128

    • Special Reserved NetIDs: NetID 0 (represents current local network) and NetID 127 (reserved for loopback testing).

    • Usable Unique Networks: 27−2=1262^7 - 2 = 126

    • Unique Hosts per Network: 224−2=16,777,2142^{24} - 2 = 16,777,214

  • Class B Addresses:

    • Leading Bits: Fixed binary 10 (2 bits2\text{ bits}).

    • NetID Allocation: 14 bits14\text{ bits}.

    • HostID Allocation: 16 bits16\text{ bits}.

    • Type: Unicast addressing.

    • First Octet Decimal Range: 128128 to 191191

    • Total Unique Networks: 214=16,3842^{14} = 16,384

    • Unique Hosts per Network: 216−2=65,5342^{16} - 2 = 65,534

  • Class C Addresses:

    • Leading Bits: Fixed binary 110 (3 bits3\text{ bits}).

    • NetID Allocation: 21 bits21\text{ bits}.

    • HostID Allocation: 8 bits8\text{ bits}.

    • Type: Unicast addressing.

    • First Octet Decimal Range: 192192 to 223223

    • Total Unique Networks: 221=2,097,1522^{21} = 2,097,152

    • Unique Hosts per Network: 28−2=256−2=2542^8 - 2 = 256 - 2 = 254

  • Class D Addresses:

    • Leading Bits: Fixed binary 1110 (4 bits4\text{ bits}).

    • Address Allocation: 28 bits28\text{ bits} dedicated to multicast group identification.

    • Type: Multicast addressing (transmits packets to a defined subscriber group).

    • First Octet Decimal Range: 224224 to 239239

  • Class E Addresses:

    • Leading Bits: Fixed binary 1111 (4 bits4\text{ bits}).

    • Type: Reserved for future experimental, testing, and research usage.

    • First Octet Decimal Range: 240240 to 255255

    • Special-Purpose IP Addresses and Routing Rules:

  • Network Address (HostID = All 00s):

    • Identifies the entire network segment itself rather than an individual endpoint device.

  • Local Network Reference (NetID = All 00s):

    • Refers to "this current local network" where the sending machine is located.

  • Limited Broadcast Address (Every Bit = 11, i.e., 255.255.255.255255.255.255.255):

    • Delivers a broadcast message to every machine residing on the immediate local physical network segment. Routers block these packets from traversing boundaries.

  • Direct Broadcast Address (HostID = All 11s):

    • Delivers a message to all host endpoints located on a specified target network (e.g., for a Class B NetID 129.32129.32, the direct broadcast address is 129.32.255.255129.32.255.255).

  • Loopback Address (Class A NetID = All 11s, 127.x.x.x):

    • Reserved for internal diagnostics and local stack testing. Messages routed to 127.0.0.1 are returned internally without hitting a physical network interface.

  • Local Area Network Assignment Rule:

    • Every individual LAN or subnet within an organization shares a common primary NetID but maintains distinct subnet identifiers.

Subnetting and Subnet Masking

  • Subnet Architecture:

    • Standard Classful IP allocation can result in inefficient address space utilization.

    • Subnetting allows a single primary site NetID to be subdivided into multiple logical internal sub-networks (subnets).

    • Structural Division:     IPv4 Address=NetID+SubnetID+Local HostID\text{IPv4 Address} = \text{NetID} + \text{SubnetID} + \text{Local HostID}

    • HostID bits are borrowed from the traditional host portion to construct the internal SubnetID space.

  • Subnet Masking Principles:

    • A subnet mask is a 32-bit delimiter that explicitly indicates which bit positions correspond to the network/subnet portion and which correspond to host endpoints.

    • Binary Encoding:

    • Bit = 1: Identifies Network and Subnet portions (NetID+SubnetID\text{NetID} + \text{SubnetID}).

    • Bit = 0: Identifies Local Host portion (HostID\text{HostID}).

  • Worked Example of Subnet Mask Interpretation:

    • Base Network ID: 128.10.12.0

    • Subnet Mask: 255.255.255.0

    • Binary Subnet Mask: 11111111.11111111.11111111.00000000

    • Analysis:

    • Because 128 falls in the range 128−191128-191, the primary network is Class B (default NetID size = 16 bits16\text{ bits}).

    • First 2 octets (128.10): Represent the Internet-wide primary Class B NetID.

    • 3rd octet (12): Represents the borrowed 8-bit SubnetID.

    • 4th octet (0): Represents the remaining local host address space.

    • External Internet gateways routing traffic to this site process only the primary Class B NetID (128.10); internal subnets remain transparent to outside routers.

  • Campus Subnetting Calculation Task:

    • Problem Parameters:

    • Assigned Site Base IP: 150.10.0.0

    • Required Internal LANs (Subnets): 5050

    • Required Host Capacity: Up to 10001000 host devices per LAN.

    • Step 1: Determine Address Class:

    • The initial octet is 150150, which falls between 128128 and 191191. The address belongs to Class B.

    • Base allocations: NetID = 16 bits16\text{ bits}, HostID = 16 bits16\text{ bits}.

    • Step 2: Calculate Required Subnet Bits (ss):

    • Formula requirement: 2s subnets×2h hosts→2s×2h total addressing space2^s \text{ subnets} \times 2^h \text{ hosts} \rightarrow 2^s \times 2^h \text{ total addressing space}

    • For 5050 subnets: 25=322^5 = 32 (insufficient); 26=64 subnets2^6 = 64 \text{ subnets} (sufficient, 6 bits6 \text{ bits} borrowed).

    • Step 3: Calculate Required Host Bits (hh):

    • For 10001000 usable hosts: 29−2=5102^9 - 2 = 510 (insufficient); 210−2=1022 usable hosts2^{10} - 2 = 1022 \text{ usable hosts} (sufficient, 10 bits10 \text{ bits} required).

    • Step 4: Verify Bit Allocation Balance:

    • Total Bits: 16 (NetID)+6 (SubnetID)+10 (HostID)=32 bits16 \text{ (NetID)} + 6 \text{ (SubnetID)} + 10 \text{ (HostID)} = 32\text{ bits}.

    • Step 5: Derive Custom Subnet Mask:

    • Combined Network + Subnet length = 16+6=22 bits16 + 6 = 22\text{ bits}.

    • Binary Mask: 11111111.11111111.11111100.00000000

    • Dotted Decimal Subnet Mask: 255.255.252.0

Classless Inter-Domain Routing (CIDR)

  • Concept and Advantages:

    • Classless addressing replaces rigid Class A, B, and C boundaries, allowing the network prefix length to be defined at any arbitrary bit boundary (nn).

    • Represented using CIDR notation: w.x.y.z / n, where n specifies the exact number of contiguous leading bits assigned to the network prefix.

    • Eliminates address allocation waste by matching assigned blocks precisely to organizational requirements.

  • Allocation Example:

    • Scenario: An organization requires IP addresses for 10001000 host machines.

    • Traditional Classful Method: Class C provides only 254254 usable addresses (insufficient). The organization must be given a Class B block (65,53465,534 addresses), wasting over 64,00064,000 addresses.

    • Classless Method: The organization is allocated a block of 10241024 (2102^{10}) addresses.

    • Prefix Calculation: n=32−10=22 bitsn = 32 - 10 = 22\text{ bits}.

    • Notation: w.x.y.z / 22

    • Bit Split: Leading 22 bits22\text{ bits} represent the NetID prefix; remaining 10 bits10\text{ bits} are assigned for internal host addresses.

  • CIDR Range Analysis Task:

    • Parameter Input Range: 200.30.0.0 through 200.30.3.255

    • Binary Conversion:

    • Start Address (200.30.0.0): 11001000.00011110.00000000.00000000

    • End Address (200.30.3.255): 11001000.00011110.00000011.11111111

    • Prefix Derivation:

    • 1st Octet (200): 11001000 (8 matching bits8\text{ matching bits})

    • 2nd Octet (30): 00011110 (8 matching bits8\text{ matching bits})

    • 3rd Octet Range (0 to 3): Binary 00000000 to 00000011. The first 6 bits6\text{ bits} (000000) remain static across the range, while the last 2 bits2\text{ bits} vary.

    • Total Common Network Bits (nn): 8+8+6=22 bits8 + 8 + 6 = 22\text{ bits}.

    • Final Derived Parameters:

    • Network ID (CIDR): 200.30.0.0 / 22

    • Binary Address Mask: 11111111.11111111.11111100.00000000

    • Dotted Decimal Address Mask: 255.255.252.0

Network Address Translation (NAT)

  • Operational Function:

    • Network Address Translation (NAT) maps an entire internal private IP address space to a single public IP address for outgoing and incoming Internet communications.

    • Conserves public IPv4 space and provides an implicit boundary layer for internal network security.

  • Standard Reserved Private IP Ranges (RFC 1918):

    • 10-bit Block (10.0.0.0 / 8):

    • Range: 10.0.0.0 to 10.255.255.255

    • Capacity: 224=16,777,2162^{24} = 16,777,216 host addresses.

    • 12-bit Block (172.16.0.0 / 12):

    • Range: 172.16.0.0 to 172.31.255.255

    • Capacity: 220=1,048,5762^{20} = 1,048,576 host addresses.

    • 16-bit Block (192.168.0.0 / 16):

    • Range: 192.168.0.0 to 192.168.255.255

    • Capacity: 216=65,5362^{16} = 65,536 host addresses.

  • NAT Translation Table Mechanics:

    • The NAT router dynamically tracks connection states by altering address and port values in passing IP and TCP/UDP packet headers.

    • Local IP/Port bindings are converted to corresponding Global IP/Port bindings.


NAT Router Translation Architecture
  • Step-by-Step Translation Sequence:

    • System Topology Configuration:

    • Local Host Endpoint: Private IP 10.0.0.3

    • NAT Router Interface (Internal): Private IP 10.0.0.4

    • NAT Gateway External Interface (ADSL Line): Public IP 168.24.16.7

    • Remote Web Server: Public IP 128.40.19.12, HTTP Port 80

    • Step 1 (Outbound Local Packet - Internal Segment):

    • Local Host 10.0.0.3 originates a request on source port 2750 addressed to Web Server 128.40.19.12:80.

    • Source IP: 10.0.0.3 | Source Port: 2750

    • Destination IP: 128.40.19.12 | Destination Port: 80

    • Step 2 (Outbound Global Packet - NAT Gateway Processing):

    • NAT router intercepts the packet, assigns an unused public source port (4001), and overwrites the header fields.

    • NAT Table Entry Generated: 10.0.0.3 : 2750 →\rightarrow 168.24.16.7 : 4001

    • Source IP: 168.24.16.7 | Source Port: 4001

    • Destination IP: 128.40.19.12 | Destination Port: 80

    • Step 3 (Inbound Response Packet - Global Internet Return):

    • Web Server 128.40.19.12 generates a response targeted to the router's public address and port combination.

    • Source IP: 128.40.19.12 | Source Port: 80

    • Destination IP: 168.24.16.7 | Destination Port: 4001

    • Step 4 (Inbound Local Packet - NAT Table Lookup and Delivery):

    • NAT router inspects port 4001 in its translation table, identifies matching local host binding 10.0.0.3:2750, rewrites destination address fields, and forwards the packet to the local machine.

    • Source IP: 128.40.19.12 | Source Port: 80

    • Destination IP: 10.0.0.3 | Destination Port: 2750