Host Communication Flow

主機間通訊流程範例,說明同網路和跨網路的通訊過程。

Part 1 - 同網路通訊

Hosts communicating to another host in the same network.

  flowchart LR
    A[Host_A] ----> B[Host_B]

Host A and B are directly connected:

  • Both hosts have a NIC, and therefore a MAC address
  • Both hosts are configured with an IP address and a Subnet Mask
  • Subnet Mask identifies the size of the IP network

通訊流程

Host A has some Data to send to Host B:

  • Host A knows the IP address of Host B (e.g., user typed ping 10.1.1.33)
  • IP address may be acquired from DNS (www.example.com192.249.124.38)
  • Host A knows 10.1.1.33 is in its own IP Network
  • Host A can create the L3 Header to attach to the Data
  • Host A doesn’t know Host B’s MAC address → Must use ARP
Communicate Flow 1

ARP Request

Host A uses ARP to resolve target’s MAC address:

  • ARP request asks for the MAC address associated with target IP
  • ARP request includes sender’s MAC address
  • ARP request is a Broadcast: sent to everyone in the network
    • Destination MAC address: ffff.ffff.ffff
    • Reserved MAC address to send a packet to everyone on the local network
Communicate Flow 2

ARP Response

  • ARP mappings are stored in an ARP Cache
  • Host B responds by sending an ARP Response
  • Response is sent Unicast (directly to Host A)
  • Host A populates its ARP cache with Host B’s IP/MAC mapping
Communicate Flow 3

Data Transmission

  • Host A creates L2 Header: SRC a2a2 DST b3b3
  • Data is sent to Host B
  • L2 header is discarded
  • L3 header is discarded
Communicate Flow 4

Key Points

  • Steps a Host takes when speaking to another host on the same network
  • Steps are the same regardless of whether there are switches or hubs
  • ARP links a L3 address to a L2 address

Part 2 - 跨網路通訊

Hosts communicating to another host in a foreign network.

  flowchart LR
    A[Host_A] ---> Router ----> B[Host_B]

判斷目標網路

Host A - First Step always the same:

  • Determine if target IP is on local or foreign network
    • Foreign: ARP for Default Gateway IP
    • Local: ARP for Target IP

Host A, Host C, and the Router have MAC and IP address (/24 is Subnet Mask - 255.255.255.0).

Part 2 - Step 1

ARP for Gateway

Host A uses ARP to resolve the MAC address of the Router’s IP. Router IP address is configured as the Default Gateway.

Part 2 - Step 2

Router Response

Part 2 - Step 3

Data Sent to Router

  • Data is sent to the Router
  • L2 header is discarded
  • Router takes over from this point
  • Host A’s job is done
Part 2 - Step 4

Reuse Router ARP Mapping

ARP mapping can be used for ANY host in foreign networks.

Part 2 - Step 5

連接網際網路的三要素

Three things to configure for Internet connectivity:

Internet Connectivity
  1. IP Address - 裝置的網路位址
  2. Subnet Mask - 判斷本地或遠端網路
  3. Default Gateway - 連接外部網路的路由器