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
255.255.255.24811111111111111111111111111111000network bitshost bits

A subnet uses the mask 255.255.255.248. How many usable host addresses H does it have?

255.255.255.248
H =
2.IPv4 subnettingHard
last octet = 243112816413211608041211networkhost

A host has the address 10.20.168.243/29. What is the fourth octet x of the last usable host address in its subnet?

10.20.168.243/29
x =
3.Computer networksMedium

What is the main difference between the HTTP methods GET and POST?

  1. AGET retrieves a resource, POST submits data in the request body
  2. BGET is encrypted, POST is not
  3. CGET uses UDP, POST uses TCP
  4. DGET deletes a resource, POST reads it from the server's database
4.Computer networksHard

Why does TCP choose an unpredictable initial sequence number for each connection?

  1. ATo encrypt the payload of each segment
  2. BTo compress the data more efficiently
  3. CTo avoid confusion with old segments and make spoofed segments harder to inject
  4. DTo select the best route to the destination for the segments of that connection
5.Number systemsMedium
place values in two's complement1−12816403201608040201

The 8-bit pattern 1100 0000 stores a signed integer in two's complement. What is its value N in decimal?

1100 00008 bit
N =
6.Number systemsHard
1960 codes, b = ? bits?2ᵇ⁻¹…?4?2?1

A system must give every one of 1960 items its own binary code of the same length. What is the smallest number of bits b needed?

1960
b = bit

3Solutions

1.IPv4 subnetting

Answer: H = 6

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).

Prefix length

255.255.255.248 = /29

Usable hosts

23 − 2 = 6

Answer

H = 6
2.IPv4 subnetting

Answer: x = 246

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

23 = 8

Subnet of this host

network: ⌊243/8⌋·8 = 240
broadcast: 240 + 8 − 1 = 247
usable hosts: 241 … 246

Answer

x = 246
3.Computer networks

Answer: A · GET retrieves a resource, POST submits data in the request body

Why this is the answer

GET asks for a resource and should not change server state. POST sends data, such as a form, in the body for the server to process.

Answer

A · GET retrieves a resource, POST submits data in the request body
4.Computer networks

Answer: C · To avoid confusion with old segments and make spoofed segments harder to inject

Why this is the answer

Random initial sequence numbers stop delayed segments from old connections being accepted and make it hard for off-path attackers to forge valid segments.

Answer

C · To avoid confusion with old segments and make spoofed segments harder to inject
5.Number systems

Answer: N = −64

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.

Add the place values

The other bits keep their normal positive values.

−128 + 64 = −64

Answer

N = −64
6.Number systems

Answer: b = 11 bit

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.

Powers of two

210 = 1024 < 1960
211 = 2048 ≥ 1960

Answer

b = 11

ExamProblems · examproblems.com/courses/computer-networks