last tracert packet has summary of whole tracert.

This commit is contained in:
Tim Young 2017-06-08 10:47:57 -05:00
parent fe42364f4d
commit 0886c46c6e

View File

@ -36,6 +36,7 @@ namespace EduNetworkBuilder
protected Color MorphColor = Color.Empty;
public List<FirewallRule> FirewallRules = new List<FirewallRule>();
public bool PowerOff = false;
private List<string> tracertmessages = new List<string>();
public NetworkDevice(NetworkComponentType what, string tHostname, Point tLocation, NicType firstNic = NicType.eth)
{
@ -1294,6 +1295,7 @@ namespace EduNetworkBuilder
Packet TracertPacket = new Packet(this, Destination, Destination.GetIPString, PacketType.tracert_request, -1, 1);
Network myNet = NB.GetNetwork();
myNet.addPacket(TracertPacket);
tracertmessages.Clear(); //Start with a fresh bunch of messages
}
public void AskArpFromHere(IPAddress Destination, PacketMessage Tracker=null)
@ -1851,9 +1853,6 @@ namespace EduNetworkBuilder
ResponseToPacket response = HowToRespondToPacket(tPacket);
if (response == ResponseToPacket.none || response == ResponseToPacket.masq) return; //We do not do anything with it here.
//The reply got here. This packet is done
tPacket.AddMessage(DebugLevel.info, NB.Translate("ND_ProcessArrival_TracertReply") + " " + tPacket.sourceIP.GetIPString);
tPacket.Tracking.Status = NB.LeftPad(hostname) + " " + string.Format(NB.Translate("ND_ProcessArrival_TracertReply") + " " + tPacket.sourceIP.GetIPString);
tPacket.MyStatus = PacketStatus.finished_ok;
IPAddress origStart = new IPAddress(tPacket.payloadData);
int ttl = tPacket.OrigTTL + 1;
@ -1861,6 +1860,8 @@ namespace EduNetworkBuilder
//Console.WriteLine("Tracert: " + tPacket.OrigTTL + " " + tPacket.sourceIP.GetIPString);
//Console.WriteLine("Tracert: -- " + tPacket.sourceIP.GetIPString + " " + origStart.GetIPString);
//If we had not landed on the actual dest...
tracertmessages.Add(NB.Translate("ND_ProcessArrival_TracertReply") + " " + tPacket.sourceIP.GetIPString);
if (tPacket.sourceIP.GetIPString != origStart.GetIPString && ttl < 10)
{
Packet trPacket = new Packet(this, origStart, origStart.GetIPString, PacketType.tracert_request, -1, ttl);
@ -1870,7 +1871,17 @@ namespace EduNetworkBuilder
if (tPacket.sourceIP.GetIPString == origStart.GetIPString)
{
myNet.NotePacketArrived(tPacket.MyType, this, tPacket.destIP, tPacket.sourceIP, tPacket.packetID);
foreach(string message in tracertmessages)
{
tPacket.Tracking.AddMessage(DebugLevel.info, this, message);
Console.WriteLine(message);
}
tracertmessages.Clear();
}
tPacket.AddMessage(DebugLevel.info, NB.Translate("ND_ProcessArrival_TracertReply") + " " + tPacket.sourceIP.GetIPString);
tPacket.Tracking.Status = NB.LeftPad(hostname) + " " + string.Format(NB.Translate("ND_ProcessArrival_TracertReply") + " " + tPacket.sourceIP.GetIPString);
tPacket.MyStatus = PacketStatus.finished_ok;
return;
}
if (tPacket.MyType == PacketType.arp_request)