2

I'm trying to get a better understanding of networking in general. Here's one of the many questions I got:

What exactly happens (network wise) when I ping 192.168.0.5 from 192.168.0.3, when both are on a wireless connection for example?

Does it go through the default gateway (let's say 192.168.0.1), and would that be the DHCP Server, the modem, or the router?

I feel like it should be the router. But if it is, how do you configure your network if the modem and the router are 2 separate entities (so, with different ips). Because the default gateway has to be the modem, what's left for the router?

Or am i missing something?

  • 1
    Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer. – Ron Maupin Dec 25 '18 at 9:00
3

Wireless networking (802.11) works differently than wired Ethernet.

The access point "creates" the wireless LAN. In a standard infrastructure mode WLAN, when two devices want to communicate on the same subnet, the source sends its frames to the access point which then resends the frame to the destination. So when station A ARPs for the mac of station B, the frame is sent to the access point, when then forwards it to station B.

That's why devices have to be associated with an access point (on the same SSID) in order to communicate with each other.

Note that most consumer wireless routers are actually three devices in one: An access point, a router and a modem. Even though they are in the same box, they function separately.

3

As they are on the same network, they do not need to send traffic through a router. They send out ARP requests to get the MAC address of the other device, then send Ethernet frames directly between each other. If a host needs to send something to another network, it sends it to the router (default gateway). The DHCP server is only used once to assign an IP address to the PC when it boots up, and then periodically every few days, to renew the lease of the address, it isn’t needed for traffic forwarding. The modem is the device that connects to the phone line. It can be built into the router, or a separate device. The router will send traffic to the modem if it needs to reach a destination off site, something on the Internet.

  • So, 2 computers on the same network send Ethernet frames directly to each other. But then, why do the computers need to be connected to the same network in order to talk to each other directly to each other? I think there is a lot I don't understand about the WiFi itself... – math2001 Jul 9 '18 at 6:56
  • Routers are devices that connect networks together. Hosts can still talk to each other if they are on different networks, they just need to talk through a router in that case. If they are on the same network, there is no need for a router. You need to investigate IP addressing and subnet masks. A basic tutorial should show how a device can work out if another device is on the same network and how the forwarding works if they are on the same network (direct) or different networks (through a router) – Karl Billington Jul 9 '18 at 7:56
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.