Fixed bug with network loop puzzle. That caused issues with tSourceIP. Needed to set tSourceIP when forwarding / routing, and coming out of a VPN
This commit is contained in:
parent
2094f7fac4
commit
52c7ab63e2
2
EduNetworkBuilder/DeviceConfig.Designer.cs
generated
2
EduNetworkBuilder/DeviceConfig.Designer.cs
generated
@ -185,7 +185,7 @@
|
||||
this.lbArpTable.ItemHeight = 17;
|
||||
this.lbArpTable.Location = new System.Drawing.Point(15, 269);
|
||||
this.lbArpTable.Name = "lbArpTable";
|
||||
this.lbArpTable.Size = new System.Drawing.Size(326, 89);
|
||||
this.lbArpTable.Size = new System.Drawing.Size(349, 89);
|
||||
this.lbArpTable.TabIndex = 13;
|
||||
//
|
||||
// btnGateway
|
||||
|
@ -211,10 +211,10 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
|
||||
lbArpTable.Items.Clear();
|
||||
lbArpTable.Items.Add("Arp Table MAC\tIPAddress");
|
||||
lbArpTable.Items.Add("Arp Table MAC\tIPAddress\tIF");
|
||||
foreach(ArpEntry ae in ndCLonedItem.GetArps())
|
||||
{
|
||||
lbArpTable.Items.Add(ae.MACAddress + "\t" + ae.IPAddr);
|
||||
lbArpTable.Items.Add(ae.MACAddress + "\t" + ae.IPAddr + "\t" + ae.NicOnWhichItIsFound.NicName);
|
||||
}
|
||||
|
||||
//The IP Addresses for the given nic
|
||||
|
@ -57,10 +57,10 @@
|
||||
<ApplicationIcon>Resources\NBIco.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ManifestCertificateThumbprint>FC016CC0B0D70B0A6ABDABD9CDB267055A8FCCA3</ManifestCertificateThumbprint>
|
||||
<ManifestCertificateThumbprint>B9F30C1A5500E918477D84AE79FD91D601D3860E</ManifestCertificateThumbprint>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ManifestKeyFile>EduNetworkBuilder_1_TemporaryKey.pfx</ManifestKeyFile>
|
||||
<ManifestKeyFile>EduNetworkBuilder_2_TemporaryKey.pfx</ManifestKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<GenerateManifests>true</GenerateManifests>
|
||||
@ -214,6 +214,7 @@
|
||||
<DependentUpon>VLANConfig.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="EduNetworkBuilder_1_TemporaryKey.pfx" />
|
||||
<None Include="EduNetworkBuilder_2_TemporaryKey.pfx" />
|
||||
<None Include="EduNetworkBuilder_TemporaryKey.pfx" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
|
@ -294,6 +294,7 @@ namespace EduNetworkBuilder
|
||||
public static int WirelessMaxSuccessfulLink = 100; //Packets will drop after this distance
|
||||
public static int WirelessReconnectDistance = 70; //Try to find a closer AP if we are this far out.
|
||||
public static int UntaggedVLAN = -1; //If the packet is not tagged.
|
||||
public static int MaxPacketsBeforeOptimizing = 50;
|
||||
|
||||
/// <summary>
|
||||
/// Find the global random number generator.
|
||||
|
@ -941,8 +941,29 @@ namespace EduNetworkBuilder
|
||||
|
||||
public void addPacket(Packet toadd)
|
||||
{
|
||||
if(toadd != null && !myPackets.Contains(toadd))
|
||||
myPackets.Add(toadd);
|
||||
if (toadd != null && !myPackets.Contains(toadd))
|
||||
{
|
||||
if (myPackets.Count > NB.MaxPacketsBeforeOptimizing)
|
||||
{
|
||||
bool foundit = false;
|
||||
foreach(Packet pkt in myPackets)
|
||||
{
|
||||
if(pkt.MyType == toadd.MyType && pkt.WhereAmI == toadd.WhereAmI &&
|
||||
(pkt.sourceIP != null && pkt.sourceIP.Equals(toadd.sourceIP)) &&
|
||||
(pkt.destIP != null && pkt.destIP.Equals(toadd.destIP)))
|
||||
{
|
||||
foundit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundit)
|
||||
myPackets.Add(toadd);
|
||||
}
|
||||
else
|
||||
{
|
||||
myPackets.Add(toadd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int CountPackets(PacketType WhatType)
|
||||
|
@ -464,8 +464,8 @@ namespace EduNetworkBuilder
|
||||
case NicType.eth:
|
||||
case NicType.wlan:
|
||||
//see if it the packet dest is local to this nic
|
||||
if (tPacket.MyType == PacketType.dhcp_answer)
|
||||
Console.WriteLine("DHCP Answer");
|
||||
//if (tPacket.MyType == PacketType.dhcp_answer)
|
||||
// Console.WriteLine("DHCP Answer");
|
||||
foreach (NetworkInterface nf in interfaces.ToList())
|
||||
{
|
||||
if (tPacket.InboundNic != null && tPacket.InboundNic == this &&
|
||||
@ -477,6 +477,8 @@ namespace EduNetworkBuilder
|
||||
continue; //only send out arp requests on local networks
|
||||
nPacket = new Packet(tPacket);//Creates a new packet but sets isfresh=false
|
||||
nPacket.OutboundIF = nf;
|
||||
if(nf != null)
|
||||
nPacket.TsourceIP = nf.myIP;
|
||||
nPacket.InboundInterface = tPacket.InboundInterface;
|
||||
nf.ProcessOutboundPacket(nPacket);
|
||||
if (nPacket.MyStatus == PacketStatus.finished || nPacket.MyStatus == PacketStatus.finished_failed || nPacket.MyStatus == PacketStatus.finished_ok)
|
||||
@ -532,6 +534,8 @@ namespace EduNetworkBuilder
|
||||
nPacket = new Packet(tPacket);//Creates a new packet but sets isfresh=false
|
||||
nPacket.OutboundIF = nf;
|
||||
nPacket.InboundInterface = tPacket.InboundInterface;
|
||||
if (nf != null)
|
||||
nPacket.TsourceIP = nf.myIP;
|
||||
|
||||
nf.ProcessOutboundPacket(nPacket);
|
||||
if (nPacket.MyStatus == PacketStatus.finished || nPacket.MyStatus == PacketStatus.finished_failed || nPacket.MyStatus == PacketStatus.finished_ok)
|
||||
@ -595,6 +599,8 @@ namespace EduNetworkBuilder
|
||||
tPacket.MyStatus = PacketStatus.encapsulated;
|
||||
tPacket.TsourceIP = nf.myIP;
|
||||
tPacket.destMAC = WhereFrom.LookupArpFromIP(tPacket.OutboundIP.GetIPString);
|
||||
if (nf != null)
|
||||
tPacket.TsourceIP = nf.myIP;
|
||||
|
||||
//We need to make a new, tunnel packet
|
||||
if (myNicType == NicType.tun)
|
||||
@ -672,7 +678,8 @@ namespace EduNetworkBuilder
|
||||
if (nPacket.TsourceIP == null)
|
||||
nPacket.TsourceIP = WhereFrom.HubManagementIP();
|
||||
nl = myNet.GetLinkFromID(ConnectedLink);
|
||||
if (nl == null) break;
|
||||
if (nl == null)
|
||||
break;
|
||||
nPacket.StartOnLink(nl, WhereFrom); //This sends the packet down the link.
|
||||
myNet.addPacket(nPacket);
|
||||
if (tPacket.isFresh)
|
||||
|
@ -1348,13 +1348,6 @@ namespace EduNetworkBuilder
|
||||
if (tPacket.TsourceIP != null && !tPacket.TsourceIP.IsLocal(tPacket.destIP) && !HasBroadcastAddress(tPacket.destIP)) return ResponseToPacket.none;
|
||||
foreach(IPConnectionEntry ipc in IPConnections)
|
||||
{
|
||||
if(ipc.What == PacketType.dhcp_request)
|
||||
{
|
||||
//Console.WriteLine(NB.LeftPad(hostname) + ": packet=" + tPacket.MyType.ToString());
|
||||
//Console.WriteLine(" " + NB.LeftPad(hostname) + ": d:" + ipc.destIP.GetIPString + " s:" + tPacket.sourceIP.GetIPString);
|
||||
//if (HasBroadcastAddress(ipc.destIP))
|
||||
// Console.WriteLine(" Broadcast");
|
||||
}
|
||||
if (ipc.destIP.GetIP == tPacket.sourceIP.GetIP || HasBroadcastAddress(ipc.destIP))
|
||||
{
|
||||
if (ipc.What == PacketType.arp_request && tPacket.MyType == PacketType.arp_answer)
|
||||
@ -1444,15 +1437,16 @@ namespace EduNetworkBuilder
|
||||
|
||||
bool MacAddressMatch = HasMac(tPacket.destMAC);
|
||||
//It is an exact match if it is coming from a local source.
|
||||
bool ExactMatch = HasIPAddress(tPacket.destIP) && (tPacket.TsourceIP == null || tPacket.TsourceIP.IsLocal(tPacket.destIP));
|
||||
bool HasIp = HasIPAddress(tPacket.destIP);
|
||||
bool ExactMatch = HasIp && (tPacket.TsourceIP == null || tPacket.TsourceIP.IsLocal(tPacket.destIP));
|
||||
bool LocalMatch = LocalMatches(tPacket);
|
||||
bool BroadcastMatch = HasBroadcastAddress(tPacket.destIP);
|
||||
bool NeedsRouting = MacAddressMatch && (!ExactMatch && !BroadcastMatch);
|
||||
|
||||
if(ExactMatch || BroadcastMatch || LocalMatch)
|
||||
{
|
||||
//Change this. Need a new ProcessArrival
|
||||
if(tPacket.MyType != PacketType.dhcp_answer) //If it is a match, it should be handled elsewhere
|
||||
//Change this. Need a new ProcessArrival
|
||||
if (tPacket.MyType != PacketType.dhcp_answer) //If it is a match, it should be handled elsewhere
|
||||
ProcessArrival(tPacket);
|
||||
if (ExactMatch && tPacket.isFinshed())
|
||||
return;
|
||||
@ -1483,15 +1477,18 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
//It is a local packet. Let it go out the interface it needs to go out
|
||||
tPacket.OutboundIP = tPacket.destIP;
|
||||
tPacket.TsourceIP = null;
|
||||
}
|
||||
else if(tPacket.destIP.GetIPString != NB.BroadcastIPString)
|
||||
{
|
||||
//it needs to go to a gateway. Set the next destination is the GW
|
||||
tPacket.OutboundIP = dest;
|
||||
tPacket.TsourceIP = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
tPacket.OutboundIP = tPacket.destIP;
|
||||
tPacket.TsourceIP = null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1508,6 +1505,7 @@ namespace EduNetworkBuilder
|
||||
if (arp.MACAddress == tPacket.destMAC)
|
||||
{
|
||||
dNic = NicFromID(arp.NicOnWhichItIsFound);
|
||||
break;
|
||||
}
|
||||
//if (arp.MACAddress == tPacket.sourceMAC)
|
||||
//{
|
||||
@ -1529,7 +1527,7 @@ namespace EduNetworkBuilder
|
||||
// Resume processing at the nic level, not the device level when the arp comes back
|
||||
int count = 0;
|
||||
bool PacketSentOutWAN = false;
|
||||
foreach(NetworkCard nic in NICs)
|
||||
foreach (NetworkCard nic in NICs)
|
||||
{
|
||||
NicType NT = nic.GetNicType;
|
||||
//bridges and waps are basically switches
|
||||
@ -1579,7 +1577,9 @@ namespace EduNetworkBuilder
|
||||
case NicType.port:
|
||||
case NicType.wport:
|
||||
if (PacketSentOutWAN)
|
||||
{
|
||||
continue; //do not send packets out of ports if they have been sent out a WAN nic
|
||||
}
|
||||
NetworkCard tdNic = dNic;
|
||||
if (myType == NetworkComponentType.wrouter)
|
||||
{
|
||||
@ -1660,6 +1660,7 @@ namespace EduNetworkBuilder
|
||||
tPacket.MyStatus = PacketStatus.finished_ok; //It stops here
|
||||
nPacket = tPacket.payloadPacket;
|
||||
NetworkCard nc = LocalNic(nPacket.TsourceIP, true);
|
||||
nPacket.TsourceIP = null;
|
||||
if (nc != null)
|
||||
{
|
||||
if (nPacket != null)
|
||||
@ -2471,6 +2472,7 @@ namespace EduNetworkBuilder
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ForwardsPackets())
|
||||
{
|
||||
if (tPacket.MyType == PacketType.dhcp_request && !isDHCPServer)
|
||||
@ -2872,8 +2874,10 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
if(fwr.Source == inIF && fwr.Destination == outIF)
|
||||
{
|
||||
if (fwr.Action == FirewallRuleType.Allow) return true;
|
||||
if (fwr.Action == FirewallRuleType.Drop) return false;
|
||||
if (fwr.Action == FirewallRuleType.Allow)
|
||||
return true;
|
||||
if (fwr.Action == FirewallRuleType.Drop)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -203,6 +203,13 @@ namespace EduNetworkBuilder
|
||||
NetworkDevice HD = theNet.GetDeviceFromID(AttachedToHostNic);
|
||||
if (HD == null) return; //Oops! Something went wrong.
|
||||
string hostname = HD.hostname;
|
||||
//added to fix the issue with vpns and pings - 11-09-2016
|
||||
//Only do this on non-ports?
|
||||
NetworkCard nic = HD.NicFromID(AttachedToHostNic);
|
||||
if(nic != null && nic.GetNicType != NicType.port && nic.GetNicType != NicType.wport)
|
||||
tPacket.TsourceIP = myIP;
|
||||
if(tPacket.TsourceIP == null || tPacket.TsourceIP.GetIPString == NB.ZeroIPString)
|
||||
tPacket.TsourceIP = myIP;
|
||||
|
||||
if (What == VLANTagType.Forbidden)
|
||||
{
|
||||
@ -224,8 +231,6 @@ namespace EduNetworkBuilder
|
||||
//We actually do not do anything. The tag remains intact.
|
||||
tPacket.VLANID = VI.ID;
|
||||
}
|
||||
//added to fix the issue with vpns and pings - 11-09-2016
|
||||
tPacket.TsourceIP = myIP;
|
||||
}
|
||||
|
||||
private VLANInfo IncomingVLAN(int ID)
|
||||
@ -324,6 +329,9 @@ namespace EduNetworkBuilder
|
||||
if (tPacket.destIP != null && myIP.IsLocal(tPacket.destIP)) isgood = true;
|
||||
if (myIP.NetworkAddress == myIP.GetIP) isgood = true;
|
||||
|
||||
Network MyNet = NB.GetNetwork();
|
||||
NetworkDevice ND = MyNet.GetDeviceFromID(AttachedToHostNic);
|
||||
|
||||
tPacket.InboundInterface = this;
|
||||
|
||||
if(isgood)
|
||||
|
@ -42,7 +42,7 @@ namespace EduNetworkBuilder
|
||||
public int health = 100;
|
||||
public IPAddress sourceIP;
|
||||
public IPAddress OriginalDestIP;
|
||||
public IPAddress TsourceIP;
|
||||
public IPAddress TsourceIP; //This is the local link source ip. It should go along with the local MAC address
|
||||
public IPAddress destIP;
|
||||
public string sourceMAC;
|
||||
public string destMAC;
|
||||
|
Loading…
Reference in New Issue
Block a user