ARP vs NAT Routing Decisions: WAN and LAN Traffic Control

MAC addresses and IP addresses play a crucial role in identifying host systems, enabling communication between devices in both Local Area Networks (LANs) and Wide Area Networks (WANs). Regardless of the network type, when two systems communicate, they must have a way to recognize each other.

However, LAN and WAN traffic employ different methods for host identification and communication due to the varying layers at which these networks operate and their distinct scopes.

In a LAN, such as a home or office network, systems function at the data link layer, and communication happens directly between devices within the same local network. When a device in the LAN wants to communicate with another, it can simply send out a request for all MAC addresses using the Address Resolution Protocol (ARP).

This enables the device to find the MAC address of the destination host and establish direct communication without the need to send packets out to the internet. LAN communication is relatively straightforward and efficient, as devices are confined within a limited physical area.

In contrast, WANs, like the internet, operate at the network layer. When two remote systems communicate over the internet, the process becomes more intricate. Packets need to traverse multiple routers and networks to reach their destination, covering longer distances.

IP addresses become essential in this scenario, as they facilitate identifying hosts and routing packets across different networks.

The complexity of WAN communication is due to the vast geographical scope and diverse infrastructure involved in transmitting data over the internet.

To dive deeper into this matter, let us explore the mechanisms and intricacies of how MAC and IP addresses enable effective communication and routing within and between networks.

Data Link Layer

The Data Link layer is the second layer in the OSI model of networking. It deals with how devices on the same local network communicate with each other. It uses MAC (Media Access Control) addresses to uniquely identify devices within the network and ensures data is delivered directly to the right recipient. The Data Link layer also handles error detection and correction to make sure data is transmitted accurately and reliably over the physical network.

LAN/WLAN Routing

In a Local Area Network (LAN), devices communicate using link layer addresses, also known as MAC addresses. If a packets destination is a private IP address, then the router knows that it is destined for a host within the local network but is not able to make destination decisions based on strictly the IP addresses. When devices communicate within the LAN, they rely on a combination of MAC addresses and private IP addresses. Whether a device is connected to the internet or not, the LAN communication remains reliant on these two key identifiers.

MAC addresses are used for local data delivery within the LAN, while private IP addresses serve to identify devices within the network. This combination of MAC addresses and private IP addresses ensures efficient and secure communication between devices within the LAN.

Local IP addresses are assigned automatically by a process called Dynamic Host Configuration Protocol (DHCP). Typically, your router or wireless access point manages the DHCP. If a host doesn’t know the destination’s IP address, it can use DHCP to discover it.

By using MAC addresses, communication between these devices becomes unicast, meaning data is sent directly from one specific device to another without traversing the internet. This direct communication mechanism ensures efficient and reliable data exchange within the local network. Consequently, even if devices within the LAN lack internet connectivity, they can still interact seamlessly using their MAC addresses and private IP addresses as long as they are connected to the same broadcast domain.

Here’s how the journey of LAN traffic goes: When a host wants to send data to another device, it first figures out the destination’s private IP address. Once it knows the IP address, the sender needs the destination’s MAC address to send the data. This mapping of IP addresses to MAC addresses is achieved through a process called Address Resolution Protocol (ARP). ARP helps the sender find the MAC address associated with the destination IP address, allowing for effective communication within the LAN.

ARP (Address Resolution Protocol) is used in IPv4 networks to map IP addresses to MAC addresses. Every device capable of handling IPv4 packets maintains an ARP table that stores these mappings.

When a device wants to communicate with another device on the same LAN but only knows the destination IP address, it sends an ARP request packet to find the MAC address of the target device. The ARP request is a broadcast message that essentially says, “Who has this IP address? Please tell me your MAC address.” Since it’s a broadcast, all devices within the same network segment receive the ARP request packet. The device that matches the IP address mentioned in the ARP request will respond with an ARP reply packet.

By resolving the MAC addresses and private IP addresses, LAN traffic can be precisely directed and efficiently transmitted between devices within the local network.

Network Layer

The Network Layer in the OSI model is positioned after the Physical Layer and the Data Link Layer. Its primary function is to route and direct network traffic efficiently, determining the optimal path for packets across the network.

To accomplish this, it relies on network addresses, specifically IP addresses, to identify devices and guide packets from their source to their intended destinations.

While the Data Link Layer and MAC addresses are crucial for communication within a Local Area Network (LAN), the Network Layer plays a vital role in enabling traffic to extend beyond the confines of the local network. By using IP addresses, the Network Layer facilitates the movement of data beyond your immediate network, allowing devices to access information and resources on the internet.

WAN Routing

The internet, being a vast interconnected network, often requires communication with remote servers located across the globe. In such cases, using MAC addresses becomes impractical, and that’s where public IP addresses come into play. Public IP addresses serve as unique identifiers for hosts, enabling direct requests to be made to the specified address. However, IP addresses can be challenging to remember, which is why we use domain names as human-readable alternatives. These domain names help us identify specific locations on the internet, making it more convenient for users.

To map a domain name to its corresponding IP address, Domain Name Servers (DNS) come into action, processing the domain and returning the IP address.

Much like how the ARP protocol maps private IP addresses to MAC addresses within our local networks, DNS performs a similar function by mapping domain names to public IP addresses. When we enter a domain name like “jcawl.com” into our browser, the request is routed to a DNS resolver, usually managed by our internet service provider (ISP). This resolver then forwards the request to a DNS root name server, responsible for handling all “.com” domains. The DNS root name server checks its records, finds the IP address associated with “jcawl.com,” and responds to the browser request by returning the IP address. The browser caches this IP address for faster access, and then proceeds to send the request to retrieve the desired webpage from the IP address we just received.

Within our immediate networks we have many devices, but somehow our router knows which device is sending out requests even though each device does not have a public IP address. As stated, earlier WAN traffic does not use MAC addresses, so how does the router keep track of what traffic belongs to who?

All routers connected to the internet have its own public facing IP address which it used to route all traffic to the internet. While each host inside of the network has a private IP address, when traffic destined for the internet is sent to the router to be routed to a remote server, the router performs a Network Address Translation (NAT) to translate the private IP address of the host to its own public IP address. IP addresses are limited so NAT conserves IP addresses enabling all internal networks to communicate with the internet over a single IP address.

To distinguish between multiple devices in the Local Area Network (LAN) as they communicate with various servers on the internet simultaneously, routers use a combination of their public IP address and a random, unique port number. Each outgoing connection from a device is assigned a specific port number which acts as an identifier for each communication channel. To keep track of all the communication channels the port numbers, public IP address, and sending host private IP address are added to the NAT table.

As data packets are sent out from the LAN to the internet, they carry a source IP address and port number, allowing the router to identify the sending host. When responses are received from the internet, the packets contain a public IP address and port number as their destination address. The router refers to the NAT table to match the received port number with the corresponding private IP address of the destination host. This way, the router accurately directs the response to the correct system within the LAN.

By utilizing this method of port-based identification and NAT, routers efficiently manage the flow of data between multiple devices in the LAN and the internet.

Conclusion

When exploring how routers manage traffic and identify the sending host, I initially found it confusing. However, after conducting some research, I now grasp the concepts and the reasons behind these decisions. It turns out that WANs and LANs operate on vastly different scales, which necessitates two distinct methods for handling traffic and identifying sending hosts. These approaches ensure efficient traffic management for each network type. I hope this post has shed some light on the topic and helped you better understand how routers work.