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; protected Color MorphColor = Color.Empty;
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>();
public NetworkDevice(NetworkComponentType what, string tHostname, Point tLocation, NicType firstNic = NicType.eth) 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); Packet TracertPacket = new Packet(this, Destination, Destination.GetIPString, PacketType.tracert_request, -1, 1);
Network myNet = NB.GetNetwork(); Network myNet = NB.GetNetwork();
myNet.addPacket(TracertPacket); myNet.addPacket(TracertPacket);
tracertmessages.Clear(); //Start with a fresh bunch of messages
} }
public void AskArpFromHere(IPAddress Destination, PacketMessage Tracker=null) public void AskArpFromHere(IPAddress Destination, PacketMessage Tracker=null)
@ -1851,9 +1853,6 @@ namespace EduNetworkBuilder
ResponseToPacket response = HowToRespondToPacket(tPacket); ResponseToPacket response = HowToRespondToPacket(tPacket);
if (response == ResponseToPacket.none || response == ResponseToPacket.masq) return; //We do not do anything with it here. if (response == ResponseToPacket.none || response == ResponseToPacket.masq) return; //We do not do anything with it here.
//The reply got here. This packet is done //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); IPAddress origStart = new IPAddress(tPacket.payloadData);
int ttl = tPacket.OrigTTL + 1; int ttl = tPacket.OrigTTL + 1;
@ -1861,6 +1860,8 @@ namespace EduNetworkBuilder
//Console.WriteLine("Tracert: " + tPacket.OrigTTL + " " + tPacket.sourceIP.GetIPString); //Console.WriteLine("Tracert: " + tPacket.OrigTTL + " " + tPacket.sourceIP.GetIPString);
//Console.WriteLine("Tracert: -- " + tPacket.sourceIP.GetIPString + " " + origStart.GetIPString); //Console.WriteLine("Tracert: -- " + tPacket.sourceIP.GetIPString + " " + origStart.GetIPString);
//If we had not landed on the actual dest... //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) if (tPacket.sourceIP.GetIPString != origStart.GetIPString && ttl < 10)
{ {
Packet trPacket = new Packet(this, origStart, origStart.GetIPString, PacketType.tracert_request, -1, ttl); 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) if (tPacket.sourceIP.GetIPString == origStart.GetIPString)
{ {
myNet.NotePacketArrived(tPacket.MyType, this, tPacket.destIP, tPacket.sourceIP, tPacket.packetID); 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; return;
} }
if (tPacket.MyType == PacketType.arp_request) if (tPacket.MyType == PacketType.arp_request)