IP addressing and subnets — exam-style exercises with masks, classes, fragments and ARP (and the DHCP ports I got the wrong way round)

In the last IC2 mock test I reached the DHCP question in such a hurry that I answered from memory: “the server listens on 68 and the client on 67”. True, next one. It was false, and the worst part is that I knew it: I had read it that very morning. What I was missing was a trick so I would not hesitate. Now I tell myself this: the server arrives first, so it gets the lower number (67), and the client, who comes later, gets the next one (68). Silly, but I have not got it wrong since.

This article is for training exactly that: the details you know but mix up under pressure. There is an interactive quiz with every exam format (single choice, multiple choice where wrong ticks subtract, true or false, gap filling, matching, ordering, short answer and two table calculations, one on fragments and one on subnets), four open questions with model answers, a picture with the whole topic and the cheat sheet for the night before. If you have not read the theory yet, start with IP addressing and subnets explained: here it is taken as known. And if you come from the OSI and TCP/IP models exercises, this is the next step.

How to use this article

  1. Do the quiz without looking at the theory. Answer each question and press “Check”: you will see whether you got it right and, above all, why (and why the other options are wrong).
  2. Treat it like the real exam. In multiple-answer questions every wrong tick subtracts: if you are not sure, do not tick.
  3. Do the calculations on paper before typing them: the AND byte by byte, the offsets by adding up the previous data, and the hosts with 2^h − 2. In the tables you type a single number per cell.
  4. Write the open answers before opening the model answer. Then compare it with the “what the marker looks for” list and count how many points you covered. Revise at the end with the cheat sheet and do the quiz again another day: the options are shuffled every time.

The examples use the faculty network from the theory: the laptop 10.110.7.24 with mask 255.255.255.0, the gateway 10.110.7.1 and the campus server 10.200.1.80. If a question sounds strange, think about what that laptop would do.

Quiz: multiple-choice questions

There are 31 questions in the order of the theory: internetworking, addresses and classes, the IP protocol, header and fragmentation, routing, subnets and support protocols. At the end you will see your mark out of 10, calculated as in the exam.

Question 1Multiple · wrong ticks subtract

Which of these are premises of the TCP/IP internetwork? (Tick only the ones that are: every wrong tick subtracts)

  1. Users should not need to know how the networks are interconnected
  2. No particular topology is imposed
  3. The internetwork is independent of the user interface
  4. Every router knows every device on the Internet
  5. Every physical network uses the same technology
Solution

Answer: Users should not need to know how the networks are interconnected · No particular topology is imposed · The internetwork is independent of the user interface

The idea of the internetwork is to make many different physical networks look like one. To do that, it hides how they are joined, imposes no topology and does not depend on the user interface.

Question 2Single choice

The faculty router receives a datagram for 10.200.1.80. What does it look at to decide where to send it?

  1. The network the destination belongs to (10.200.1.0), and it looks for the next router
  2. The server’s MAC
  3. The server’s domain name
  4. The service’s TCP port
Solution

Answer: The network the destination belongs to (10.200.1.0), and it looks for the next router

A router does not keep a route for every device in the world: it keeps networks. It works out the destination’s network and looks up the next hop in its table.

Question 3True or false

About IP addresses:

  1. An IPv4 address takes 4 bytes
  2. The laptop’s IP is the same as its Wi-Fi card’s MAC
  3. In 10.110.7.24 each of the four numbers is one byte written in decimal
  4. IPv6 uses 64-bit addresses
  5. The IP identifies the device’s connection to the network, not the device itself
Solution
  • T — An IPv4 address takes 4 bytes
  • F — The laptop’s IP is the same as its Wi-Fi card’s MAC
  • T — In 10.110.7.24 each of the four numbers is one byte written in decimal
  • F — IPv6 uses 64-bit addresses
  • T — The IP identifies the device’s connection to the network, not the device itself

IPv4 has 32 bits (4 bytes) and IPv6 128. The IP is not the card’s physical address (the MAC), and what it identifies is the connection: a router with three interfaces has three IPs.

Question 4Match

Match each address with its class:

10.110.7.24
172.30.3.5
193.145.138.32
224.0.0.9

Definitions:

  • Class D (multicast)
  • Class C
  • Class A
  • Physical address (MAC)
  • Class B
Solution
  • 10.110.7.24 → Class A
  • 172.30.3.5 → Class B
  • 193.145.138.32 → Class C
  • 224.0.0.9 → Class D (multicast)

The first byte is enough: 0-127 is A (starts with 0), 128-191 is B (10), 192-223 is C (110) and 224-239 is D (1110).

Question 5Fill in the gaps

Fill in the leading bits of each class:

A class B address starts with ____, a class C one with ____ and a multicast (class D) one with ____.

Words:

  • 1111
  • 110
  • 01
  • 10
  • 1110
  • 00
Solution

A class B address starts with 10, a class C one with 110 and a multicast (class D) one with 1110.

Each class adds a 1 in front: A = 0, B = 10, C = 110, D = 1110. That is why the first byte of a class C goes from 192 (11000000) to 223 (11011111).

Question 6Single choice

What class is the address 191.4.20.1?

  1. Class B
  2. Class C
  3. Class A
  4. Class D
Solution

Answer: Class B

Convert it to binary: 191 = 10111111. The first two bits are 10, so it is class B. It is the last class B value for the first byte: 192 is already C.

Question 7True or false

About the service the IP protocol gives:

  1. IP does not set up a connection before sending data
  2. IP reorders datagrams that arrive out of order
  3. Two datagrams from the same transfer can take different paths
  4. IP guarantees that no duplicate datagrams arrive
  5. If a datagram is lost, IP asks for it to be resent
Solution
  • T — IP does not set up a connection before sending data
  • F — IP reorders datagrams that arrive out of order
  • T — Two datagrams from the same transfer can take different paths
  • F — IP guarantees that no duplicate datagrams arrive
  • F — If a datagram is lost, IP asks for it to be resent

IP is connectionless and does no sequence control, no flow control and no error recovery. It decides the route of each datagram separately, so there may be losses, disorder and duplicates: TCP, further up, takes care of that.

Question 8Short answer

What is the packet called that is the smallest block of information in a datagram-switched network and carries the source and destination in its header?

Solution

Answer: datagram

It is the datagram: since it carries source and destination in its header, each one is handled independently.

Question 9Match

Match each IPv4 header field with what it holds:

IHL
Total length
Identification
Time to live
Fragment offset

Definitions:

  • Size of the whole datagram, in bytes
  • Header length, in 32-bit words
  • Physical address of the next router
  • Stops a datagram going round the network forever
  • Number shared by all the fragments of the same datagram
  • Position of the fragment's data inside the original datagram
Solution
  • IHL → Header length, in 32-bit words
  • Total length → Size of the whole datagram, in bytes
  • Identification → Number shared by all the fragments of the same datagram
  • Time to live → Stops a datagram going round the network forever
  • Fragment offset → Position of the fragment’s data inside the original datagram

The next router’s MAC is not in the IP header: it goes in the frame of the network access layer.

Question 10Short answer

An IPv4 header without options is 20 bytes long. What value does its IHL field hold?

Solution

Answer: 5

IHL counts 32-bit (4-byte) words: 20 / 4 = 5. It is the minimum value.

Question 11Single choice

A datagram arrives with IHL = 6. How long is its header?

  1. 24 bytes
  2. 6 bytes
  3. 20 bytes
  4. 48 bytes
Solution

Answer: 24 bytes

Always multiply by 4: IHL × 4 = header bytes.

Question 12Single choice

A datagram has DF = 1 and does not fit in the next network’s MTU. What does the router do?

  1. It cannot fragment it: it discards it and tells the source with an ICMP “fragmentation needed” message
  2. It fragments it anyway
  3. It reassembles it with other fragments
  4. It sets MF = 0 and sends it whole
Solution

Answer: It cannot fragment it: it discards it and tells the source with an ICMP “fragmentation needed” message

DF (Don’t Fragment) set to 1 forbids splitting the datagram. If it does not fit, the router drops it and ICMP tells the source (the “fragmentation needed” code).

Question 13True or false

About the header flags:

  1. MF = 1 in a fragment means more fragments follow
  2. The last fragment of a datagram has MF = 0
  3. Bit 0 of the flags must be 1
  4. With DF = 0 the datagram can be fragmented
Solution
  • T — MF = 1 in a fragment means more fragments follow
  • T — The last fragment of a datagram has MF = 0
  • F — Bit 0 of the flags must be 1
  • T — With DF = 0 the datagram can be fragmented

The flags are 3 bits: bit 0 is reserved and is 0, bit 1 is DF (1 = don’t fragment) and bit 2 is MF (1 = more fragments, 0 = last).

Question 14Calculation

A datagram with 1000 bytes of data reaches a network with MTU 420 (20-byte header, so 400 bytes of data fit per fragment). Fill in the table with the offset in bytes, as in the notes:

FragmentData bytesOffsetMF
1
2
3
Solution
FragmentData bytesOffsetMF
140001
24004001
32008000

400 + 400 + 200 = 1000. Each offset is the sum of the previous data: 0, 400 and 400 + 400 = 800. Only the last one has MF = 0. (In the real header it would be stored in 8-byte units: 0, 50 and 100.)

Question 15True or false

About fragment reassembly in TCP/IP:

  1. Fragments are joined at the destination device
  2. Every router along the way reassembles and fragments again
  3. If a fragment is lost, the destination cannot rebuild the datagram and discards it when its timer runs out
  4. All the fragments of a datagram have to take the same path
Solution
  • T — Fragments are joined at the destination device
  • F — Every router along the way reassembles and fragments again
  • T — If a fragment is lost, the destination cannot rebuild the datagram and discards it when its timer runs out
  • F — All the fragments of a datagram have to take the same path

Reassembling at the destination frees routers from the work and lets each fragment take its own path. The downside: it is less efficient, and a single lost fragment makes all the others useless.

Question 16Short answer

Work out the network: 10.110.12.5 AND 255.255.255.0 = ?

Solution

Answer: 10.110.12.0

The first three bytes of the mask are 255 (all ones) and go through unchanged; the last one is 0 and sets the byte to zero: 10.110.12.0.

Question 17Single choice

The laptop (10.110.7.24, mask 255.255.255.0) sends a job to the printer 10.110.7.200. How does it deliver it?

  1. Directly: it is on the same network, so it asks for its MAC with ARP and sends it the frame
  2. It sends it to the gateway 10.110.7.1
  3. It asks DNS for the printer
  4. It discards it because the printer is not a router
Solution

Answer: Directly: it is on the same network, so it asks for its MAC with ARP and sends it the frame

Same AND, same network: direct delivery. The router does not even notice.

Question 18Single choice

By mistake, the laptop has the mask 255.255.0.0 instead of 255.255.255.0 and pings 10.110.12.5, which is in classroom 12, behind the router. What happens?

  1. The laptop thinks 10.110.12.5 is on its network, asks for its MAC with ARP in classroom 7 and nobody answers
  2. It sends it correctly to the gateway, because the router fixes the mask
  3. The classroom switch forwards it to classroom 12
  4. It works just the same, the mask does not affect sending
Solution

Answer: The laptop thinks 10.110.12.5 is on its network, asks for its MAC with ARP in classroom 7 and nobody answers

10.110.12.5 AND 255.255.0.0 = 10.110.0.0, the same as the laptop’s network with that mask. So it tries direct delivery and the ARP request gets no answer, because the device is on another network.

Question 19Match

Match each type of routing with its description:

Direct
Indirect with static tables
Indirect with dynamic tables

Definitions:

  • The datagram is sent to every device on the Internet
  • The administrator writes the routes by hand and they do not change on their own
  • Routers exchange information every so often and recalculate the routes
  • The destination is on a network the device is connected to
Solution
  • Direct → The destination is on a network the device is connected to
  • Indirect with static tables → The administrator writes the routes by hand and they do not change on their own
  • Indirect with dynamic tables → Routers exchange information every so often and recalculate the routes

Direct = same network, no router. Indirect = through routers, with tables that can be static (by hand, they do not adapt to changes) or dynamic (they build themselves and adapt).

Question 20Multiple · wrong ticks subtract

Which columns does a routing table have as a minimum? (every wrong tick subtracts)

  1. The destination network
  2. The address of the next router (or the interface’s IP if the network is connected)
  3. The final destination’s MAC
  4. The time to live of each datagram
  5. The destination’s DNS name
Solution

Answer: The destination network · The address of the next router (or the interface’s IP if the network is connected)

The minimum is two columns: destination network and next hop. Fuller tables add the mask and a cost.

Question 21Order

Put in order the steps a router follows with its table:

  1. Compare the result with the row’s destination network
  2. Take the destination IP from the datagram
  3. If it matches, send the datagram to that row’s next hop
  4. If no row matches, discard the datagram
  5. AND that IP with the row’s mask
Solution

Correct order:

  1. Take the destination IP from the datagram
  2. AND that IP with the row’s mask
  3. Compare the result with the row’s destination network
  4. If it matches, send the datagram to that row’s next hop
  5. If no row matches, discard the datagram

It is the algorithm in the notes: row by row, N = ID AND mask; if N matches the row’s network, it is sent; if the rows run out, it is discarded.

Question 22Single choice

What is the 0.0.0.0 row with mask 0.0.0.0 at the end of the table for?

  1. It is the default route: any IP AND 0.0.0.0 gives 0.0.0.0, so it picks up everything else
  2. It blocks datagrams with no destination
  3. It sends the datagram to every device (broadcast)
  4. It represents the router’s own network
Solution

Answer: It is the default route: any IP AND 0.0.0.0 gives 0.0.0.0, so it picks up everything else

With the mask all zeros, the AND always gives 0.0.0.0, which matches the row’s network. If it came first, it would swallow every datagram.

Question 23Fill in the gaps

Complete the definition of a subnet mask:

The mask has 32 bits: a bit set to ____ means that bit belongs to the ____ identifier and a bit set to ____ means it belongs to the ____ identifier.

Words:

  • 2
  • 0
  • router
  • network
  • host
  • 1
  • port
Solution

The mask has 32 bits: a bit set to 1 means that bit belongs to the network identifier and a bit set to 0 means it belongs to the host identifier.

Ones mark the network (and subnet) and zeros the host. The notes also call the host the station.

Question 24Calculation

The classroom 7 network, 10.110.7.0, is split into four subnets with the mask 255.255.255.192. Fill in the last byte of each subnet’s network and broadcast addresses, and how many hosts fit:

SubnetNetwork (last byte)Broadcast (last byte)Hosts
1st
2nd
3rd
4th
Solution
SubnetNetwork (last byte)Broadcast (last byte)Hosts
1st06362
2nd6412762
3rd12819162
4th19225562

192 = 11000000: two more bits for the subnet and 6 for the host. Each subnet has 2⁶ = 64 addresses, so they go up in steps of 64. The first one (all zeros) is the network and the last (all ones) the broadcast: that leaves 64 − 2 = 62 hosts.

Question 25Short answer

With the mask 255.255.255.192, what is the network address of the subnet 10.110.7.100 is in?

Solution

Answer: 10.110.7.64

100 AND 192: 01100100 AND 11000000 = 01000000 = 64. The subnet is 10.110.7.64 (from .64 to .127).

Question 26Single choice

How many hosts fit in a subnet with mask 255.255.255.240?

  1. 14
  2. 16
  3. 240
  4. 30
Solution

Answer: 14

Count the zeros in the mask (h) and work out 2^h − 2.

Question 27Match

Match each protocol or application with what it does:

ARP
RARP
ICMP
DHCP
DNS

Definitions:

  • Carries error and control messages back to the source
  • Reassembles fragments at every router
  • Gives a device its network configuration when it connects
  • Translates a name like www.ulpgc.es into an IP address
  • Finds the MAC that corresponds to an IP on the same network
  • A device that only knows its MAC asks a server for its IP
Solution
  • ARP → Finds the MAC that corresponds to an IP on the same network
  • RARP → A device that only knows its MAC asks a server for its IP
  • ICMP → Carries error and control messages back to the source
  • DHCP → Gives a device its network configuration when it connects
  • DNS → Translates a name like www.ulpgc.es into an IP address

ARP goes from IP to MAC and RARP the other way round (Reverse). ICMP reports errors, DHCP configures and DNS translates names. No protocol reassembles fragments at the routers: it happens at the destination.

Question 28Order

The laptop needs its gateway’s MAC (10.110.7.1). Put in order what happens:

  1. IP can now deliver the datagram in a frame addressed to that MAC
  2. The router recognises its IP and replies only to the laptop with its MAC
  3. Every device in the classroom receives the request
  4. The laptop sends the whole network an ARP request with the IP 10.110.7.1 and its own IP-MAC pair
  5. The laptop stores the IP-MAC pair in its ARP cache
Solution

Correct order:

  1. The laptop sends the whole network an ARP request with the IP 10.110.7.1 and its own IP-MAC pair
  2. Every device in the classroom receives the request
  3. The router recognises its IP and replies only to the laptop with its MAC
  4. The laptop stores the IP-MAC pair in its ARP cache
  5. IP can now deliver the datagram in a frame addressed to that MAC

Question by broadcast, direct answer and a cache so it does not ask again. Since the request carries the laptop’s IP-MAC pair, the router can note it down too.

Question 29Order

Put in order the messages a laptop uses to get a new address through DHCP:

  1. DHCPOFFER: each server offers an address
  2. DHCPREQUEST: the client asks for the offer it chose
  3. DHCPDISCOVER: the client looks for servers by broadcast
  4. DHCPACK: the chosen server confirms the allocation
Solution

Correct order:

  1. DHCPDISCOVER: the client looks for servers by broadcast
  2. DHCPOFFER: each server offers an address
  3. DHCPREQUEST: the client asks for the offer it chose
  4. DHCPACK: the chosen server confirms the allocation

Discover, Offer, Request, Ack (DORA). If the server cannot fulfil it, it answers DHCPNACK and the client starts again; if the client sees with ARP that the IP is already in use, it sends DHCPDECLINE.

Question 30True or false

About ICMP and DHCP:

  1. ICMP reports the error to the device that sent the original datagram
  2. ICMP messages travel inside the data field of an IP datagram
  3. ping uses ICMP’s echo request and echo reply messages
  4. In DHCP, the client listens on UDP port 67
  5. DHCP’s dynamic allocation lends the address for a period of time
Solution
  • T — ICMP reports the error to the device that sent the original datagram
  • T — ICMP messages travel inside the data field of an IP datagram
  • T — ping uses ICMP’s echo request and echo reply messages
  • F — In DHCP, the client listens on UDP port 67
  • T — DHCP’s dynamic allocation lends the address for a period of time

ICMP only reports to the original source, not to the routers along the way. ping sends echo requests (type 8) and receives replies (type 0). In DHCP the server listens on 67 and the client on 68.

Question 31Single choice

Which DHCP mechanism gives a device a permanent address the first time it connects?

  1. Automatic allocation
  2. Dynamic allocation
  3. RARP
  4. ARP
Solution

Answer: Automatic allocation

Automatic = for good; dynamic = a timed loan. Careful: the name is misleading, because the server does both without any human involved.

In the class questions, do not convert to binary unless you need to: look at the first byte and compare it with 128, 192 and 224. And in the subnet ones, 256 minus the last byte of the mask gives you the size of each subnet.

Open questions

The IC2 exam has written questions, and how ARP works is one that comes up. Here you have that one and three more that fit the topic: routing with its table, subnets with their mask, and fragmentation. Write your answer in the box (a well-linked paragraph, as in the exam) and then open the model answer.

Question 1Open answer

Explain how the ARP protocol works.

Solution

Model answer:

ARP (Address Resolution Protocol) obtains the physical (MAC) address of a device on the same network from its IP address. When a device A has to deliver a datagram to B and only knows its IP, A’s ARP process sends an ARP request by broadcast with B’s IP and with A’s own IP-MAC pair. Every device on the network receives the request, but only B recognises its IP and answers A directly with an ARP reply containing its MAC. A stores the IP-MAC pair in its ARP cache (you can see it with arp -a), so the following datagrams do not need to ask, and the IP process can now deliver the datagram in a frame addressed to that MAC. If the destination is on another network, what is asked for is the router’s (the gateway’s) MAC. The reverse operation, getting an IP from a MAC, is done by RARP with the help of a server.

What the marker looks for:

  • What it does: from IP to MAC, within the same network
  • The request goes by broadcast and carries the sender’s IP-MAC pair
  • Only the owner of the IP answers, directly to whoever asked
  • The ARP cache, so the question is not repeated
  • For a destination on another network the gateway’s MAC is asked for, or the difference with RARP

If you tell it with an example (the laptop asking for its gateway), you gain clarity and lose nothing.

Question 2Open answer

Explain the difference between direct and indirect routing and how a router uses its routing table.

Solution

Model answer:

Routing is the network-layer function that decides the path of datagrams between networks. It is direct when the destination is on a network the device is connected to: it is delivered without going through any router (the MAC is found with ARP and the frame is sent). It is indirect when the destination is on another network: the datagram is handed to the next router, which decides again. To decide, the routing table is used, which has at least the destination network and the next hop (or “direct”), and usually the mask and a cost too. The router takes the destination IP from the datagram and, row by row, ANDs it with the mask; if the result matches the row’s network, it sends the datagram to its next hop, and if no row matches, it discards it. The 0.0.0.0 row with mask 0.0.0.0 is the default route and goes last. Tables can be static, written by hand and not adapting to changes, or dynamic, built automatically by routers exchanging information every so often.

What the marker looks for:

  • Definition of routing as a network-layer function
  • Direct (same network) vs indirect (through the next router)
  • Table columns: destination network, next hop (mask and cost)
  • The algorithm: AND with the mask, compare, send or discard
  • Default route and static vs dynamic tables

A worked example (10.200.1.80 AND 255.255.255.0 = 10.200.1.0) shows you have understood it.

Question 3Open answer

What are subnets and what is the subnet mask for? Give an example.

Solution

Model answer:

Subnets make it possible to use a single network identifier for several physical networks: some of the most significant bits of the host (station) part are used to identify the subnet. From outside it looks like one network, and inside the router shares traffic out among the subnets. The subnet mask has 32 bits: it is 1 in the bits that identify the network (subnet included) and 0 in the ones that identify the host. A bitwise AND between an IP and its mask gives the network it belongs to. For example, the faculty has the network 10.110.0.0 and uses the third byte for the classroom with the mask 255.255.255.0: the laptop 10.110.7.24 is in the subnet 10.110.7.0 (classroom 7) and the printer 10.110.12.5 in 10.110.12.0 (classroom 12), so between them traffic has to go through the router. In each subnet, the address with all host bits at 0 is the network address and the one with them all at 1 is the broadcast address, so 2^h − 2 hosts fit (with 8 host bits, 254).

What the marker looks for:

  • Definition: one network identifier for several networks, with bits from the host part for the subnet
  • Mask: 1 = network, 0 = host
  • The AND between IP and mask to get the network
  • An example with numbers that add up
  • Network address, broadcast address and number of hosts (2^h − 2)

The definition from the notes is the first two sentences; the example and the calculations are what push the mark up.

Question 4Open answer

Explain the fragmentation of an IP datagram and where it is reassembled, with its advantages and disadvantages.

Solution

Model answer:

Every network has an MTU, the maximum size a frame can carry. If a datagram does not fit in the next network’s MTU, the router splits it into fragments, each with its own IP header. All the fragments carry the same identification; the fragment offset field says which part of the original datagram their data belongs to, and the MF flag is 1 in all of them except the last, which has MF = 0. If the DF flag is 1, the datagram cannot be fragmented. For example, 1400 bytes of data on a network with MTU 620 come out as three fragments of 600, 600 and 200 bytes with offsets 0, 600 and 1200. In TCP/IP, reassembly happens at the destination device. Advantages: each fragment can be routed separately, through different networks, and routers are not overloaded. Disadvantages: it is less efficient and, if a single fragment is lost, the destination cannot rebuild the datagram (the reassembly timer runs out) and the whole datagram is lost.

What the marker looks for:

  • Why fragmentation happens: the network’s MTU
  • Fields involved: identification, offset, MF and DF
  • An example with correct offsets
  • Reassembly at the destination, not at the routers
  • Advantages and disadvantages

What people forget most in the exam: saying where reassembly happens and why that is an advantage.

Open answers are marked on concepts, not exact sentences. An example with numbers that add up (an AND, some offsets) shows you understand it and often makes the difference.

The whole topic in one picture

Before the cheat sheet, a map of everything that comes up. IP in the middle and, around it, what you need to know about each part. If you can explain every card without looking, you have the topic.

The whole topic in one picture Topic map: IP in the centre and five cards with addresses, datagram, routing, subnets and support protocols. IPInternet layerconnectionlessno error or flow controlAddresses32 bits (IPv6: 128)A 0 · B 10 · C 110 · D 1110not the same as the MACDatagrammin. header 20 B (IHL 5)TTL: it cannot loop foreverDF 1 don’t fragment · MF 0 lastRoutingdirect: same networkindirect: table network → next hopstatic by hand · dynamic by itselfSubnetsmask: 1 network · 0 hostnetwork = IP AND maskhosts = 2^h − 2ProtocolsARP IP → MAC · RARP MAC → IPICMP: errors to the sourceDHCP: DORA, UDP 67 / 68
If you can explain every card without looking, you have the topic.

Cheat sheet: IP addressing and subnets

The essentials in 30 seconds

  • IPv4 = 32 bits (4 bytes in decimal with dots); IPv6 = 128 bits. The IP identifies the connection and is not the MAC.
  • Classes: A starts with 0 (1st byte 0-127), B with 10 (128-191), C with 110 (192-223), D with 1110 (224-239, multicast).
  • IP: connectionless, independent datagrams, no sequence, flow or error control; there can be losses, disorder and duplicates.
  • Header: IHL in 32-bit words (minimum 5 = 20 bytes); DF = 1 don’t fragment; MF = 0 last fragment; TTL so it does not circulate forever.
  • Routing: direct if it is the same network; indirect with a table (destination network → next hop); network = IP AND mask; the default route 0.0.0.0/0.0.0.0 goes last.
  • Subnets: mask 1 = network, 0 = host; 2^h − 2 hosts.
  • Protocols: ARP IP → MAC; RARP MAC → IP (server); ICMP errors to the source; DHCP DORA, server 67, client 68.

If they ask you…

If they ask you…Answer
What routers forward onThe destination network, not the device
Goal of the TCP/IP internetworkHide the hardware details and give a universal communication service, as if it were a single network
The class of an addressLook at the first byte: < 128 A, < 192 B, < 224 C, otherwise D
What IP does not doSequence control, flow control and error recovery
Smallest unit of datagram switchingThe datagram
Where reassembly happensAt the destination device
Minimum columns of a tableDestination network and next router
Static vs dynamicBy hand and do not adapt / automatic, periodic exchange, they adapt
Which protocol turns IP into MACARP (and RARP the other way)
Which protocol sends errors and warningsICMP, only to the original source
Automatic vs dynamic allocationPermanent the first time / lent for a period
Name to IPDNS (application)

The calculations that come up

I want…CalculationExample
The network of an IPIP AND mask, byte by byte (255 copies, 0 zeroes)10.200.1.80 AND 255.255.255.0 = 10.200.1.0
An in-between mask byteConvert both to binary and AND them100 AND 192 = 01100100 AND 11000000 = 64
Header bytesIHL × 4IHL 6 → 24 bytes
Data per fragmentMTU − 20MTU 620 → 600 bytes
OffsetsSum of the data in the previous fragments0, 600, 1200
Size of each subnet256 − last non-zero byte of the mask.224 → 32 addresses
Hosts2^h − 2 (h = zeros in the mask).240 → 2⁴ − 2 = 14
BroadcastNext network − 1Network .64 with size 64 → broadcast .127

Templates for the open questions

  • ARP: what it does (IP → MAC, same network) → request by broadcast with the IP wanted and its own IP-MAC pair → everyone receives it, only the owner answers → direct reply with its MAC → ARP cache → IP delivers the frame (if it is another network, it asks for the gateway) → RARP does the opposite.
  • Routing: definition (network-layer function) → direct vs indirect → table (destination network, next hop, mask and cost) → algorithm with AND, compare, send or discard → default route → static vs dynamic.
  • Subnets: one network identifier for several networks → bits from the host part for the subnet → 1/0 mask → AND → example → network, broadcast and 2^h − 2.
  • Fragmentation: MTU → fragments with their own header → identification, offset, MF, DF → example with offsets → reassembly at the destination → advantages and disadvantages.

Symptom and likely cause

Symptom in your examLikely cause
You wrote IHL = 20You counted bytes; IHL counts 32-bit words
The last offset does not add upYou also added the fragment’s own data or took the header off twice
You got one host too many per subnetYou used 2^h instead of 2^h − 2
You ticked that routers reassembleYou mixed up fragmenting (at the router) with reassembling (at the destination)
You swapped ARP and RARPYou did not stop to think which data you have and which you want
A multiple-choice question you thought you had took marks offYou ticked an option “just in case”
You put the DHCP server on 68The other way round: server 67, client 68

Before you hand it in, ask yourself

  1. Did I check the class with the first byte, not by eye?
  2. Do my ANDs copy the bytes with 255 and zero the ones with 0, and did I convert the in-between byte to binary if there was one?
  3. Did I subtract the network and broadcast addresses when counting hosts, and do my offsets add up the previous data?
  4. Did I leave blank the multiple-choice options I was not sure about?

If something was hard, go back to the IP addressing and subnets theory and repeat the quiz another day. With this topic we finish the networks part of IC2; the next one opens operating systems: what an operating system is.

Keep goingAll Networks articles

Did this article help you? Here is how you can support SergioLearns →

Sigue aprendiendo

Leave a Reply

Your email address will not be published. Required fields are marked *