How Two Node Communicate To Eachother
A host is basically a computer in a network.
On internal network


Note: In this example there will be multiple router or different devices in between. It doesn't matter, the process will be the same
There are a few key things
- Both host will have a NIC (Network interface card) which will have the MAC address
- Both host are configured with IP address and a subnet mask
- Subnet Mask is to identifies the size of the IP network
Host Awill know the IP address ofHost B(10.1.1.33)- Maybe the user give to it (i.e
ping) - Maybe DNS (Domain Name System) Protocol
- Maybe the user give to it (i.e
Host Awill know that10.1.1.33is in the same IP network. It knows by calculating its IP address and the Subnet Mask to see if10.1.1.33is within the same network- Since
Host AknowsHost Bip address, it will create aLayer 3 Header:src: 10.1.1.22dst: 10.1.1.33
- Since
Layer3cannot communicate over the wired,Host Aneeds to add aLayer 2 Header. HoweverHost Adoes not knowHost Bmac address. - Therefore
Host Awill use ARP (Address Resolution Protocol) to find out the MAC address ofHost B.- It shoots out the
ARPrequest (Layer 2).- Which has the IP address it's looking for:
10.1.1.33 Host AIP address and Mac address:10.1.1.22anda2a2
- Which has the IP address it's looking for:
ARPrequest is sent as a Broadcast via Broadcast address.- This will send the packet to everyone on the local network
- This can be go through a switch or a medium that connect all the device together.
Host Bwill prepare anARPresponse with its MAC addressb3b3so thatHost Awill know.ARPis Unicast, so therefore only it only send toHost A.- It also updated the
ARPtable becauseHost Aalready provided its mac address. SoHost BARP Table would be10.1.1.22 -> a2a2
- It also updated the
Host Awill then update itsARPtable with:10.1.1.33 -> b3b3
Host Awill then sendData, L3 Header, L2 HeadertoHost B
- It shoots out the
- Upons packet arrival at
Host Bit will discardL2 HeaderandL3 Headeras it becomes unnecessary data now.
Note: Based on Network Switch > How switch works (L2 switch example), would the switch already have MAC table which should already have Host B MAC address? Why does ARP needed.
- When
Host Aneed to send a packet toHost B, it needs to prepare aL2 Header. The problem isHost Aneeds to know which address to put onL2 Headersince the L2 switch only reads L2 Header. - Since it doesn't know what to put, it needs to send an
ARPrequest even though theHost Bmac address is already in FIB (Forwarding information base) of the switch.
On External network (via router)

- Everything with an IP address will have an
ARPcache, which includes:- Host A,
- Router
- Host C
Host Ahas the ip address it wants to speak to10.9.9.44. Based on its subnet information, it knows that this IP address is not in the same network.Host Awill create aL3header:src: 10.1.1.22dst: 10.9.9.44
Host Athen create aL2header, the purpose of this is for us to deliver the packet from Hop to hop- Since this packet goes outside of the network, the next hop should be the router.
- Since
Host A,ARPtable is empty, it doesn't know the MAC address of the router.- It will send the
ARPrequest looking for10.1.1.1, it knows this IP because of it's configured Default Gateway - This will go through the Broadcast address and the Router will respond with its
MAC addressandIP Address(e5e5,10.1.1.1). - At this point the router also will save its IP address into its ARP Table as well (following the exact same process in On internal network)
- It will send the
Host Athen store routerARP entry:10.1.1.1 -> e5e5- Note: this ARP entry will be reuse whenever
Host Awants to talk to external network
Host Athen can prepareLayer 2header:src: a2a2dst: e5e5
Host Athen sendData, L3 Header, L2 HeadertoRouter- Upons receiving,
Routerwill discardL2 Header - Router will add a different
L2 Headerto reach to the next Hop orHost C.