Skip to main content
added 216 characters in body
Source Link
Zac67
  • 88.1k
  • 4
  • 73
  • 137

A router is only used for destination IP addresses that are not in the local network. Assuming you're using 192.168.0.0/24, both addresses are within this subnet and communicate directly over Ethernet.

For this, the source host needs to know the destination's MAC address. IPv4 uses ARP, so the source host sends an ARP request for the destination IP address (as broadcast) and the destination host replies with its MAC address.

ping uses ICMP echo request and reply. The source host forms an IP packet encapsulating the echo request and - since the destination is local - encapsulates this IP packet in an Ethernet frame addressed to the destination's MAC address learned through ARP.

This Ethernet frame is forwarded to the destination's port by the switch, the ICMP echo request discovered and replied to using the same mechanism. ARP isn't required as the destination has already learned the source's MAC from the received traffic.

As Karl's pointed out, DHCP isn't used at all (except for possibly assigning IP addresses to source and destination on startup). Neither is the router/gateway, it's only used to forward IP packets to destinations beyond the local network. For this, the Ethernet frame would be addressed to the gateway, everything else would stay the same.

PS: Actually missed the wireless bit - this is very close to the workings above but instead of Ethernet frames you've got 802.11 frames and instead of a switch there's an access point interconnecting the network.

A router is only used for destination IP addresses that are not in the local network. Assuming you're using 192.168.0.0/24, both addresses are within this subnet and communicate directly over Ethernet.

For this, the source host needs to know the destination's MAC address. IPv4 uses ARP, so the source host sends an ARP request for the destination IP address (as broadcast) and the destination host replies with its MAC address.

ping uses ICMP echo request and reply. The source host forms an IP packet encapsulating the echo request and - since the destination is local - encapsulates this IP packet in an Ethernet frame addressed to the destination's MAC address learned through ARP.

This Ethernet frame is forwarded to the destination's port by the switch, the ICMP echo request discovered and replied to using the same mechanism. ARP isn't required as the destination has already learned the source's MAC from the received traffic.

As Karl's pointed out, DHCP isn't used at all (except for possibly assigning IP addresses to source and destination on startup). Neither is the router/gateway, it's only used to forward IP packets to destinations beyond the local network. For this, the Ethernet frame would be addressed to the gateway, everything else would stay the same.

A router is only used for destination IP addresses that are not in the local network. Assuming you're using 192.168.0.0/24, both addresses are within this subnet and communicate directly over Ethernet.

For this, the source host needs to know the destination's MAC address. IPv4 uses ARP, so the source host sends an ARP request for the destination IP address (as broadcast) and the destination host replies with its MAC address.

ping uses ICMP echo request and reply. The source host forms an IP packet encapsulating the echo request and - since the destination is local - encapsulates this IP packet in an Ethernet frame addressed to the destination's MAC address learned through ARP.

This Ethernet frame is forwarded to the destination's port by the switch, the ICMP echo request discovered and replied to using the same mechanism. ARP isn't required as the destination has already learned the source's MAC from the received traffic.

As Karl's pointed out, DHCP isn't used at all (except for possibly assigning IP addresses to source and destination on startup). Neither is the router/gateway, it's only used to forward IP packets to destinations beyond the local network. For this, the Ethernet frame would be addressed to the gateway, everything else would stay the same.

PS: Actually missed the wireless bit - this is very close to the workings above but instead of Ethernet frames you've got 802.11 frames and instead of a switch there's an access point interconnecting the network.

Source Link
Zac67
  • 88.1k
  • 4
  • 73
  • 137

A router is only used for destination IP addresses that are not in the local network. Assuming you're using 192.168.0.0/24, both addresses are within this subnet and communicate directly over Ethernet.

For this, the source host needs to know the destination's MAC address. IPv4 uses ARP, so the source host sends an ARP request for the destination IP address (as broadcast) and the destination host replies with its MAC address.

ping uses ICMP echo request and reply. The source host forms an IP packet encapsulating the echo request and - since the destination is local - encapsulates this IP packet in an Ethernet frame addressed to the destination's MAC address learned through ARP.

This Ethernet frame is forwarded to the destination's port by the switch, the ICMP echo request discovered and replied to using the same mechanism. ARP isn't required as the destination has already learned the source's MAC from the received traffic.

As Karl's pointed out, DHCP isn't used at all (except for possibly assigning IP addresses to source and destination on startup). Neither is the router/gateway, it's only used to forward IP packets to destinations beyond the local network. For this, the Ethernet frame would be addressed to the gateway, everything else would stay the same.