I have a local network here. I am doing traceroute to another system on the same network. I was expecting two results. One is the hit to my router, and then to the other machine. But I see just one result as follows
1 13 ms 4 ms 12 ms nj-PC [192.168.1.110]
Why is the information about the router not shown?
1) Does router act as a switch here, or
2) Does it not return the packet if the packet is being forwarded on the same interface? or
3) The packet does not go through the router at all. Once it gets the MAC address of the destination, does it directly send it to the destination? My doubt here is the packet will still go through the router, right? Will it just act as a pass through for these packets?
Basically, what happens when you run traceroute nj-PC
is this:
nj-PC
to an IP address. (won't go into the details of that here)The source host checks its local routing table for a route to that IP address.
Example routing table:
Destination Gateway Genmask ...
0.0.0.0 192.168.1.254 0.0.0.0 ... # default route
192.168.2.0 192.168.1.253 255.255.255.0 ... # net route
192.168.3.23 192.168.1.252 255.255.255.255 ... # host route
192.168.1.0 0.0.0.0 255.255.255.0 ... # directly reachable
If the destination is directly reachable (gateway 0.0.0.0
or On-link
, depending on your operating system), the MAC address of the destination IP address is resolved via ARP and the packet is sent directly to the destination host (via Ethernet).
In your case both source and destination IP address are in the same subnet, so the destination is directly reachable and the packet is thus delivered directly without router involvement. That's why you see only a single hop in the traceroute
output.
The router device may still act as a switch here, if it has a built-in switch and both devices are connected to that switch, but that's a different matter and unrelated to routing. Switching (Ethernet) takes place in the data link layer (layer 2 of the OSI model), whereas routing (IP) takes place in the network layer (layer 3).