0

In case this is a yes why cant we connect 2 Lans with a hub or a switch. Let me elaborate, we have subnet A and subnet B, completely differents IPs, all hosts (of B and A) are wired directly to one HUB/Switch. One host of A decides to talk to someone on B with a known IP. So he decides to send a frame broadcasted on layer-2 but has encapsulated an ip header with the ip of the host that belongs to subnet B as its destination. Would the packet end up in the desired destination? Would it be accepted? Obviously i know about the existence and the use of Routers and how a host routes a packet (with ARP and default gateway) and the above case is full of problems but this is not an actual practical question, just a completely theoretical one that came up to me recently after i ended my networking class in uni.

3 Answers 3

0

why cant we connect 2 Lans with a hub or a switch.

With "LANs" I assume you mean separate L2 segments.

we have subnet A and subnet B, completely differents IPs, all hosts (of B and A) are wired directly to one HUB/Switch.

That is one L2 segment (unless you've configured separate VLANs on the switch).

One host of A decides to talk to someone on B with a known IP. So he decides to send a frame broadcasted on layer-2 but has encapsulated an ip header with the ip of the host that belongs to subnet B as its destination. Would the packet end up in the desired destination?

End up, yes. The broadcast is forwarded throughout the L2 segment, received by the intended NIC (and all others), not dropped (because it's broadcast) and passed to the local IP stack. Since this case isn't well defined, the local stack might decide to ignore the encapsulated packet, or it might decide to process it normally. It's up to its implementation.

In case you really mean two L2 segments, then no, the frame will be dropped by the gateway. Gateways do no forward packets from broadcast frames.

1
  • Yeah i meant one L2 segment. Thanks a lot for your answer !
    – J.T
    Jan 29 at 23:28
2

One host of A decides to talk to someone on B with a known IP. So he decides to send a frame broadcasted on layer-2 but has encapsulated an ip header with the ip of the host that belongs to subnet B as its destination.

A host on network A sending a packet to a host on network B will encapsulate the packet in a frame destined to its configured gateway. A source host masks the destination IP address to determine if the destination is on the same or a different network. On the same network, it will encapsulate the packet in a frame with the address of the destination host, but for a different network, it will encapsulate the packet in a frame for its configured gateway toward the destination network.

I'm not sure what you mean by an unknown MAC address because a receiving host does not care about the source MAC address when receiving a frame. A host receiving a broadcast frame will forward the frame payload to the layer-3 protocol for inspection, regardless on the source MAC address.

5
  • I know the routing process and this is what it would happen normally but making it manually (i dont know if that is possible) like that would it end up on its destination
    – J.T
    Jan 29 at 23:03
  • The network stack performs as I described. Your question is really outside the bounds of this site because hosts/servers are off-topic here. What you seem to want is something non-standard that is off-topic. What any particular host OS does is off-topic here.
    – Ron Maupin
    Jan 29 at 23:07
  • oh ok sorry. yeah the question is totally non-standard. Thanks for your time. Is there a place for non-standard stuff ?
    – J.T
    Jan 29 at 23:14
  • You could ask about what a host OS may do with something like that on Super User, but it may vary based on the OS (each could handle it differently).
    – Ron Maupin
    Jan 29 at 23:18
  • Unless you have an "interface" route telling the host that layer-3 subnet is local. Such overlapping is a bad practice, but people have done it for decades. (see also: cisco ip address ... secondary)
    – Ricky
    Jan 30 at 0:56
0

One host of A decides to talk to someone on B with a known IP. So he decides to send a frame broadcasted on layer-2 but has encapsulated an ip header with the ip of the host that belongs to subnet B as its destination

This is not the normal operation of a TCP/IP host. I suppose you could program your computer to do that if you really wanted to.

When a (normal) host receives a layer 2 frame, it checks if the destination address matches its own address, or the broadcast address. If so, the data is passed up to the next layer.

A similar process happens at the IP layer. If the destination address matches, the packet is passed ip to the next layer.

1
  • You could use a static ARP entry for that IP - if the hosts accepts that...
    – Zac67
    Jan 30 at 7:44

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.