1

If I have two nodes/computers connected to each other on the same range of IPs. Say:

Node A: 192.168.0.1/30 Node B: 192.168.0.2/30

How to know (from Node A) if B is connected directly to it (via the same switch) or not (via multiple hops)?

3

Since switches generally do not rewrite the Ethernet frame, you can't tell from inspecting the data. You might be able to infer something based on timing (delays), but I suspect that would be unreliable.

  • Indeed, this is what I know. My problem is related to a throughput bottleneck on a ring topology when using several hops (Due to delays on each round). I wanted to make sure. – Mohamad-Jaafar NEHME Mar 16 '15 at 20:30
  • How far apart are the switches? Your delay should be in the 10's of microseconds. Perhaps something else is going on. – Ron Trunk Mar 16 '15 at 21:46
  • I am seeking for a generic solution. – Mohamad-Jaafar NEHME Mar 20 '15 at 20:56
3

Not unless the switch is identifying itself via CDP or LLDP. Even then, there can be technology along the path that won't be detectable. (i.e. in a metro-e setup you may have two ports on the same layer-2 device that follow different layer-1 paths.)

Timing measurements will ultimately be inconclusive. Different switches process at different rates, and the load on the switch can lead to variability in switching rates. Plus, do you have the gear to time things down to the micro- or nano-second?

1

The easiest and most reliable method is to physically trace out the network cables from the respective clients.

  • You are right ,however my question is: (From client A). Anyway, thank you. – Mohamad-Jaafar NEHME Mar 20 '15 at 21:03
1

From the host it self as said before you cannot check that.. but you can check it if you have access to the switch where host A is connect to.. and check the mac-address table. If the mac-adress of host B is showing on a trunk port then you know is on another switch.

0

To piggy back on Ricky's answer if you can access PC A and B but not any of the switches inbetween you could use Wireshark to capture any CDP or LLDP packets that come your way. Using the device name and other information in these packets you could at least confirm whether they are 1 switch hop apart, or 2 (or more) switch hops away from each other.

EDIT: Expanded the original answer below

You would be able to capture CDP or LLDP packets which, if enabled on the switches are sent out every 60 and 30 seconds respectively. These types of packets both have switch information inside them. For example: You enable Wireshark on PC A to capture packets. You receive an LLDP (or CDP) packet there, you expand the details in Wireshark and you will see System Name: Cisco-3750-London-1 or you could look at the System ID: de:ad:01:01:be:ef. On PC B you could do the same and see if they are the same or different System Names and IDs. Does PC B receive CDP/LLDP packets that contain System Name: Cisco-3750-London1 and de:ad:01:01:be:ef, or will it be Cisco-3550-London-Building2 with a System ID of 0c:07:08:de:ab:45?

It will only tell you for sure if it is one switch as if the Names or IDs differ then it could be 2 or 3 or 50 hops in between. It also depends on the network to have CDP or LLDP compatible switches and for it to be enabled on the host ports.

  • would you please clarify a little bit more. How could I know the number of hops? – Mohamad-Jaafar NEHME Mar 20 '15 at 21:10
  • Added it to the original comment – jpd126 Mar 20 '15 at 22:46
  • Ok thanks a lot. Unfortunately, I cannot upvote yet. – Mohamad-Jaafar NEHME Mar 20 '15 at 22:58
  • No worries I am new too. If you can access the first switch hop that is connected to Switch A and all the ring topology is Cisco you can use a Layer 2 traceroute. Check out Cisco documentation. I am not sure if I can link it here (newbie) all the best – jpd126 Mar 20 '15 at 23:05
-2

You can execute the traceroute command from node A to trace the route of an IP packet sent to node B. If the two nodes are connected to the same switch traceroute output will shows only one hop. Run this in a windows terminal tracert 192.168.0.2

  • If the two computers are on the same subnet, there won't be a hop no matter how many switches there are. – Ron Trunk Mar 20 '15 at 0:28
  • I know , maybe "hop" is not the right word but you'll have one line which corresponds to note B. Just tested this using the default gateway address it works. – storm Mar 20 '15 at 15:12
  • You will get that same response whether there is one switch or ten in between. – Ron Trunk Mar 20 '15 at 16:28

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.