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
/16 → /2111111111111111111111100000000000network bitshost bits

The network 172.16.0.0/16 is divided into equal subnets with prefix /21. How many subnets N are there?

172.16.0.0/16/21
N =
2.IPv4 subnettingHard
third octet = 202112816403201618041201networkhost

A host has the address 172.20.202.120/18. What is the third octet x of its network address?

172.20.202.120/18
x =
3.Computer networksMedium

What does a subnet mask of 255.255.255.0 correspond to in CIDR notation?

  1. A/8
  2. B/24
  3. C/16
  4. D/32
4.Computer networksHard

Why does the side that closes a TCP connection first stay in the TIME_WAIT state for twice the maximum segment lifetime?

  1. ATo keep the encryption keys for later reuse
  2. BSo delayed segments die out and the final ACK can be resent if it was lost
  3. CTo let the routers along the path update their routing tables for the next connection
  4. DTo wait for the DNS cache to expire
5.Number systemsMedium
8-bit two's complement0−12806403201608040201

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

N = −348 bit
U =
6.Number systemsHard
click the bits to set them012806403201608040201

Set the bits to the 8-bit result of 0110 1111 AND 1000 1000. What is the result's value R in decimal?

0110 1111AND1000 1000
R =

3Solutions

1.IPv4 subnetting

Answer: N = 32

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

Borrowed bits

21 − 16 = 5

Number of subnets

N = 25 = 32

Answer

N = 32

Each /21 subnet has 211 − 2 = 2046 usable hosts.

2.IPv4 subnetting

Answer: x = 192

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 in the third octet

26 = 64

Subnet of this host

network: 172.20.192.0
broadcast: 172.20.255.255

Answer

x = 192
3.Computer networks

Answer: B · /24

Why this is the answer

Three octets of 255 are 24 one-bits, so 255.255.255.0 = /24.

Answer

B · /24
4.Computer networks

Answer: B · So delayed segments die out and the final ACK can be resent if it was lost

Why this is the answer

TIME_WAIT ensures a lost final ACK can be repeated and old duplicate segments expire before the same address and port pair is reused.

Answer

B · So delayed segments die out and the final ACK can be resent if it was lost
5.Number systems

Answer: U = 222

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

34 = 0010 0010
inverted: 1101 1101
+1 → 1101 1110

Read it as unsigned

1101 1110₂ = 256 − 34 = 222

Answer

U = 222
6.Number systems

Answer: R = 8

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.

Bit by bit

AND gives 1 only where both bits are 1.

0110 1111
AND 1000 1000
= 0000 1000

Value of the result

0000 1000₂ = 8

Answer

R = 8

ExamProblems · examproblems.com/courses/computer-networks