Introduction to TCP/IP (Part 1) - Routers, Switches and Addressing

Source: Microchip Developer Help

Routers in Local Networks

image

Routers connect one network to another. They:

What is an IP Address?

image

IP addresses uniquely identify every host (network node) on a TCP/IP network.

IPv4 vs IPv6

Version Address Size Total Addresses
IPv4 32-bit (4 octets) ~4.3 billion (about 1 per person)
IPv6 128-bit (8 x 16-bit fields) 3.4 × 10³⁸ (5 × 10²⁸ per person)

Obtaining IP Addresses (DHCP Process)

When a device connects to a network, it automatically requests an IP address from the router.

Step 1: PC Generates Request for IP Address

image

Step 2: IP Address Request Received in Router

Step 3: Router Offers an IP Address to the PC

image

Step 4: PC Receives and Configures IP Address

image

Switches in Local Networks

image

A switch enables connection of multiple devices to the same network.

Switches Inside Routers

image

Most home/small business routers have a built-in switch.

Ref: https://labs.iximiuz.com/courses/computer-networking-fundamentals/bridge-vs-switch

Switches use MAC Addresses

image

Switches use Media Access Controller (MAC) addresses to forward and filter data.

Two Addresses per Network Host

Address Type Layer Description
IP Address Layer 3 Virtual address
MAC Address Layer 2 Physical address

Key Differences: Switches vs Routers

Device Layer Address Type MAC Address?
Switch Layer 2 MAC only No (transparent to network)
Router Layer 3 IP Yes - two: LAN and WAN

Switches vs Routers

Gemini

image

image

Ref: https://www.conceptdraw.com/examples/block-diagram-of-a-computer-network-with-8-computer-switch-router-1-lan-printer

image

image

image

image

image

Ref: https://labs.iximiuz.com/courses/computer-networking-fundamentals/bridge-vs-switch

MAC Functions

What is a MAC Address?

A MAC (Media Access Control) address is a unique 48-bit identifier assigned to a network interface controller (NIC) for hardware identification on a network.

image

Switch Operation on a Local Network

A switch uses a routing table to associate port numbers with MAC addresses.

Step 1: PC Sends a Frame to the Switch

image

Step 2: Switch Receives Frame

image

Step 3: Switch Broadcasts Frame to All Nodes

image

Step 4: Router Sends Reply to PC

image

Step 5: Switch Forwards Frame to PC

image

Example: Simplified Local Network TCP/IP Communication

image

Scenario

Step 1: Open Web Browser and Enter Development Board’s IP Address

image

Step 2: PC Generates and Transmits a Frame

image

Step 3: Frame is Forwarded Through the Switch

image

Step 4: Frame Arrives at Development Board

image

  1. Destination MAC address checked → matches device’s MAC
  2. Frame opened, destination IP address checked → matches device’s IP
  3. Packet opened to see message → destined for web server
  4. Message sent to web server application

Filtering at each layer:

image

Step 5: Web Server Sends the Webpage to the PC

  1. Web server generates message containing the web page
  2. Source/destination IP addresses added → packet
  3. Source/destination MAC addresses added → frame
  4. Frame sent to PHY for transmission
  5. Switch forwards to PC using routing table
  6. PC opens frame, checks MAC, opens packet, checks IP
  7. PC opens message and receives the HTML file

Question: What happens next? Answer:

The frame is received at the switch.
The switch finds the frame’s destination MAC address and uses its routing table to determine what port to forward the frame to.
The frame is sent to the PC
The PC opens the frame and checks the destination MAC address to determine if it needs to pay attention to it.
The PC opens the packet and checks the destination IP address.
The PC opens the message and finds the web page (which is just an HTML file) it requested.

Learn More