Route and Switch

Routing and switching are fundamental concepts in computer networking that enable data communication across networks. Understanding these technologies is essential for network engineers and IT professionals working with network infrastructure.

1. Switching Fundamentals

What is Switching?

Switching is the process of forwarding data frames within a local area network (LAN) based on MAC addresses. Switches operate at Layer 2 (Data Link Layer) of the OSI model and create collision domains for each port.

Switch Operations

  • Learning: Building MAC address table by examining source addresses
  • Flooding: Broadcasting frames when destination is unknown
  • Forwarding: Sending frames to specific ports based on MAC table
  • Filtering: Dropping frames destined for the same segment
  • Aging: Removing old entries from MAC address table

Switch Types

  • Unmanaged Switches: Basic plug-and-play functionality
  • Managed Switches: Configuration capabilities, VLANs, QoS
  • Smart/Web Managed: Limited management through web interface
  • Layer 3 Switches: Routing capabilities at wire speed

2. Virtual LANs (VLANs)

VLAN Concepts

  • Logical Segmentation: Separate broadcast domains on same physical switch
  • VLAN ID: 12-bit identifier (1-4094, with 1 and 4094 reserved)
  • Default VLAN: VLAN 1, cannot be deleted
  • Native VLAN: Untagged traffic on trunk ports

VLAN Types

  • Data VLAN: User traffic
  • Management VLAN: Switch management traffic
  • Voice VLAN: VoIP traffic with QoS priority
  • Native VLAN: Untagged frames on trunk links

VLAN Trunking

  • 802.1Q: Industry standard VLAN tagging
  • ISL (Inter-Switch Link): Cisco proprietary (deprecated)
  • Trunk Ports: Carry multiple VLANs
  • Access Ports: Belong to single VLAN

3. Spanning Tree Protocol (STP)

STP Purpose

  • Loop Prevention: Prevents Layer 2 loops in redundant topologies
  • Redundancy: Provides backup paths for fault tolerance
  • Convergence: Recalculates topology when changes occur

STP Variants

  • STP (802.1D): Original standard, slow convergence (30-50 seconds)
  • RSTP (802.1w): Rapid convergence (1-6 seconds)
  • MSTP (802.1s): Multiple spanning trees for VLAN load balancing
  • PVST+: Cisco per-VLAN spanning tree
  • Rapid PVST+: Cisco rapid per-VLAN spanning tree

STP Port States

  • Blocking: Receives BPDUs, blocks data traffic
  • Listening: Processes BPDUs, prepares to forward
  • Learning: Builds MAC address table
  • Forwarding: Normal operation, forwards traffic
  • Disabled: Port administratively down

4. Routing Fundamentals

What is Routing?

Routing is the process of forwarding packets between different networks based on IP addresses. Routers operate at Layer 3 (Network Layer) and make forwarding decisions using routing tables.

Routing Process

  1. Packet Reception: Router receives packet on interface
  2. Destination Analysis: Examines destination IP address
  3. Route Lookup: Searches routing table for best match
  4. Forwarding Decision: Determines next-hop and exit interface
  5. Packet Forwarding: Sends packet toward destination

Routing Table Components

  • Destination Network: Target network address
  • Subnet Mask: Network portion identifier
  • Next Hop: Next router in path
  • Exit Interface: Outgoing interface
  • Administrative Distance: Route trustworthiness
  • Metric: Route cost or preference

5. Static vs Dynamic Routing

Static Routing

  • Manual Configuration: Administrator defines routes
  • Advantages: Predictable, secure, no overhead
  • Disadvantages: No automatic adaptation, scalability issues
  • Use Cases: Small networks, stub networks, default routes

Dynamic Routing

  • Automatic Discovery: Protocols learn network topology
  • Advantages: Automatic adaptation, scalability
  • Disadvantages: Protocol overhead, complexity
  • Use Cases: Large networks, redundant paths

6. Routing Protocols

Distance Vector Protocols

  • RIP (Routing Information Protocol)
    • Metric: Hop count (max 15)
    • Updates: Every 30 seconds
    • Convergence: Slow
    • Use: Small networks
  • EIGRP (Enhanced Interior Gateway Routing Protocol)
    • Metric: Composite (bandwidth, delay, reliability, load)
    • Updates: Triggered
    • Convergence: Fast
    • Vendor: Cisco proprietary

Link State Protocols

  • OSPF (Open Shortest Path First)
    • Algorithm: Dijkstra's SPF
    • Metric: Cost (based on bandwidth)
    • Scalability: Areas for hierarchy
    • Standard: RFC 2328
  • IS-IS (Intermediate System to Intermediate System)
    • Protocol: ISO standard
    • Levels: Level 1 and Level 2
    • Use: Service provider networks

Path Vector Protocols

  • BGP (Border Gateway Protocol)
    • Scope: Inter-domain routing
    • Attributes: AS-path, next-hop, local preference
    • Policy: Extensive policy control
    • Use: Internet backbone, enterprise multi-homing

7. OSPF Deep Dive

OSPF Areas

  • Backbone Area (Area 0): Central area, all other areas connect
  • Standard Areas: Normal OSPF operation
  • Stub Areas: No external routes
  • Totally Stubby Areas: No external or inter-area routes
  • NSSA: Not-So-Stubby Area, limited external routes

OSPF Router Types

  • Internal Router: All interfaces in same area
  • Area Border Router (ABR): Connects multiple areas
  • Autonomous System Boundary Router (ASBR): Injects external routes
  • Backbone Router: Has interface in Area 0

OSPF LSA Types

  • Type 1 (Router LSA): Router's links within area
  • Type 2 (Network LSA): Multi-access network information
  • Type 3 (Summary LSA): Inter-area routes
  • Type 4 (ASBR Summary): ASBR location
  • Type 5 (External LSA): External routes
  • Type 7 (NSSA External): External routes in NSSA

8. BGP Fundamentals

BGP Sessions

  • eBGP (External BGP): Between different autonomous systems
  • iBGP (Internal BGP): Within same autonomous system
  • Peering: TCP connection on port 179
  • Route Reflectors: Solve iBGP full mesh requirement

BGP Attributes

  • Well-known Mandatory: AS-path, next-hop, origin
  • Well-known Discretionary: Local preference, atomic aggregate
  • Optional Transitive: Community, aggregator
  • Optional Non-transitive: MED, originator ID

BGP Path Selection

  1. Highest weight (Cisco proprietary)
  2. Highest local preference
  3. Locally originated routes
  4. Shortest AS-path
  5. Lowest origin code
  6. Lowest MED
  7. eBGP over iBGP
  8. Lowest IGP metric to next-hop
  9. Oldest route
  10. Lowest router ID

9. Quality of Service (QoS)

QoS Models

  • Best Effort: No guarantees, default behavior
  • Integrated Services (IntServ): Per-flow reservations
  • Differentiated Services (DiffServ): Class-based treatment

QoS Mechanisms

  • Classification: Identifying traffic types
  • Marking: DSCP, IP precedence, CoS
  • Queuing: FIFO, PQ, WFQ, CBWFQ
  • Shaping: Rate limiting traffic
  • Policing: Enforcing rate limits
  • Congestion Avoidance: WRED, ECN

10. Network Security

Access Control Lists (ACLs)

  • Standard ACLs: Source IP address only
  • Extended ACLs: Source, destination, protocol, ports
  • Named ACLs: Descriptive names, easier management
  • Placement: Standard close to destination, extended close to source

Port Security

  • MAC Address Limiting: Restrict number of MAC addresses
  • Violation Actions: Protect, restrict, shutdown
  • Sticky Learning: Dynamically learned addresses become static

DHCP Snooping

  • Trusted Ports: Legitimate DHCP servers
  • Untrusted Ports: Client-facing ports
  • Binding Table: MAC-IP-VLAN-Port mappings
  • Protection: DHCP starvation, rogue DHCP servers

11. Network Troubleshooting

Troubleshooting Methodology

  1. Problem Identification: Define the issue clearly
  2. Information Gathering: Collect relevant data
  3. Hypothesis Formation: Develop possible causes
  4. Testing: Verify hypotheses systematically
  5. Resolution: Implement solution
  6. Documentation: Record findings and solution

Common Tools

  • ping: Connectivity testing
  • traceroute: Path discovery
  • show commands: Device status and configuration
  • debug commands: Real-time protocol analysis
  • Wireshark: Packet capture and analysis
  • SNMP monitoring: Performance metrics

Layer-by-Layer Approach

  • Physical Layer: Cable, connectors, link lights
  • Data Link Layer: Frame errors, MAC addresses
  • Network Layer: IP addressing, routing
  • Transport Layer: Port numbers, TCP/UDP
  • Application Layer: Service-specific issues

12. Modern Networking Trends

Software-Defined Networking (SDN)

  • Centralized Control: Controller manages network behavior
  • Programmability: Network behavior defined by software
  • Abstraction: Separation of control and data planes
  • Protocols: OpenFlow, NETCONF, RESTCONF

Network Automation

  • Configuration Management: Ansible, Puppet, Chef
  • Network APIs: REST, NETCONF, gRPC
  • Intent-Based Networking: Policy-driven automation
  • DevOps Integration: Infrastructure as Code

Cloud Networking

  • Virtual Private Clouds: Isolated cloud networks
  • Hybrid Connectivity: VPN, Direct Connect
  • Container Networking: Kubernetes, Docker
  • Service Mesh: Microservices communication

13. Best Practices

  • Network Design: Hierarchical design, redundancy planning
  • Documentation: Network diagrams, IP addressing schemes
  • Change Management: Controlled configuration changes
  • Monitoring: Proactive network monitoring
  • Security: Defense in depth, regular updates
  • Backup: Configuration backups, disaster recovery
  • Training: Continuous learning, certification