microwave and light now corrupt packets.
This commit is contained in:
parent
8c2c1c4109
commit
e24d9fd8c1
@ -983,6 +983,7 @@ namespace EduNetworkBuilder
|
||||
tList.Sort();
|
||||
return tList;
|
||||
}
|
||||
|
||||
public List<string> GetBroadcasts()
|
||||
{
|
||||
List<string> tList = new List<string>();
|
||||
@ -1065,6 +1066,44 @@ namespace EduNetworkBuilder
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool DeviceIsOverDamaging(LinkType myLink, Point location)
|
||||
{
|
||||
NetworkDevice ND;
|
||||
int countDistance = 25;
|
||||
double HowFar;
|
||||
foreach(NetworkComponent NC in NetComponents)
|
||||
{
|
||||
if (NB.GetComponentType(NC) == GeneralComponentType.device)
|
||||
{
|
||||
ND = (NetworkDevice)NC;
|
||||
if(myLink == LinkType.wireless && ND.GetNetType() == NetworkComponentType.microwave)
|
||||
{
|
||||
HowFar = distance(location, ND.myLocation());
|
||||
//Console.WriteLine("position=" + HowFar.ToString());
|
||||
if (HowFar < countDistance)
|
||||
if (HowFar < countDistance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (myLink != LinkType.wireless && ND.GetNetType() == NetworkComponentType.fluorescent)
|
||||
{
|
||||
HowFar = distance(location, ND.myLocation());
|
||||
//Console.WriteLine("position=" + HowFar.ToString());
|
||||
if (HowFar < countDistance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public double distance(Point start, Point dest)
|
||||
{
|
||||
return Math.Sqrt(Math.Pow((start.X - dest.X),2) + Math.Pow((start.Y - dest.Y),2)) / 5; //use grid size...
|
||||
}
|
||||
|
||||
|
||||
/****************************************
|
||||
|
@ -563,7 +563,10 @@ namespace EduNetworkBuilder
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public Point myLocation()
|
||||
{
|
||||
return MyLocation;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns the centerpoint of the device
|
||||
/// </summary>
|
||||
@ -1382,16 +1385,26 @@ namespace EduNetworkBuilder
|
||||
ResponseToPacket response = HowToRespondToPacket(tPacket);
|
||||
if (response == ResponseToPacket.accept || HasIPAddress(tPacket.destIP))
|
||||
{
|
||||
tPacket.AddMessage(DebugLevel.info, "Success! The ping returned from its destination.");
|
||||
tPacket.Tracking.Status = hostname + ":\tPing success: The ping returned from its destination" + tPacket.sourceIP.GetIP.ToIpString() + " -> " + tPacket.destIP.GetIP.ToIpString();
|
||||
tPacket.MyStatus = PacketStatus.finished_ok;
|
||||
if (tPacket.sourceIP.GetIP != 0)
|
||||
if (tPacket.health < 100)
|
||||
{
|
||||
myNet.NotePacketArrived(tPacket.MyType, this, tPacket.destIP, tPacket.OriginalDestIP);
|
||||
tPacket.AddMessage(DebugLevel.info, "Success! The ping returned from its destination." + " But some was lost: health=" + tPacket.health.ToString() );
|
||||
int left = 100 - tPacket.health;
|
||||
tPacket.Tracking.Status = hostname + string.Format(":\tPing partial success: {0}% packet loss. {1} -> {2}", left , tPacket.sourceIP.GetIP.ToIpString(),tPacket.destIP.GetIP.ToIpString());
|
||||
tPacket.MyStatus = PacketStatus.finished_ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
myNet.NotePacketArrived(tPacket.MyType, this, tPacket.destIP, tPacket.sourceIP);
|
||||
tPacket.AddMessage(DebugLevel.info, "Success! The ping returned from its destination.");
|
||||
tPacket.Tracking.Status = hostname + ":\tPing success: The ping returned from its destination" + tPacket.sourceIP.GetIP.ToIpString() + " -> " + tPacket.destIP.GetIP.ToIpString();
|
||||
tPacket.MyStatus = PacketStatus.finished_ok;
|
||||
if (tPacket.sourceIP.GetIP != 0)
|
||||
{
|
||||
myNet.NotePacketArrived(tPacket.MyType, this, tPacket.destIP, tPacket.OriginalDestIP);
|
||||
}
|
||||
else
|
||||
{
|
||||
myNet.NotePacketArrived(tPacket.MyType, this, tPacket.destIP, tPacket.sourceIP);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -193,6 +193,19 @@ namespace EduNetworkBuilder
|
||||
Network myNet = NB.GetNetwork();
|
||||
HostNicID target;
|
||||
tPacket.IncrementDistance();
|
||||
Point newLocation = PositionOnLine(tPacket.myDirection, tPacket.myLinkPercent);
|
||||
if (myNet.DeviceIsOverDamaging(theLinkType, newLocation))
|
||||
{
|
||||
tPacket.health -= 10;
|
||||
//Console.WriteLine(" health=" + tPacket.health.ToString());
|
||||
}
|
||||
if(tPacket.health <= 0)
|
||||
{
|
||||
//The link is broken. Drop the packet
|
||||
tPacket.Tracking.AddMessage(DebugLevel.info, this, "The packet was corrupted. The network wire may run too close to electricity or fluorescent lighting, or the wireless path is being interfered by a microwave, wireless phone, or other radio device.");
|
||||
tPacket.Tracking.Status = "The packet got corrupted and was dropped.";
|
||||
tPacket.MyStatus = PacketStatus.finished_failed;
|
||||
}
|
||||
if(theLinkType == LinkType.broken && tPacket.myLinkPercent > 50)
|
||||
{
|
||||
//The link is broken. Drop the packet
|
||||
|
@ -33,6 +33,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
public int TTL = 20;
|
||||
public int TickTTL = 50;
|
||||
public int health = 100;
|
||||
public IPAddress sourceIP;
|
||||
public IPAddress OriginalDestIP;
|
||||
public IPAddress TsourceIP;
|
||||
@ -96,6 +97,7 @@ namespace EduNetworkBuilder
|
||||
payloadIP = copyfrom.payloadIP;
|
||||
Tracking = copyfrom.Tracking;
|
||||
WhereAmI = copyfrom.WhereAmI;
|
||||
health = copyfrom.health;
|
||||
StartTime = copyfrom.StartTime;
|
||||
OriginalDestIP = copyfrom.OriginalDestIP;
|
||||
Tracking.AddMessage(DebugLevel.debug, WhereAmI, "Packet duplicated");
|
||||
|
Loading…
Reference in New Issue
Block a user