Data Communication Components · Computer Networks

Virtual LANs (VLANs)

Watch lectures
SVGVector Architecture Diagram (SVG)
COMPUTER NETWORKS · Module 1★ High PriorityVirtual LANs (VLANs)IT Sem 6 · Code 100602 · Broadcast domains by software, 802.1Q trunksMNEMONICVLAN = software broadcast domain. Access port = 1 VLAN, trunk port = many, tagged by 802.1Q.802.1Q adds 4 bytes: TPID 0x8100 + 3-bit priority + 1-bit DEI + 12-bit VID.Core BreakdownConceptA logical subnet grouping devices from any floor into one broadcast domain.Defined in software on the switch, not by physical cabling.WhyBroadcast containment (ARP, DHCP stay in the VLAN), security by isolation,lower cost: no extra switches or cables when teams move.MembershipPort-based (static), MAC-based (dynamic), protocol-based, IP subnet-based.Dynamic MAC-based lets a laptop keep its VLAN at any port.PortsAccess port: one VLAN, untagged frames to end hosts.Trunk port: many VLANs between switches or to a router, frames tagged.802.1Q tag4-byte tag between Source MAC and Type: TPID 0x8100 (2 B) + TCI (2 B).TCI = Priority 3 b + DEI 1 b + VID 12 b: 4096 IDs, 1-4094 usable.Inter-VLANDifferent VLANs cannot talk without a Layer 3 device.Router-on-a-stick: one trunk with sub-interfaces; or an L3 switch with SVIs.Diagram: VLANs, Trunk and TagSwitchHost AVLAN 10Host BVLAN 20Host CVLAN 10Host DVLAN 20Switch 1Switch 2trunktagged 10, 20802.1Q tagged frame:DstSrcTag 4BTypeDataFCSTag = TPID 0x8100|Pri 3|DEI 1|VID 12Router-on-a-stick: sub-interface/VLAN⚠️ Exam Traps & Viva Favorites① Access vs trunk port?Access: one VLAN, untagged frames to a host.Trunk: carries several VLANs between switchesor to a router, using 802.1Q tags.② How many VLANs in 802.1Q?The VID is 12 bits, so 2^12 = 4096 IDs. 0 and 4095are reserved, leaving 1 to 4094 for real VLANs.③ Different VLANs, no router?Impossible. Each VLAN is its own Layer 2 domainand subnet; a router or multilayer switch mustroute between them (router-on-a-stick, SVI).Tip: VID 12 bits = 4096 VLANsMaster Revision Table(learn it row by row!)ItemAccess portTrunk portNoteVLANs carriedOneManyTrunk = multiplexed VLAN trafficFrame typeStandard, untagged802.1Q taggedTag inserted after Source MACConnects toEnd host / PCSwitch or routerRouter-on-a-stick uses a trunkTag sizeNone4 bytesTPID 2 B + TCI 2 BVLAN IDSet by port configVID in tag, 12 bits1 to 4094 usableInter-VLANNot possible aloneNeeds Layer 3Router sub-interfaces or SVIQUICK FACTSExample: ports 1-8 = VLAN 10 Engineering, ports 9-16 = VLAN 20 HR · each VLAN = one subnetRouter sub-interfaces Gig0/0.10 and Gig0/0.20 route VLAN 10 and VLAN 20Standard frame 6 + 6 + 2 + data + 4 FCS grows by 4 bytes when taggedVERIFIED★ Golden rule: VLANs isolate at Layer 2,only Layer 3 connects them.

Virtual Local Area Networks (VLANs)


1. Concept and Motivation of VLANs

A Virtual Local Area Network (VLAN) is a logical subnetwork that groups together a collection of devices from different physical LAN segments into a single broadcast domain, regardless of their physical location.

MermaidDiagram
Rendering diagram…

Key Motivations:

  1. Broadcast Containment: Broadcast traffic from one department (e.g., ARP, DHCP) does not flood users in other departments.
  2. Security: Logical isolation prevents unauthorized eavesdropping between sensitive subnets (e.g., Finance isolated from Guest Wi-Fi).
  3. Cost Reduction & Flexibility: Eliminates the need to run separate physical switches and cables when teams relocate within a building.

2. VLAN Membership Types

Switches assign switch ports to VLANs using several mechanisms:

  1. Port-Based (Static VLAN):
    • Network administrator manually assigns physical ports to a specific VLAN ID (e.g., Ports 1–8 = VLAN 10, Ports 9–16 = VLAN 20).
    • Most common, secure, and easiest to manage.
  2. MAC Address-Based (Dynamic VLAN):
    • Membership is based on the 48-bit MAC address of the connected host. If a user moves their laptop to a different desk/port, the switch automatically assigns that port to the user's VLAN.
  3. Protocol-Based:
    • Packets are segregated into VLANs based on the protocol carried in the Layer 3 header (e.g., IPv4 vs IPv6 vs IPX).
  4. IP Subnet-Based:
    • Frames are assigned to VLANs based on the sender's Layer 3 IP subnet.

3. Trunking and IEEE 802.1Q Frame Tagging

When VLAN traffic must traverse across multiple interconnected switches, a Trunk Link is used.

MermaidDiagram
Rendering diagram…
  • Access Port: Carries traffic for only one specific VLAN. Frames sent to end-user workstations are standard Ethernet frames (untagged).
  • Trunk Port: Carries traffic for multiple VLANs simultaneously between switches or between a switch and a router.

IEEE 802.1Q Frame Format:

The IEEE 802.1Q standard inserts a 4-byte VLAN Tag into the standard Ethernet frame between the Source MAC Address and the Length/Type field:

SVGVector Architecture Diagram (SVG)
Standard Ethernet Frame: Dest MAC Src MAC Type/Len Data Payload FCS 6 bytes 6 bytes 2 bytes 46-1500 bytes 4 bytes Inserts 4-byte 802.1Q Tag Tagged 802.1Q Ethernet Frame: Dest MAC Src MAC 802.1Q Tag Type/Len Data Payload FCS 6 bytes 6 bytes 4 bytes 2 bytes 46-1500 bytes 4 bytes TPID (2 bytes) 0x8100 TCI (2 bytes) Pri 3 bits | DEI 1 bit | VID 12 bits
  • TPID (Tag Protocol Identifier - 2 bytes): Fixed value 0x8100 identifying the frame as 802.1Q-tagged.
  • TCI (Tag Control Information - 2 bytes):
    • Priority (3 bits): Quality of Service (QoS / 802.1p) marking 8 priority levels (0 to 7) for voice/video.
    • DEI (Drop Eligible Indicator - 1 bit): May be dropped during network congestion.
    • VID (VLAN Identifier - 12 bits): Identifies the VLAN (212=40962^{12} = 4096 possible VLANs, values 1−40941 - 4094 usable).

4. Inter-VLAN Routing

Because each VLAN is an independent Layer 2 broadcast domain and logical subnet, devices in different VLANs cannot communicate without a Layer 3 routing device.

MermaidDiagram
Rendering diagram…
  1. Router-on-a-Stick:
    • A single physical trunk cable connects the switch to a router interface.
    • The router configures logical sub-interfaces (e.g., Gig0/0.10 and Gig0/0.20), routing traffic between VLANs across the trunk.
  2. Layer 3 Switch (Multilayer Switch):
    • Modern enterprise solution that performs Inter-VLAN routing at internal backplane wire speed using SVIs (Switch Virtual Interfaces) without an external router.

Frequently Asked Questions

QWhat is the difference between an Access Port and a Trunk Port?
  • An Access port belongs to a single VLAN and sends untagged standard frames to end hosts.
  • A Trunk port interconnects switches or routers, carrying multiplexed traffic for multiple VLANs tagged with IEEE 802.1Q headers.
QHow many VLANs can be identified in IEEE 802.1Q and why?

Up to 40964096 (2122^{12}) VLANs, because the VLAN Identifier (VID) field in the 802.1Q tag is 12 bits wide (VLAN 0 and 4095 are reserved).

QCan hosts in different VLANs communicate without a router?

No. VLANs provide strict Layer 2 broadcast isolation. Passing packets between different VLANs requires a Layer 3 device (Router or Multilayer Switch).

QWhat is router-on-a-stick?

A single trunk link connects a switch to one router interface. The router uses logical sub-interfaces (e.g., Gig0/0.10, Gig0/0.20), one per VLAN, to route traffic between VLANs.

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Computer Networks modules