Week 3 - samuelwilson02/tech-journal GitHub Wiki
LANs and Layer 2
- in a LAN: computes communicate NIC to NIC, sending packets w/ their own MAC as destination
- they pay attention to Layer 2 broadcasts (FFs in destination MAC
Layer 2 = data link layer
Hubs (Layer 1, physical) (obsolete)
- don't care about destination - just broadcast packets out all ports
- NICs either accept or reject packets based on MAC destination -> inefficient
Switches (Layer 2 - used in most modern LANs)
- direct packets correctly instead of sending to everyone
- Store info about devices to determine where to send packets -> MAC/CAM/Lookup table
- Correlates devices to switch ports
- If the lookup table doesn't recognize a MAC, it will "flood" the ports
- Filter or flood: recognized -> send to right port (not broadcast); unrecognized -> flood
- Full duplex: can send/receive in both directions
ARP (Address Resolution Protocol)
- Systems find each other's MAC addresses with ARP
- A device must know the destination MAC for its NIC to accept a packet
- When MAC = all "F"s any NIC will accept it (forwarding device)
- ARP identifies the destination IP, requests the MAC; device with the matching IP sends back its MAC
- OS can use an ARP cache to store MACs of recently resolved IP addresses
- MACs are only relevant within the LAN - outside the LAN, ARP is irrelevant because the next MAC is the default gateway
- The Layer 2 header (MAC) is rewritten as it crosses each router; IP (layer 3) stays the same
- If the destination IP's network ID doesn't match the source's, it sends to the default gateway
- On larger networks, ARP can cause issues - so networks are separated into subnets connected by routers