Unit 3 Networking Field Guide

AP Cybersecurity, Days 41 to 45. A reference for the Networking Lab, the Hex Tutorial, and the Network Sandbox. Each section says when to use it. It explains each idea and shows a worked example, and it never gives away your answers.

Need a word or a port number? Open the Computer Science Hub, choose AP Cybersecurity, and use the Vocabulary tab or Cheat Sheets > Common Ports.

1. What a network is

Use this on Day 1, and any time you mix up a switch and a router.

WordMeaning
LANLocal area network. One room, building, or home.
WANWide area network. Cities or the world. The internet is the biggest WAN.
PacketA small chunk of data with a source address, a destination address, and part of the message.
SwitchJoins the devices inside one LAN and sends each message only to the device it is meant for.
RouterJoins different networks and forwards each packet toward its destination.
Access pointLets wireless devices join the LAN.
ISPThe internet service provider. Your router connects to it, and it connects to other providers.
Worked example. A file is 4,300 bytes and each packet carries at most 1,000 bytes. 4,300 ÷ 1,000 = 4.3, and the leftover 300 bytes still need a packet, so round up: 5 packets.

Layouts. Star: everything connects to one central switch. Bus: one shared cable. Ring: each device connects to two neighbors in a loop. Mesh: many direct links, so traffic can go around a failure.

In the sandbox: a computer's gateway is the address of the router on its own LAN. It is where the computer sends anything that is not on its own LAN.

↑ top of section

2. IP addresses and MAC addresses

Use this on Day 2, and whenever the sandbox complains about an address.

An IPv4 address is four numbers from 0 to 255 separated by dots, like 192.168.1.23. It changes when a device joins a different network. A MAC address is six bytes in hex, like 3C:22:FB:9A:10:5E, built into the network card. The first three bytes name the manufacturer.

Private ranges (only work inside one local network)
10.0.0.0 to 10.255.255.255
172.16.0.0 to 172.31.255.255 (172.15 and 172.32 are public)
192.168.0.0 to 192.168.255.255 (192.169 is public)
Worked example. Is 172.20.4.9 private? It starts with 172, and 20 is between 16 and 31, so yes. Is 172.40.4.9 private? 40 is outside 16 to 31, so no, it is public. A valid address needs exactly four parts, and each part must be 0 to 255.

The rule the sandbox uses

Everything on one LAN shares the first three numbers (the network part) and has a different last number. For example, 192.168.1.10 and 192.168.1.11 are on the same LAN. 192.168.1.10 and 192.168.2.10 are not, so they need a router between them. Every address must be unique.

IP stays, MAC changes. Going across routers, the IP addresses stay the same all the way, but the MAC addresses change on every cable segment, because a MAC address only matters on one local link.
↑ top of section

3. Bits, bytes, and hexadecimal

Use this on Day 3, in the Hex Tutorial, and any time you read a hex dump.

A bit is a 0 or a 1. A byte is 8 bits. Each place is worth double the one to its right: 128, 64, 32, 16, 8, 4, 2, 1. Add up the places that hold a 1.

Binary to decimal. 0100 1101 has 1s in the 64, 8, 4, and 1 places. 64 + 8 + 4 + 1 = 77.

Hex is base 16: the digits 0 to 9 and the letters A to F. One hex digit stands for 4 bits, so two digits make one byte.

ABCDEF
101112131415
Hex to decimal. 2F: the left digit is worth 16 each, so 2 × 16 = 32. The right digit is F = 15. 32 + 15 = 47.
Decimal to hex. 200 ÷ 16 = 12 with 8 left over. 12 is C, so 200 is C8.
Hex as text. ASCII letters start at capital A = 41 (65), B = 42, C = 43. So 42 4F 4F is B, O, O: BOO.
↑ top of section

4. The TCP/IP model and packet headers

Use this on Day 3, and whenever you open a packet in the sandbox.

LayerWhat lives here
ApplicationHTTP, HTTPS, DNS, SSH, FTP
TransportTCP and UDP (ports)
InternetIP addresses, routers
Network accessEthernet, Wi-Fi, MAC addresses, switches

Each layer adds its own header in front of the data. A packet in the sandbox is a stack: Ethernet, then IPv4, then TCP or UDP, then the data.

Ethernet header (14 bytes)

BytesField
0 to 5Destination MAC (FF:FF:FF:FF:FF:FF means every device on the LAN)
6 to 11Source MAC
12 to 13Type: 08 00 IPv4, 08 06 ARP, 86 DD IPv6

IPv4 header (20 bytes, starts after the Ethernet header)

ByteField
0Version and length. 45 means IPv4, 20 bytes
2 to 3Total length
8TTL: hops left. Each router subtracts 1
9Protocol: 06 TCP, 11 UDP
10 to 11Header checksum (changes when the TTL changes)
12 to 15Source IP
16 to 19Destination IP

UDP header (8 bytes) and TCP header (20 bytes)

UDP byteFieldTCP byteField
0 to 1Source port0 to 1Source port
2 to 3Destination port2 to 3Destination port
4 to 5Length4 to 7Sequence number
6 to 7Checksum8 to 11Acknowledgment number
13Flags: 02 SYN, 10 ACK, 18 PSH+ACK, 01 FIN, 04 RST
16 to 17Checksum
Worked example. 00 11 22 33 44 55 AA BB CC DD EE FF 08 06: the destination is 00:11:22:33:44:55, the source is AA:BB:CC:DD:EE:FF, and 08 06 means an ARP message follows.
In an IP header, C0 A8 01 0A in the source field is 192.168.1.10, because C0 = 192, A8 = 168, 01 = 1, and 0A = 10.
↑ top of section

5. Ports, protocols, and firewall rules

Use this on Day 4, whenever a packet is refused or blocked, and when you write firewall rules.

ServicePortCleartext?
HTTP80Yes
HTTPS443No, encrypted
FTP21 (control)Yes
SSH22No, encrypted
Telnet23Yes
DNS53(not asked in the lab)
SMTP25(not asked in the lab)

A server only answers on ports it is listening on. TCP port 443 and UDP port 443 are different doors, so the protocol has to match too.

A firewall rule allows or denies traffic. The firewall checks its rules from the top, and the first rule that matches decides. A rule for any matches every packet, so put it last. A firewall only sees packets that cross it, so computers inside the LAN can still reach each other.

1. allow port 443
2. deny port 80
3. allow any
Worked example. A packet for port 80: rule 1 is about 443, no match. Rule 2 is port 80, match, so it is denied. Rule 3 is never checked. A packet for port 22 matches nothing until rule 3, so it is allowed.
↑ top of section

6. Reading a result in the Network Sandbox

Use this whenever you press Send and want to know what happened and why.

ResultWhat it meansWhat to look at
DeliveredThe server was reached and is listening on that port.Open each frame and compare the MAC addresses and TTL.
Blocked by a firewallA router dropped it. The message names the router and the rule.That router's rule list. Order matters.
RefusedThe server was reached, but nothing listens on that port and protocol. TCP answers with a reset (RST), UDP with an ICMP "port unreachable".The server's ports panel.
No routeThe packet had nowhere to go: a missing gateway, a gateway that is not a router on the LAN, or no cable path.Section 8, the checklist.
Cannot send yetA computer has no valid IP address.The device's settings panel.

What changes from step to step

Stays the sameChanges at every router
Source and destination IP, the ports, the dataSource and destination MAC, the TTL (down by 1), and the IP header checksum

Cleartext or encrypted? On ports 80, 21, and UDP the data bytes are readable text. On ports 443 and 22 they look scrambled. That is exactly what someone capturing the packet would see.

↑ top of section

7. TCP, UDP, FTP, and sending files

Use this on Day 4 and Day 5, and before you use Send a file.

UDPTCP
SetupNone. It just sends.Three-way handshake: SYN, SYN-ACK, ACK.
Lost packetsGone for good. Nobody asks for them again.Numbered and acknowledged. A missing one is sent again.
SpeedFastest, with no waiting.Slower, because of handshakes and resends.
Used forVideo streams, voice calls, DNS, games.Web pages, email, file transfer.

FTP

FTP is not a transport protocol. It runs on TCP. It uses a control connection on port 21 for commands and a separate data connection for the file. In the sandbox it uses passive mode: the server tells the client a high data port (50000). Your cheat sheet lists FTP as 20/21, which is the older active mode. The login and every command cross the network as cleartext, including the password.

The classic FTP problem. If a firewall allows port 21 but blocks the data port, the login works and then the transfer fails. Open the FTP log to see the server answer 425 Cannot open data connection.

Reading the file transfer results

LineWhat it tells you
Packets neededThe file size divided by what one packet can carry, rounded up.
Lost for good (UDP) / Lost, then sent again (FTP)How many packets disappeared on the noisy cables.
Fingerprint sent and receivedA CRC32 checksum of the whole file. If they match, the file is exactly right. If not, it is damaged.
Time (ticks)A simplified clock. TCP pays extra ticks for handshakes and for waiting to resend.

Bigger files lose more. Every packet has the same chance of being lost, so a 50 MB file (tens of thousands of packets) almost always loses some. Even 1% loss damages a UDP file that big.

↑ top of section

8. If something is not working: a checklist

Use this when the Network check panel lists a problem, or a packet says No route or Refused.

You seeTry this
"has no IP address yet"Click the device and type an address. Computers on one LAN share the first three numbers.
"different network parts"Find the one device whose first three numbers do not match the rest of its LAN, and fix it.
"Two devices use the IP address"Give one of them a new last number. Every address must be unique.
"gateway ... is not on its own network" or "is not a router on this LAN"A gateway is the address of the router on the same LAN. Click the router, find its address for that LAN, and use it.
"has no gateway set"Type the router's address for that LAN into the Gateway box.
"is not connected" or "fewer than two connections"Use the Cable tool to connect it.
No routeCheck, in order: the sender's gateway, the cables between every router and the provider, and the destination's address.
RefusedClick the server and look at its ports. Is the right port open, and is it the right protocol (TCP or UDP)?
BlockedClick the router the message names and read its rules from the top. Which one matched first?
The transfer could not startRead the explanation. Control port 21 blocked means it never connects. Data port 50000 blocked means you can log in, but the file cannot move.

Back to the Networking Lab, the Hex Tutorial, or the Network Sandbox.

↑ top of section