LAN and WAN Protocols
Ethernet is the most widely deployed LAN technology. It was developed jointly by Xerox, Intel, and DEC in 1975 and later standardized by the IEEE 802.3 committee.
MAC Addresses
Definition
A definition is a precise description of what a concept, a term, or an object means. Understanding definitions is the foundation of learning any field, and every concept has its own exact meaning.
A MAC address (Media Access Control Address) is the physical address used by the data link layer to uniquely identify a network interface within a LAN. A MAC address is 48 bits (6 bytes) long and is usually written as 12 hexadecimal digits, for example 00:1A:2B:3C:4D:5E.
The structure of a MAC address:
- First 24 bits (OUI, Organizationally Unique Identifier): the vendor code assigned by the IEEE to equipment manufacturers
- Last 24 bits: the device serial number assigned by the vendor
Special MAC addresses:
- Broadcast address:
FF:FF:FF:FF:FF:FF, meaning all stations in the LAN - Multicast address: the lowest bit of the first byte is 1, meaning a group of stations
- Unicast address: the lowest bit of the first byte is 0, meaning a single station
The Ethernet Frame (Ethernet II Format)
Ethernet Frame (Ethernet II) Structure
Ethernet frame: the preamble synchronizes the clock, the SFD marks the start of the frame, and the FCS is a CRC check
The fields are:
- Preamble: 7 bytes of alternating 0 and 1 bits (
10101010), used by the receiver to synchronize its clock - Start Frame Delimiter (SFD): 1 byte,
10101011, marking the start of the frame - Destination MAC address: 6 bytes, the physical address of the receiver
- Source MAC address: 6 bytes, the physical address of the sender
- Type/Length field: 2 bytes
- a value ≥ 1536 (0x0600) indicates a type (for example 0x0800 for IPv4, 0x0806 for ARP, 0x86DD for IPv6)
- a value ≤ 1500 indicates a length (the original 802.3 format)
- Data field: 46 to 1500 bytes. Padding is required when the data is shorter than 46 bytes, because the minimum Ethernet frame length is 64 bytes (14 bytes of header + 46 bytes of data + 4 bytes of FCS)
- FCS (Frame Check Sequence): 4 bytes, a CRC-32 check used for error detection
The Ethernet MTU (Maximum Transmission Unit) is 1500 bytes, so the data field is at most 1500 bytes. If a packet handed down by the network layer exceeds 1500 bytes, it must be fragmented at the network layer.
The Evolution of Ethernet
| Standard | Speed | Medium | Name origin |
|---|---|---|---|
| 10BASE5 | 10 Mbps | Thick coaxial cable | Maximum segment length 500 m |
| 10BASE2 | 10 Mbps | Thin coaxial cable | Maximum segment length about 200 m (185 m in practice) |
| 10BASE-T | 10 Mbps | Twisted pair | T = Twisted Pair |
| 100BASE-TX | 100 Mbps | Category 5 twisted pair | Fast Ethernet |
| 1000BASE-T | 1 Gbps | Category 5e twisted pair | Gigabit Ethernet |
| 10GBASE-T | 10 Gbps | Category 6a twisted pair | 10 Gigabit Ethernet |
Modern Ethernet uses switches and twisted pair (or fiber) almost exclusively, runs in full-duplex mode, and no longer uses CSMA/CD.
Virtual LANs (VLAN)
A VLAN (Virtual LAN) logically divides a physical LAN into several independent broadcast domains through switch configuration.
- Purpose: isolate broadcast domains and improve network security and performance
- Implementation: insert a 4-byte VLAN tag (the 802.1Q tag) into the Ethernet frame, carrying a VLAN ID (12 bits, 0 to 4095)
- Trunk port: a port connecting two switches, carrying frames with VLAN tags
- Access port: a port connecting an end device, belonging to a single VLAN and carrying untagged frames
A wireless LAN (WLAN) uses radio waves as its transmission medium. The most common standards are the IEEE 802.11 family (marketed as Wi-Fi).
The Evolution of the 802.11 Standards
| Standard | Year | Band | Maximum rate | Notes |
|---|---|---|---|---|
| 802.11 | 1997 | 2.4 GHz | 2 Mbps | The original standard |
| 802.11b | 1999 | 2.4 GHz | 11 Mbps | The first widely used standard |
| 802.11a | 1999 | 5 GHz | 54 Mbps | Not compatible with b |
| 802.11g | 2003 | 2.4 GHz | 54 Mbps | Backward compatible with b |
| 802.11n (Wi-Fi 4) | 2009 | 2.4/5 GHz | 600 Mbps | MIMO technology |
| 802.11ac (Wi-Fi 5) | 2014 | 5 GHz | 3.5 Gbps | Wider channels, more MIMO |
| 802.11ax (Wi-Fi 6) | 2019 | 2.4/5 GHz | 9.6 Gbps | OFDMA, higher density |
The 802.11 Frame
An 802.11 frame is more complex than an Ethernet frame and contains up to four address fields, because the wireless environment requires distinguishing the transmitter, the receiver, the source, and the destination:
802.11 Frame Structure
An 802.11 frame carries up to four address fields to distinguish the receiver, the transmitter, the source, and the destination in a wireless environment
- Address 1: the receiver address (RA, Receiver Address)
- Address 2: the transmitter address (TA, Transmitter Address)
- Address 3: the source address (SA) or the destination address (DA), depending on the frame type
- Address 4: used only in a Wireless Distribution System (WDS)
Operating Modes
- Infrastructure mode: all stations communicate through an AP (Access Point), which connects to the wired network. This is the most common mode.
- Ad Hoc mode: stations communicate directly with each other without an AP. Also called an IBSS (Independent BSS).
Wi-Fi Security
- WEP (Wired Equivalent Privacy): the earliest encryption standard, based on RC4. It has been broken and is not secure.
- WPA (Wi-Fi Protected Access): an improved version of WEP using TKIP encryption
- WPA2: the current mainstream standard, using AES encryption (CCMP), with strong security
- WPA3: the newest standard, further strengthening security and supporting 192-bit encryption
The PPP Protocol
PPP is a data link layer protocol that carries network layer data over point-to-point links. It is widely used for dial-up access, DSL, and leased lines.
Definition
A definition is a precise description of what a concept, a term, or an object means. Understanding definitions is the foundation of learning any field, and every concept has its own exact meaning.
PPP is a byte-oriented data link layer protocol that transfers data over a point-to-point link between two nodes. It supports multiple network layer protocols (IP, IPX, and so on) and provides authentication, compression, and error detection.
The PPP Frame
PPP Frame Structure
PPP frame: the flag field is 0x7E, and the protocol field indicates the payload type (for example 0x0021 = IPv4)
- Flag field:
0x7E, the frame delimiter (the same as HDLC) - Address field:
0xFF, the broadcast address (PPP is point-to-point, so it has no real meaning) - Control field:
0x03, an unnumbered frame (UI) - Protocol field: indicates the protocol type of the data field (for example
0x0021= IPv4,0xC021= LCP,0x8021= IPCP) - FCS: usually 2 bytes (it can also be negotiated as 4 bytes), a CRC check
The PPP Phases
Establishing and maintaining a PPP link goes through four phases:
- Link establishment: LCP (Link Control Protocol) negotiates link parameters such as the maximum receive unit (MRU), the authentication protocol, and the compression protocol
- Authentication (optional): PAP (Password Authentication Protocol) or CHAP (Challenge Handshake Authentication Protocol) performs the authentication
- PAP: a two-way handshake that sends the password in clear text, so it is weak
- CHAP: a three-way handshake that uses an MD5 hash and never transmits the password in clear text, so it is strong
- Network layer protocol: NCP (Network Control Protocol) configures parameters for each network layer protocol. IPCP (IP Control Protocol), for example, assigns IP addresses.
- Data transfer: network layer data is transferred normally
- Link termination: LCP terminates the link
PPP is designed to be very flexible: LCP handles link layer parameter negotiation and NCP handles network layer parameter negotiation, and the two are decoupled. This allows PPP to support any network layer protocol, provided a matching NCP is defined.
The HDLC Protocol
HDLC is a bit-oriented data link layer protocol standardized by the ISO, and it is the basis for many other link layer protocols such as PPP, LAPB, and LAPD.
The HDLC Frame
HDLC Frame Structure
HDLC frame: the flag field is 0x7E (01111110), and bit stuffing keeps that pattern out of the data
- Flag field:
0x7E(01111110), with bit stuffing guaranteeing that the pattern never appears in the data - Address field: identifies the secondary station (in multipoint connections); usually
0xFFin point-to-point links - Control field: identifies the frame type and the sequence numbers
- FCS: 2 or 4 bytes, a CRC check
HDLC Frame Types
According to the format of the control field, HDLC frames fall into three categories:
-
Information frames (I-frame, Information): the first bit of the control field is 0
- carry user data
- contain the send sequence number N(S) and the receive sequence number N(R)
- can piggyback an acknowledgment (N(R) indicates the sequence number of the next frame expected)
-
Supervisory frames (S-frame): the first two bits of the control field are
10- carry no data and are used for flow control and error control
- four types: RR (receive ready, ACK), RNR (receive not ready), REJ (reject, GBN), SREJ (selective reject, SR)
-
Unnumbered frames (U-frame): the first two bits of the control field are
11- contain no sequence numbers and are used for link management
- such as SABM (set asynchronous balanced mode), UA (unnumbered acknowledgment), and DISC (disconnect)
HDLC Operating Modes
- Normal Response Mode (NRM): a master/slave mode in which a secondary station may transmit only after being polled by the primary
- Asynchronous Response Mode (ARM): a secondary station may transmit on its own initiative, but the primary still manages the link
- Asynchronous Balanced Mode (ABM): a peer mode in which the two stations have equal standing and either may initiate a transmission. PPP uses a mode similar to ABM.
Bridge
- Operates at the data link layer and forwards frames based on MAC addresses
- Usually has only 2 ports, used to connect two LAN segments
- Learns the MAC address table automatically and isolates collision domains
- Uses store-and-forward, so it forwards more slowly
Switch
- Operates at the data link layer (a layer 2 switch) and is essentially a multi-port bridge
- Forwards frames based on MAC addresses, and each port is an independent collision domain
- Supports both store-and-forward and cut-through forwarding
- Supports advanced features such as VLANs, QoS, and port aggregation
- Is the core device of a modern LAN
Keep the two apart: a hub operates at the physical layer, all of its ports share one collision domain, and it works in half-duplex mode; a switch operates at the data link layer, each port is an independent collision domain, and it works in full-duplex mode.
Example 1: Ethernet Frame Padding
The data field of an Ethernet frame is only 20 bytes. How many bytes of padding are needed, and what is the total length of the frame?
Approach: compare the data field against the 46-byte minimum and add up header, data (with padding), and FCS.
Steps:
- The Ethernet data field must be at least 46 bytes (so that the minimum frame length is 64 bytes)
- The data is currently 20 bytes, so the padding needed is: bytes
- The Ethernet frame header (destination MAC + source MAC + type) = 6+6+2 = 14 bytes
- FCS = 4 bytes
- Total length = 14 (header) + 46 (data plus padding) + 4 (FCS) = 64 bytes
Note that the preamble (7 bytes) and the SFD (1 byte) are normally not counted in the frame length.
Answer: 26 bytes of padding are needed and the total frame length is 64 bytes (the minimum frame length).
Example 2: Analyzing the PPP Protocol
During the establishment of a PPP link, what is LCP responsible for and what is NCP responsible for? If a PPP connection carries only IPv4 data, which protocols are involved?
Approach: separate the responsibilities of LCP and NCP, then list the protocols needed for an IPv4-only connection.
Steps:
-
LCP (Link Control Protocol) is responsible for data link layer parameter negotiation and link management, including:
- maximum receive unit (MRU) negotiation
- authentication protocol negotiation (PAP/CHAP)
- compression protocol negotiation
- link quality monitoring
- link establishment and termination
-
NCP (Network Control Protocol) is responsible for configuring network layer parameters, with one NCP per network layer protocol:
- IPCP (IP Control Protocol): configures the IP address, DNS, and so on
- IPXCP: configures the IPX protocol
- IPv6CP: configures IPv6
-
If only IPv4 is carried, the protocols needed are:
- LCP: link layer parameter negotiation
- an authentication protocol (optional): PAP or CHAP
- IPCP: IP address assignment and configuration
- IPv4: data transmission
Answer: LCP handles link layer parameter negotiation and NCP handles network layer parameter configuration. An IPv4-only connection needs LCP, an optional authentication protocol, IPCP, and IPv4.
Example 3: MAC Addresses and Broadcast
The destination MAC address of an Ethernet frame is FF:FF:FF:FF:FF:FF. What kind of address is this, and which stations receive the frame?
Approach: identify the address pattern, then trace how the frame propagates in shared and switched Ethernet.
Steps:
FF:FF:FF:FF:FF:FFis the broadcast address (all bits set to 1).- A broadcast frame is received and processed by every station in the same broadcast domain.
- In traditional shared Ethernet (connected through hubs), all stations are in the same broadcast domain and the same collision domain.
- In switched Ethernet, the switch floods the broadcast frame out of every port except the one it arrived on, so every station attached to the same switch (or the same VLAN) receives it.
- Routers do not forward broadcast frames (a router isolates broadcast domains), so a broadcast never crosses a network segment boundary.
Answer: this is the broadcast address, and it is received by every station in the same broadcast domain. Because routers do not forward broadcast frames, broadcast traffic stays local to the segment.
Exercise 1
Compare the PPP and HDLC protocols.
Approach: list the shared properties first, then the seven points on which the two protocols differ.
Steps:
Shared properties:
- Both are data link layer protocols and both support point-to-point connections
- Both use
0x7Eas the frame delimiter and use bit stuffing (PPP in asynchronous mode also supports character stuffing) - Both provide error detection (FCS/CRC)
- Both have similar frame structures (flag, address, control, data, FCS)
Differences:
- Orientation: PPP is byte-oriented, HDLC is bit-oriented
- Complexity: PPP is simple and flexible, HDLC is more capable but more complex
- Connection types: PPP mainly supports point-to-point, HDLC supports both point-to-point and multipoint
- Authentication: PPP supports PAP/CHAP authentication, HDLC does not
- Multi-protocol support: PPP supports multiple network layer protocols through NCP, HDLC is independent of the network layer protocol
- Sequence numbers: HDLC has a complete sequence number and acknowledgment mechanism (I-frames and S-frames), whereas PPP provides no reliable transmission by default (a reliable transmission mode is optional)
- Applications: PPP is used for dial-up, DSL, and leased lines; HDLC was used in early leased-line networks and in the serial links of Cisco routers (Cisco HDLC)
Answer: both are data link layer protocols with similar framing and error detection, but PPP is byte-oriented, simpler, and adds authentication and NCP-based multi-protocol support, while HDLC is bit-oriented, more complex, and provides full sequence number and acknowledgment mechanisms.
Exercise 2
What are the main differences between an Ethernet switch and a hub, and why did the switch replace the hub?
Approach: compare the two devices on six properties, then list the five reasons the switch took over.
Steps:
Main differences:
- Layer: a hub operates at the physical layer, a switch operates at the data link layer
- Collision domains: all ports of a hub share one collision domain, while each port of a switch is an independent collision domain
- Duplex: a hub is half-duplex only, a switch supports full duplex
- Forwarding: a hub broadcasts the signal to all ports, while a switch forwards to the specific port found in its MAC address table
- Bandwidth: all ports of a hub share the total bandwidth, while each port of a switch has its own bandwidth
- Features: a hub only amplifies and repeats the signal, while a switch supports MAC address learning, VLANs, QoS, and so on
Why the switch replaced the hub:
- Higher performance: full duplex, independent collision domains, and parallel transmission greatly increase network throughput
- Fewer collisions: each port is an independent collision domain, which avoids the collision overhead of CSMA/CD
- Better security: unicast frames are forwarded only to the destination port, so other ports cannot eavesdrop
- Richer features: VLANs isolate broadcast domains, QoS provides priority, and port aggregation is supported
- Lower cost: as the technology matured, switch prices fell to an acceptable level
Answer: a switch forwards at layer 2 with per-port bandwidth and full duplex, while a hub simply repeats a layer 1 signal to every port sharing one collision domain; the switch’s throughput, isolation, and feature set made the hub obsolete.
| Term | Abbreviation | Explanation |
|---|---|---|
| Media Access Control Address | MAC | A 48-bit physical address |
| Ethernet | - | The most widely deployed LAN technology |
| Frame Check Sequence | FCS | The CRC check field of a frame |
| Maximum Transmission Unit | MTU | The maximum length of the data field |
| Virtual LAN | VLAN | A logical division of broadcast domains |
| Access Point | AP | The central device of a wireless LAN |
| Point-to-Point Protocol | PPP | A point-to-point link layer protocol |
| Link Control Protocol | LCP | PPP link parameter negotiation |
| Network Control Protocol | NCP | PPP network layer parameter negotiation |
| Challenge Handshake Auth Protocol | CHAP | Secure authentication in PPP |
| High-level Data Link Control | HDLC | A bit-oriented link layer protocol |
| Service Set Identifier | SSID | The name of a Wi-Fi network |
| CSMA with Collision Avoidance | CSMA/CA | The MAC protocol of wireless LANs |
| Bridge | - | A two-port layer 2 forwarding device |
| Switch | - | A multi-port layer 2 forwarding device |
| Hub | - | A physical layer shared device |
| Preamble | - | The synchronization field of an Ethernet frame |
| Start Frame Delimiter | SFD | The start-of-frame marker of an Ethernet frame |
