Computer Networks: cram pack

Formula sheets, the key method steps for every topic and 6 practice problems, with full solutions at the back.

New problemsBack to the course

In the print window, choose “Save as PDF” to keep a copy on your device.

1Formulas and methods

IPv4 subnetting

Hosts per subnet
2(32 − prefix) − 2 (/31: 2, /32: 1)
Block size
256 − (mask octet)
Network address
IP AND mask
Broadcast address
IP OR (NOT mask): all host bits set to 1
Subnets from n borrowed bits
2n

Number systems

Place values
binary 2k, octal 8k, hex 16k
To decimal
Σ dk·bk
From decimal
divide by the base, read the remainders bottom-up
Hex ↔ binary
one hex digit = 4 bits
Two’s complement
invert the bits and add 1

2Practice problems

1.IPv4 subnettingMedium
/24 → /2611111111111111111111111111000000network bitshost bits

The network 192.168.10.0/24 must be divided into at least 4 equal subnets. If you borrow as few bits as possible, how many usable hosts H does each subnet have?

192.168.10.0/244 subnets
H =
2.IPv4 subnettingHard
last octet = 40012806413201618040201networkhost

A host has the address 10.20.215.40/30. What is the fourth octet x of its network address?

10.20.215.40/30
x =
3.Computer networksMedium

HTTP is stateless. How do websites usually keep a user logged in across requests?

  1. ABy giving each user a fixed IP address
  2. BBy keeping the TCP connection open for days
  3. CWith cookies holding a session identifier or token
  4. DBy storing the password in the URL
4.Computer networksHard

What does the Diffie-Hellman key exchange achieve on its own, and what is its weakness?

  1. AIt signs certificates for websites, but only works with short keys
  2. BIt encrypts bulk data directly over a public channel, but it is far too slow for large files and video
  3. CIt agrees a shared secret over a public channel, but alone it is open to a man-in-the-middle
  4. DIt authenticates both users with passwords, but needs a central server
5.Number systemsMedium
8-bit two's complement0−12806403201608040201

Set the bits so they store −71 in 8-bit two's complement. Read as an unsigned number, what is the pattern's value U?

N = −718 bit
U =
6.Number systemsHard
32 bit1 px512 px512 pxM = ? KiB

An uncompressed image is 512 × 512 pixels with 32 bits per pixel. How much memory M does it take, in KiB (1 KiB = 1024 bytes)?

512 × 512 px32 bit/px1 KiB = 1024 B
M = KiB

3Solutions

1.IPv4 subnetting

Answer: H = 62

IPv4 subnetting: an address has 32 bits. The prefix /p says how many leading bits identify the network; the remaining 32 − p bits number the hosts. A subnet has 2³²⁻ᵖ addresses, but the first (network address) and last (broadcast address) cannot be given to hosts, so 2³²⁻ᵖ − 2 hosts fit. Exceptions: a /31 (point-to-point link, RFC 3021) uses both of its 2 addresses for hosts, and a /32 is one single address (a single host or a loopback).

Bits to borrow

22 = 4 ≥ 4 → b = 2, /26

Hosts per subnet

26 − 2 = 62

Answer

H = 62
2.IPv4 subnetting

Answer: x = 40

IPv4 subnetting: an address has 32 bits. The prefix /p says how many leading bits identify the network; the remaining 32 − p bits number the hosts. A subnet has 2³²⁻ᵖ addresses, but the first (network address) and last (broadcast address) cannot be given to hosts, so 2³²⁻ᵖ − 2 hosts fit. Exceptions: a /31 (point-to-point link, RFC 3021) uses both of its 2 addresses for hosts, and a /32 is one single address (a single host or a loopback).

Block size

22 = 4

Subnet of this host

network: ⌊40/4⌋·4 = 40
broadcast: 40 + 4 − 1 = 43
usable hosts: 41 … 42

Answer

x = 40
3.Computer networks

Answer: C · With cookies holding a session identifier or token

Why this is the answer

The server sets a cookie containing a session ID or token, and the browser returns it with each request so the server can recognise the user.

Answer

C · With cookies holding a session identifier or token
4.Computer networks

Answer: C · It agrees a shared secret over a public channel, but alone it is open to a man-in-the-middle

Why this is the answer

Diffie-Hellman lets two parties derive the same secret that eavesdroppers cannot compute. An attacker in the middle can run separate exchanges with each side unless the values are signed or otherwise authenticated.

Answer

C · It agrees a shared secret over a public channel, but alone it is open to a man-in-the-middle
5.Number systems

Answer: U = 185

Setting bits: each bit is worth a power of two (128, 64, …, 1). One hex digit is exactly four bits, and in 8-bit two's complement the leftmost bit is worth −128. Bitwise operations work on each bit position separately.

Invert and add one

71 = 0100 0111
inverted: 1011 1000
+1 → 1011 1001

Read it as unsigned

1011 1001₂ = 256 − 71 = 185

Answer

U = 185
6.Number systems

Answer: M = 1024 KiB

Positional number systems: each digit is worth its value times a power of the base. In binary the places are worth 1, 2, 4, 8, 16, …; in hexadecimal 1, 16, 256, …, with A–F standing for 10–15. In 8-bit two's complement the leftmost bit is worth −128 instead of +128, which is how negative numbers are stored.

Bits and bytes

512·512·32 = 8388608 bit = 1048576 B

Convert to KiB

1048576/1024 = 1024 KiB

Answer

M = 1024 KiB

ExamProblems · examproblems.com/courses/computer-networks