-1

Possible Duplicate:
How does Subnetting Work?

Imagine there is a small network with 2 subnets. Both of the subnets have their own switch (means: all machines on that subnet share the same switch). Both of the switches are connected to a router. The router is connected to the internet.

I want to understand the procedure of how a machine A in such a subnet contacts

  1. another machine B in the same subnet
  2. another machine C in the second (and therefore different) subnet
  3. another machine D on the internet

From what I unterstand:

In all 3 cases, machine A compares the target IP to its own subnet-mask. Now, machine A knows whether the target machine is located in the same (sub-)network or not. Is this correct so far?

If the target IP is located on the same (sub-)net, there is not much to do. Machine A just sends its data directly to machine B via the switch, there is no need for the router to intervene.

If the target IP is located in another (sub-)net, like machine C in the second subnet, machine A has no direct route. Therefore, it looks for its default-gateway (in this case the gateway is the router I think) and sends its data to the router. The router does some network address translation and delegates the data to machine C. I think it is the same procedue as for machine D on the internet.

I'm especially interested in how machine A knows whether to use the default-gateway/router or not. Is it just like I mentioned by comparing the target IP with the own subnet-mask? Or maybe I'm wrong here and it is not the job of machine A to determine that at all?

Thank you

alejandro
  • 49
  • 3
  • Read this; http://serverfault.com/a/49836/1435 - by the way this site is for professional sysadmins, your question is literally 'ABC' stuff, the most basic of basic - we're not hear to cover that ground. – Chopper3 Jun 24 '12 at 16:59
  • Set the proper subnet mask. – tftd Jun 24 '12 at 17:23

2 Answers2

1

The answer above is perfect except:

  • The broadcast mentioned on line three is an ARP broadcast to the MAC FF:FF:FF:FF:FF:FF and will be received by all nodes within the collision domain unless the destination IP is found within the switches CAM table with a respective MAC of the destination node.

  • The broadcast 255.255.255.255 will propagate to all nodes within the broadcast domain. The Broadcast Domain generally represents the local subnet. So 255.255.255.255 sent on a 192.168.1.0/24 network will be received by ip 192.168.1.1-254.

  • WAIT! why not 192.168.1.255 this address is used for directed broadcasts. Say im in the 192.168.2.0/24 network but i want to communicate with all 192.168.1.0/24 hosts. The I target the broadcast address of the subnet.

more examples 10.12.0.0/16 broadcast address of 10.12.255.255 usable address of 10.12.0.1 - 10.12.255.254

192.168.4.0/26 broadcast address of 192.168.7.255 usable address of 192.168.4.1 - 192.168.7.254

0

If the other machine is on the same subnet, it's determined from the netmask on the interface, so if it's not, then it's delivered to the default gateway. ARP plays a major role here as well, if it's the same subnet, it tries to get the MAC address via 255.255.255.255 broadcast addr and if not, it does the same with the default gateway. So the packet is sent to the MAC of the default gateway, and there it goes up the same way until it's delivered to the destination. If e.g. core switch or any other switch with low-delay switching doesnt have the ARP of the destination machine yet it needs to forward the packet, it will forward it to all ports (normal switch would drop the packet), this is a small nuance here if you wonder how it works when there is no time to get the MAC address via ARP on core switch.

Andrew Smith
  • 1,123
  • 13
  • 23