trigger multiple spray packets even after the packet is done.

This commit is contained in:
Tim Young 2018-04-04 16:42:32 +03:00
parent 501c08c181
commit 421a6b1a59
4 changed files with 30 additions and 0 deletions

View File

@ -373,6 +373,8 @@ namespace EduNetworkBuilder
public static int NormalRotation = 5; public static int NormalRotation = 5;
public static int PacketDamageDistance = 25; public static int PacketDamageDistance = 25;
public static int NumBadPackets = 3; //the number of packets to spray out
public static string AllowedPasswordCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!~@#$%^&*()_+{}[]/?<>,."; public static string AllowedPasswordCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!~@#$%^&*()_+{}[]/?<>,.";
public static string AllowedUsernameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._"; public static string AllowedUsernameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._";
/// <summary> /// <summary>

View File

@ -60,6 +60,7 @@ namespace EduNetworkBuilder
public bool PuzzleIsSolved = true; //only set to false if we load a puzzle public bool PuzzleIsSolved = true; //only set to false if we load a puzzle
public List<HelpTopics> SuggestedReadings = new List<HelpTopics>(); public List<HelpTopics> SuggestedReadings = new List<HelpTopics>();
private DateTime NetworkStartTime = DateTime.Now; private DateTime NetworkStartTime = DateTime.Now;
private DateTime NextSprayTime = DateTime.Now;
private bool AlreadyChosenTimeout = false; private bool AlreadyChosenTimeout = false;
private int DefaultTimeout = 10; private int DefaultTimeout = 10;
private int NumberOfSecondsForTimeout = 10; private int NumberOfSecondsForTimeout = 10;
@ -1603,6 +1604,20 @@ namespace EduNetworkBuilder
{ {
if (Animations[i].AnimationDone) Animations.RemoveAt(i); if (Animations[i].AnimationDone) Animations.RemoveAt(i);
} }
if(DateTime.Now > NextSprayTime)
{
Random myRnd = NB.GetRandom();
int ms = (myRnd.Next(10) + 2) * 250;
NextSprayTime = DateTime.Now.AddMilliseconds(ms);
foreach(NetworkComponent NC in NetComponents)
{
if(NC is NetworkDevice)
{
NetworkDevice ND = (NetworkDevice)NC;
ND.BadPacketIfIShould();
}
}
}
} }
//if (myPackets.Count > 50) //if (myPackets.Count > 50)
//Console.WriteLine("Packets: " + myPackets.Count.ToString()); //Console.WriteLine("Packets: " + myPackets.Count.ToString());

View File

@ -486,6 +486,7 @@ namespace EduNetworkBuilder
tPacket.Tracking.Status = NB.Translate("N_ProssShouldContinTime"); tPacket.Tracking.Status = NB.Translate("N_ProssShouldContinTime");
tPacket.MyStatus = PacketStatus.finished_failed; tPacket.MyStatus = PacketStatus.finished_failed;
//Then, we make a bad packet go out from here //Then, we make a bad packet go out from here
WhereFrom.BadSprayCount = NB.NumBadPackets;
WhereFrom.BadPacketFromHere(); WhereFrom.BadPacketFromHere();
return false; return false;
} }
@ -773,6 +774,8 @@ namespace EduNetworkBuilder
tPacket.MyStatus = PacketStatus.finished_failed; tPacket.MyStatus = PacketStatus.finished_failed;
//Then, we make a bad packet go out from here //Then, we make a bad packet go out from here
nd.BadPacketFromHere(); nd.BadPacketFromHere();
nd.BadSprayCount = NB.NumBadPackets;
} }
if (mynet.ItemHasTest(nd.hostname,NetTestType.DeviceIsFrozen)) if (mynet.ItemHasTest(nd.hostname,NetTestType.DeviceIsFrozen))
{ {

View File

@ -38,6 +38,7 @@ namespace EduNetworkBuilder
public List<FirewallRule> FirewallRules = new List<FirewallRule>(); public List<FirewallRule> FirewallRules = new List<FirewallRule>();
public bool PowerOff = false; public bool PowerOff = false;
private List<string> tracertmessages = new List<string>(); private List<string> tracertmessages = new List<string>();
public int BadSprayCount = 0;
public NetworkDevice(NetworkComponentType what, string tHostname, Point tLocation, NicType firstNic = NicType.eth) public NetworkDevice(NetworkComponentType what, string tHostname, Point tLocation, NicType firstNic = NicType.eth)
{ {
@ -1594,6 +1595,15 @@ namespace EduNetworkBuilder
myNet.addPacket(BadPacket); myNet.addPacket(BadPacket);
} }
public void BadPacketIfIShould()
{
if(BadSprayCount > 0)
{
BadPacketFromHere();
BadSprayCount--;
}
}
public void TracerouteFromHere(NB_IPAddress Destination) public void TracerouteFromHere(NB_IPAddress Destination)
{ {
//We need to create a traceroute packet - start with 1 TTL //We need to create a traceroute packet - start with 1 TTL