broadcast address only applies to correct subnet

Ultimately, the problem stemmed from a ping to an address
       with the wrong subnet mask (auto-filled subnet) which turned
       the address (which should have been routed) into a local broadcast.
       Only the global broadcast, or a local broadcast should be accepted,
       not a broadcast that should be routed.

       This can be seen in Level 4, Small Subnets puzzle.
       1.) fix router2 to be /31
       2.) from pc1, ping pc2 (which turns into 192.168.1.3)
                       -autoIP filled in a subnet mask of 255.255.255.252
                       -therefore 1.3 is considered the broadcast IP.
       -result: a local broadcast on the 192.168.2 network.
       3.) from pc1, ping 192.168.1.1 or 192.168.1.4 works fine.
       4.) edit firewall1, edit route to 192.168.1.1
                       -make no changes, just hit OK
       5.) again from pc1 ping pc2
                       -now autoIP fills in subnet mask 255.255.255.0
       -result: it works
This commit is contained in:
Tim Young 2019-02-27 08:41:58 -06:00
parent 886e1d7911
commit 2a17fba36c
1 changed files with 6 additions and 1 deletions

View File

@ -1431,7 +1431,12 @@ namespace EduNetworkBuilder
public bool HasBroadcastAddress(NB_IPAddress dest)
{
if (dest.BroadcastAddress == dest.GetIP) return true;
foreach(NetworkCard nic in NICs)
//This "fixes" a strange fringe case of when we configure a subnet such that
//a packet that is traversing the network suddenly is a broadcast packet on the
//target network. Gotta have odd subnetting for this to happen
if (NB.BroadcastIPString == dest.GetIPString) return true;
foreach (NetworkCard nic in NICs)
{
if (nic.HasBroadcastAddresses(dest))
return true;