Asked • 03/19/19

How does a packet find its way from a LAN device to a router, or vice versus?

I am trying to understand how packets are sent from one device to another in a wireless network? (Perhaps the same question also applies to a wired network) How does a router know in which physical direction to send a packet in order for a particular IP/MAC address to receive it? Or is this not the case, and is the data sent out or scattered in a random direction, and all devices on a network listen to all network traffic and act only on those matching its IP/MAC address? If the latter is true, does this not raise security vulnerabilities? And is the same is true of wired networks?

1 Expert Answer

By:

Jackson J.

tutor
TL;DR - Your question is answered in Steps 6-8 but it would behoove you to read through the entire narrative ;-) Important Takeaways: The IP Packet (Layer 3) contains the Source IP Address and the Destination IP Address. Therefore, PC-A will have generated an IP Packet containing the actual Ping Echo Request which has PC-A's IP Host Address filled out in the "Source IP Address field" and it will fill in PC-B's IP Host Address in the "Destination IP Address" field of the IP packet. This is how the Ping Request will actually be delivered to PC-B. This IP Packet gets encapsulated into an Ethernet Frame therefore, it never gets modified.** When Router-X receives the Ping Echo Request destined to PC-B, it will de-encapsulate the Ethernet Frame and inspect the IP packet inside. It will look at the Destination IP Address field to be more specific. This is the main basic nature of how Routers function by default. Router-X will see that the IP packet is destined for "192.168.2.3" (or PC-B) and it will look in it's Routing Table for a match. Since it has an Interface that is Directly Connected to that Network (192.168.2.0/24), it will send the IP Packet out of that Interface. It's important to know that if there were multiple entries for 192.168.2.0 with varying Subnet Mask Lengths, the Router would choose the entry with the most specific match, or longest Prefix as a Tie-Breaker. This is a process called the "Longest Prefix Match". Since this Packet is destined for a different LAN/Network, the Packet needs to be Encapsulated into a NEW Ethernet Frame at Layer 2 according to the 802.3 Standard and sent out of the Router Interface pointing to Switch-B now. That means that Router-X would need to send an ARP Request for the MAC Address of the Host who has a NIC Card associated with the IP Address of 192.168.2.3. Steps 1-11 will occur again, but this time for Router-X trying to obtain the MAC Address for PC-B so that it can Route PC-A's Ping Echo Request to it. As you can guess, the Source MAC Address of this New Ethernet Frame is Router-X's Interface that's configured with the 192.168.2.1 Default Gateway Address and the Destination MAC Address is the Broadcast Address (FF:FF:FF:FF:FF:FF) since it is currently unknown. After Steps 1-11 are followed for this communication between Router-X and PC-B and then PC-B finally receives PC-A's IP Packet, PC-B is then obligated to send a Ping Echo Reply back to PC-A according to the ICMP (Internet Message Control Protocol) Standard. Similar steps are followed for PC-B to send the Ping Echo Reply to PC-A and that's how devices communicate from LAN to LAN :) When the Hosts are on the same LAN/Network, a Router is not required and they can simply send Ethernet Frames to each other. The Switch that those Hosts are connected to will perform the Basic Functions that I mentioned earlier in Steps 5 and 10. Once the MAC Address Table of the Switch is populated with proper information on which Switchport that a particular MAC Address can be found, it can then forward traffic out to that port accordingly. But it will need to either learn it first or if the MAC Address is unknown, then it will "Flood" the Frame out of every port except for the port that the Frame came in on. To answer your question, the Router serves as the "Default Gateway" for Hosts that reside in a Network that it has a Router Interface directly connected to, because Router Interfaces lead to Networks (LANs or WANs). By way of 802.3 Ethernet Addressing and the ARP Protocol, the Router can learn the MAC Address of the Host Device that it needs to route packets for or to. And the Router maintains a Routing Table that contains entries of Networks where Hosts can be reached. If a Router is not directly connected to a Network, it typically will have an entry that points to a neighboring Router that can forward the packet towards it's destination. Typically, Routers contain a "Default Route" entry (0.0.0.0/0) that points to another Gateway Router which can point to all Networks unknown to the Router. Also, I know you're probably thinking all of this Broadcasting of traffic is inefficient and causes unnecessary traffic and also unsecure. What happens if a Hacker is sitting inside the Network and uses a Hacking Tool to send Packets out to the Network impersonating the MAC Address of the real Router (RouterX)! Basically launching a "Main-In-The-Middle" Attack! Strides have been made where Fabric Networks and Software-Defined Networking allows for Broadcast traffic to be limited or prevented from being flooded throughout the LAN all together. The security of MAC Address Spoofing is a valid concern and therefore, Countermeasures have been developed; such as "Dynamic ARP Inspection" which allows Switches to validate ARP Packets within a Network. "DAI" snoops the ARP operations passing through it and keeps a Database of IP to MAC Address Bindings. The Switch essentially intercepts, logs, and discards ARP packets with invalid MAC address to IP address bindings.
Report

07/16/23

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.