LAN
MAC address
IP address is used for layer 3, MAC address is used for layer 2!
MAC (or LAN or physical or Ethernet) address is used locally to get frame from one interface to another physically-connected interface.
48-bit MAC address is burned in NIC ROM, but it is software settable nowdays.
e.g. 1A-2F-BB-76-09-AD
Q. How do I get a unique MAC address?
A. There are few network card manufacturers, and each network card manufacturers have unique prefix of MAC address.
MAC address is portable; We can move interface from one LAN to another.
c.f. IP address is not portable! It depends on IP subnet to which node is attached.
ARP (Address resolution protocol)
Determine interface's MAC address using its IP address.
Each IP node (host, router) on LAN has ARP table.
ARP table contains IP/MAC address mappings for some LAN nodes.
ARP table also contains TTL (Time To Live), time after which address mapping will be forgotten. (Typically 20 minutes)
ARP in same network
- A broadcasts ARP query, containing B's IP address. Source MAC, source IP, target IP are set correctly, and destination MAC address is set to all ones. (FF-FF-FF-FF-FF-FF)
We need to broadcast because we use Layer 2 to transfer IP packet, which requires a MAC address. - All nodes on LAN receive ARP query.
- B replies to A with ARP response, setting source MAC, source IP, target MAC, target IP correctly.
- A receives B's reply, then store source MAC (i.e. B's MAC address) into its ARP table.
ARP in other network
Assume that we are sending a datagram from A to B via router R.
A knows B's IP address, IP address of first hop router R (via DHCP), and R's MAC address (via ARP).
A can't get B's MAC address via ARP because they are not in the same LAN (i.e. same network).
- A send link-layer frame to R with A's MAC address as a source and R's MAC address as a destination.
- (Link-layer of) R pass IP datagram (from A to B) up to network-layer.
- (Network-layer of) R determines outgoing interface, then pass IP datagram back to link-layer.
- (Link-layer of) R creates link-layer frame to B with R's MAC address as a source and B's MAC address as a destination.
- B receives link-layer frame, extracts IP datagram, then pass payload up to application.
Ethernet
Ethernet is the first and the most dominant wired LAN technology.
Simple and cheap
Kept up with speed race (from 10Mbps to 400Gbps)
Single chip can have multiple speeds
Connectionless: No handshaking between sending and receiving NICs(Network Interface Card)
Unreliable: Receiving NIC doesn't send ACKs or NAKs to sending NIC. (Only higher layer can detect dropped data frame e.g. TCP)
Use unslotted CSMA/CD with binary backoff as a Ethernet's MAC protocol.
Physical topology of Ethernet
- Bus
- Coaxial cable (bus) connects all nodes.
- Popular through mid 90s.
- All nodes can collide with each other.
- Switch
- Active link-layer switch is in center, connected with all nodes.
- Widely used today.
- Each incoming link runs a separate Ethernet protocol, so nodes do not collide with each other.
Ethernet frame structure
Preamble
Used to synchronize receiver, sender clock rates.
It consists of 7 bytes of 10101010 followed by one byte of 10101011.
Addresses
6 bytes of destination MAC address, followed by 6 bytes of source MAC address.
If adapter receives frame with matching destination address, or with broadcast address, it passes data in frame to network layer protocol.
Otherwise, adapter discards frame.
Type
Determines higher layer protocol, mostly IP.
However, any network-layer protocol can be used in theory. e.g. Novell IPX, AppleTalk
The receiver can use type bytes in a demultiplexer.
Payload
Network-layer datagram, mostly IP datagram.
CRC
Cyclic redundancy check at receiver.
If error is detected, frame is dropped.
802.3 Ethernet standards
There are many different Ethernet standards!
- Standardize the link and physical layers
- Common MAC protocol and frame format
- Different speeds: 2Mbps ~ 40Gbps
- Different physical layer media: Fiber, cable
Ethernet switch
Switch examine incoming frame's MAC address, selectively forward frame to one-or-more outgoing links when frame is to be forwarded on segment, uses CSMA/CD to access segment.
Theoretically, switch is a link-layer device, i.e. it only looks at Ethernet frames and doesn't look at IP datagrams.
In fact, other network-layer protocols can be used too! (Because that's why we have layered networks...)
However, in real life, we use a Layer 3 switch which is a combination of a switch and a router.
Multiple simultaneous transmissions
Each host have a dedicated, direct connection to switch.
Switches can buffer packets, and each link have its own Ethernet protocol and collision domain.
Full duplex connection is possible without collisions!
But connection sharing either ends can't happen simultaneously.
Switch forwarding table
Switch has a switch table that records MAC address of host and interface to reach it.
Switch forwarding table can be self-learned!
When frame is received to switch, switch records MAC address of the sender and its interface.
If destination is not yet found, switch will flood the frame. (i.e. It will forward on all interfaces except arriving interface.)
Interconnecting switches
Switches can be interconnected!
Self learning works exactly the same!
However, loop can happen if switch is connected in loop.
Switches have algorithm that makes spanning tree from its graph.