Start here: IPv4: binary prefixes, subnet allocation, forwarding and fragmentation. Suggested session: 85 minutes.
An IPv4 address is a 32-bit number, usually written as four decimal octets. A prefix tells us which leading bits identify an address block. It does not depend on the old classful A/B/C categories: /26 means the first 26 bits, wherever the octet boundaries happen to lie. The remaining bits distinguish addresses inside that block.
Start with the binary representation before memorizing shortcuts. A prefix mask keeps its leading prefix bits and clears the rest. ANDing an address with that mask gives the lowest address of its block. Setting all remaining bits gives the highest. The block size is a power of two and its starting integer is aligned to that size. This explains both subnet range calculations and why an arbitrary consecutive interval is not necessarily one CIDR prefix.
For ordinary broadcast-subnet exercises, we conventionally exclude the all-zero and all-one host patterns from host assignment. That subtraction has explicit exceptions: a /31 can use both addresses on a point-to-point link under the stated supporting convention, and a /32 identifies a single address. Address-count arithmetic does not establish real-world assignability or public reachability; special-use addresses, policies and the actual link matter too. The addresses used here are constructed documentation examples, not deployed networks.
Variable-length subnet masking (VLSM) gives different-sized blocks to different demands. Round each demand up to a sufficient power-of-two block, align its start, and check that it stays within the parent and does not overlap another allocation. Larger-first allocation is a convenient strategy for these examples, not a proof that every allocation problem has one unique or globally optimal greedy solution.
Once a forwarding table exists, a router matches the destination against its prefixes and chooses the longest matching prefix. A more specific route applies only if it actually contains the destination. A /32 route can override a wider subnet for one address; a /0 default matches when there is no more specific match. Computing or learning the table through routing protocols is a separate topic.
Fragmentation solves another problem: an IPv4 datagram may be larger than a link's permitted IP packet size. MTU includes the IPv4 header and payload, excluding the link-layer framing. Fragment payloads must fit alongside their actual headers. Every fragment that is not the last part of the original datagram has a payload length that is a multiple of eight; offsets count eight-byte positions in the original IP payload. A final payload may have a different remainder.
The worked fragmentation model starts with valid IPv4 packets, DF=0 when fragmentation is allowed, and specified headers. No new headers are inserted into the reassembled payload. Refragmentation keeps the same original identification and adds each child's displacement to its parent's original offset. If the parent says more original data follows, every child must retain MF=1, including the last child of that parent. DF=1 instead prohibits producing smaller fragments; an oversized router-forwarded packet is dropped and fragmentation-needed ICMP is normally sent when permitted, without guaranteeing that the sender receives it.
Allow about 15 minutes for address/prefix arithmetic, 15 for allocation and forwarding, 20 for fragmentation, 15 for the worked examples and 20 for practice/recall. These are original AI-assisted Amalgams beta notes and questions, not official GATE questions. Independent academic review is pending. This pack covers addressing, CIDR/VLSM, longest-prefix forwarding and IPv4 fragmentation foundations within CS-11-4. NAT translation/state and distance-vector/link-state routing algorithms remain separate lessons. Complete standards-level addressing, options/ICMP behavior, route policy, security and reassembly implementation are also outside this foundation. Completing this pack does not establish full heading mastery.
This covers a foundation within the topic; continue with the broader ideas below before marking the whole topic complete.
Next lesson: Routing: neighbor distance estimates, failure loops and link-state shortest paths. Suggested session: 90 minutes.
A router needs an answer to a practical question: which neighbor should receive a packet next? Choosing that neighbor requires information about the rest of the network. Two routing families collect different information before calculating their answers.
In distance-vector routing, a neighbor says how costly it currently believes each destination is. Add the cost of reaching that neighbor, compare the candidates and choose the least. If B reports a destination at cost 4 and the local link to B costs 2, the candidate through B costs 6. The report is an estimate, not a supplied list of every router on the path. It may depend on information that has become stale.
That last detail explains a difficult failure. A can hear that B still reaches a destination, while B's belief actually depends on A's broken route. Both may continue selecting each other as their estimates rise. Count-to-infinity names this gradual increase toward a protocol's unreachable metric; it does not mean a packet travels an infinite number of hops. The worked examples state every relevant cached report, failed link and message delivery. There is no unique update trace without those premises.
Split horizon omits a route from advertisements back toward the neighbor used for that route. Poisoned reverse sends an explicit unreachable value back to that neighbor instead. This breaks the two-router mutual-dependence pattern once the relevant reverse reports have arrived. It does not guarantee that every possible longer loop disappears. Our three-router example obeys poisoned reverse throughout and still forms a loop, even though changed metrics generate updates immediately in the teaching model.
Link-state routing shares another kind of report: the origin router's local links and their costs. Those reports are flooded through the routing domain, with freshness handling, so a router can build a topology database. It then runs a shortest-path algorithm with itself as root. The graph can be shared while the resulting rooted trees and first-hop tables differ. Dijkstra's algorithm is a prerequisite; this lesson adds where its graph comes from and how its result becomes a routing entry.
All graphs here are constructed, simple, undirected router graphs with positive integer, dimensionless link costs. Stable shortest-path examples use mathematical infinity, with no 16-cost cutoff. Failure examples explicitly use capped infinity I=16, so only costs below 16 are valid. This illustrates RIP's unreachable value without claiming to implement RIP timers, packet processing, route retention or every update rule. There are no pending pre-failure messages unless specified. Each event replaces one neighbor's stored report and recomputes the minimum over currently usable links; a worse report from the chosen neighbor must be processed too.
The link-state example uses given consistent snapshots and a small sequence-number model with no wrap, restart, equal-sequence conflict or aging. It illustrates flooding and freshness without reproducing OSPF's full LSA formats, directed router/network graph, acknowledgments, area hierarchy, signed sequence space, checksum/age comparisons or ECMP implementation. The isolated supplied vertex U is unreachable in the SPF input; it is not claimed to exchange advertisements with the connected A-E domain. Receiving failure information and installing new forwarding tables are not instantaneous or globally simultaneous.
Allow about 20 minutes for neighbor updates and learning rounds, 25 for failure traces, 20 for link-state/SPF and 25 for practice and recall. These are original AI-assisted Amalgams beta explanations and questions, not official GATE questions. Independent academic approval is pending. This pack covers distance-vector and link-state foundations within CS-11-4. IPv4/CIDR/VLSM, LPM and fragmentation are taught in the earlier IPv4 pack; NAT address/port translation and state remain a separate named subpoint. Complete routing-protocol implementation, policy/security, hierarchical routing and failure-time guarantees require further study. Completing these foundations does not establish full heading mastery.
Next lesson: NAT: address bindings, port translation and the return path. Suggested session: 85 minutes.
Suppose two laptops use the same source port while sharing one outside IPv4 address. A returning packet still has to reach the right laptop. Network Address Translation (NAT) changes address information at a boundary; Network Address and Port Translation (NAPT), often called PAT, also changes a transport identifier. The interesting part is the reversible association, not merely replacing a number in a packet.
RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 for private internets. Such addresses may be reused in separate private networks and have no globally unique Internet meaning. This does not make the whole of 172.0.0.0/8 private, and it does not mean that every address outside those three blocks is publicly assignable or reachable. Documentation, loopback, link-local and other special-use ranges need their own rules. We use 198.51.100.0/24 and 203.0.113.0/24 only as constructed documentation addresses; no network is deployed or contacted in these examples. [RFC 1918 §3]
With Basic NAT, an inside address is associated with an outside address. Outbound traffic gets a translated source address; matching return traffic gets the inverse destination change. A static association is configured in advance. A dynamic association is chosen from a pool and exists while its stated binding rules keep it alive. Static versus dynamic describes how the association is supplied; address-only versus address-and-port translation describes which fields are changed. These are different distinctions. [RFC 3022 §§2.1–2.2, 3.1–3.3]
NAPT lets several internal endpoints share an outside address by assigning distinguishable outside transport endpoints. An internal endpoint here is an IP address and port within a protocol. Two hosts both using UDP source port 53000 are still different internal endpoints. A return lookup must include the protocol and outside address as well as the outside port; a port number alone is not a globally unique identity. Our stated model never assigns the same live (protocol, outside address, outside port) to two different internal bindings. TCP and UDP have separate protocol namespaces in the worked allocation, but this is an explicit model rule, not a promise about every device. [RFC 3022 §2.2; RFC 4787 §4.2.1]
Mapping behavior asks whether an existing outside association is reused when the same internal endpoint sends to a different remote endpoint. Endpoint-independent mapping ignores the remote endpoint when choosing the binding. Address-dependent mapping includes the remote IP address. Address-and-port-dependent mapping includes both the remote IP and remote port. RFC 4787 §4.1 defines these observed behaviors and requires endpoint-independent mapping for its UDP-unicast requirements. Comparing the other two teaches the distinction; it does not recommend them as compliant with that requirement.
Filtering asks a separate question: which incoming remote sources are allowed to use an existing mapping? A mapping can be endpoint-independent while its inbound filter requires that the internal endpoint previously sent to that exact remote IP and port. Therefore a reused outside port does not mean every stranger can send through it, and endpoint-dependent mapping by itself does not establish a stronger firewall. [RFC 4787 §§4.1, 5, 13]
UDP has no transport connection-establishment handshake. A translator can create and refresh UDP state when outbound packets pass it. It cannot wait for a mandatory UDP SYN. State needs a lifetime, but there is no single timeout for all implementations or all transport protocols. RFC 4787 §4.3 requires an outbound UDP mapping refresh, permits inbound refresh, and gives a two-minute lower bound with a specific well-known-destination-port exception; it recommends a default of five minutes or more. Our exercise explicitly uses a configured 120-second lifetime, refreshes only on successful outbound packets, and expires rows before processing an event at the exact deadline. These arithmetic and ordering premises determine the answer; they do not implement the whole RFC profile. TCP state tracking and TCP timers are outside the UDP trace.
Translation also affects packet integrity. IPv4 address changes require a consistent IPv4 header checksum. TCP and nonzero IPv4 UDP checksums cover IP addresses in a pseudo-header, and NAPT changes a port covered by the transport checksum as well. An IPv4 UDP checksum field of zero denotes the disabled-checksum case and stays zero in this lesson; this exception is not a general IPv6 rule. Fragmented packets add another issue: noninitial fragments do not repeat the transport ports, arrival order can differ from offset order, and two inside sources sharing an outside address can create identification collisions without suitable handling. Our table exercises use valid, unfragmented IPv4 packets and perform no ALG, hairpinning, ICMP-error rewriting or fragment reassembly. [RFC 3022 §4.1 and the failure pattern in §6.3; RFC 4787 §§10–11]
Allow about 15 minutes for address-only translation, 25 for NAPT and mapping/filtering, 20 for expiry and integrity limits, and 25 for worked practice and recall. These are original AI-assisted Amalgams beta notes and constructed questions, not official GATE questions. Independent academic approval is pending. This lesson fills the named NAT translation/state portion of CS-11-4; the earlier packs teach IPv4/CIDR/fragmentation and distance-vector/link-state foundations. It does not establish complete heading mastery, device conformance or a secure/reachable deployed service.