0

When a host attempts to communicate with another device using TCP/IP, it performs a comparison process using the defined subnet mask and the destination IP address versus the subnet mask and its own IP address. The result of this comparison tells the computer whether the destination is a local host or a remote host.

If the result of this process determines the destination to be a local host, then the computer will send the packet on the local subnet. If the result of the comparison determines the destination to be a remote host, then the computer will forward the packet to the default gateway defined in its TCP/IP properties. It's then the responsibility of the router to forward the packet to the correct subnet.

Where is the packet sent if it is determined to be for an host on local network? Is it directly sent to destination computer?

3
  • You need to understand the layer-2 frame for the LAN. The packet gets encapsulated into a frame for the local LAN. If the packet is destined to a host on the local LAN, the frame contains the data-link address of the destination host, e.g. the MAC address of the destination host on the local LAN.
    – Ron Maupin
    Jun 16 at 17:53
  • But doesn't the packet pass through switch/router?
    – variable
    Jun 17 at 12:43
  • No, a frame may pass through a switch (assuming the data-link protocol is ethernet, but remember that there are other datalink protocols). Packets are layer-3 datagrams that get encapsulated in layer-2 datagrams (frames) for delivery on the LAN. The frames do not survive a router, where the frames are stripped off the packets so that the packets can be forwarded to a different network. A router is not involved in local traffic, only traffic to a different network.
    – Ron Maupin
    Jun 17 at 12:49
1

From the information you quoted:

If the result of this process determines the destination to be a local host, then the computer will send the packet on the local subnet.

5
  • Yes but doesn't this packet pass through the switch or router? How can I directly reach the destination computer?
    – variable
    Jun 17 at 12:44
  • Switch, yes. router no. A switch does not modify the Ethernet frame.
    – Ron Trunk
    Jun 17 at 13:41
  • What if the network has only computers and 1 router. No switch
    – variable
    Jun 17 at 15:20
  • Many home "routers" (off-topic here, btw) have a built-in switch for multiple devices. So there is a switch -- it's just inside the same physical box as the router.
    – Ron Trunk
    Jun 17 at 16:23
  • @RonTrunk While I've rarely seen an actual hardware implementation of a switch in consumer models the functionality is still there as they generally simply emulate the same functionality in software typically with Linux bridging. While I know from testing that 4 gigabit ports can make the little microcontroller cry like a baby if they all decide they really want several GB of data from a different port. This is probably a scenario those devices only experience when mean people like me set up a stress test on purpose lol. Other than that it's functionally the same.
    – MttJocy
    Jun 19 at 22:03
1

Assuming an Ethernet* network, the host will translate the destination IP address to a MAC addresses using it's ARP (ND for IPV6) table. If there is no usable entry in the table then the packet will be held while an ARP request is made.

The ARP request and response will create entries in the switching tables of any Ethernet switches between the two hosts. So the actual data packets will normally** only be delivered to the appropriate switch ports.

Note that most home/small buisiness routers incorporate an Ethernet switch, so all the "LAN side" ports are on the same Ethernet network.

* Wi-fi is not Ethernet, but it's close enough for these purposes.

** There are exceptions to this such as when a switch is rebooted or when it's MAC address tables overflow.

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.