Starting towards traceroute

This commit is contained in:
Tim Young 2017-03-13 10:36:40 +03:00
parent 98c524c1f9
commit 1ebf932edb
5 changed files with 39 additions and 3 deletions

View File

@ -29,7 +29,8 @@ namespace EduNetworkBuilder
} }
public enum VLANTagType { Tagged, Untagged, Forbidden } public enum VLANTagType { Tagged, Untagged, Forbidden }
public enum LinkType { normal, wireless, broken } public enum LinkType { normal, wireless, broken }
public enum PacketType { none, ping_request, ping_answer, arp_request, arp_answer, dhcp_request, dhcp_answer, vpn_packet, tun_packet } public enum PacketType { none, ping_request, ping_answer, arp_request, arp_answer, dhcp_request,
dhcp_answer, vpn_packet, tun_packet, tracert_request, tracert_reply }
public enum ResponseToPacket { none, accept, masq, drop, reject } public enum ResponseToPacket { none, accept, masq, drop, reject }
public enum DebugLevel { none=0, info=1, routing=2, switching=4, natting=8, filtering=16, debug=32 , packet=64, all=127} public enum DebugLevel { none=0, info=1, routing=2, switching=4, natting=8, filtering=16, debug=32 , packet=64, all=127}
public enum NetworkComponentType { none, router, net_switch, net_hub, laptop, pc, server, wap , public enum NetworkComponentType { none, router, net_switch, net_hub, laptop, pc, server, wap ,

View File

@ -617,6 +617,8 @@ namespace EduNetworkBuilder
{ {
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Ping1")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Ping1"));
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_Ping_Click; pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_Ping_Click;
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Traceroute"));
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_Traceroute_Click;
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("H_ARP_Title")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("H_ARP_Title"));
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_Arp_Click; pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_Arp_Click;
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_NetViewClr")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_NetViewClr"));
@ -812,6 +814,21 @@ namespace EduNetworkBuilder
UpdateMessages(); UpdateMessages();
} }
} }
private void pbNetworkView_Traceroute_Click(object sender, EventArgs e)
{
bool todo = true;
if (ItemClickedOn == null) return; //we do not have something chosen to traceroute from
IPAddress destination = new IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only);
todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Traceroute"));
if (todo)
{
//ItemClickedOn.PingFromHere(destination);
//myNetwork.ProcessPackets();
//UpdateMessages();
}
}
private void pbNetworkView_Ping_Name_Click(object sender, EventArgs e) private void pbNetworkView_Ping_Name_Click(object sender, EventArgs e)
{ {
if (ItemClickedOn == null) return; //we do not have something chosen to ping from if (ItemClickedOn == null) return; //we do not have something chosen to ping from

View File

@ -1277,6 +1277,16 @@ namespace EduNetworkBuilder
myNet.addPacket(PingPacket); myNet.addPacket(PingPacket);
} }
public void TracerouteFromHere(IPAddress Destination)
{
//We need to create a packet
Packet TracertPacket = new Packet(this, Destination, NB.Translate("_Traceroute"), PacketType.tracert_request, -1, 1);
Network myNet = NB.GetNetwork();
//string dHost = myNet.ReverseDNSLookup(this, Destination);
//myNet.RegisterPingTest(hostname, dHost);
myNet.addPacket(TracertPacket);
}
public void AskArpFromHere(IPAddress Destination, PacketMessage Tracker=null) public void AskArpFromHere(IPAddress Destination, PacketMessage Tracker=null)
{ {
//We need to create a packet //We need to create a packet

View File

@ -115,7 +115,7 @@ namespace EduNetworkBuilder
} }
//Generate a packet with the given payload. //Generate a packet with the given payload.
public Packet(NetworkComponent start, string source, string dest, string payload, PacketType theType, int NewPacketID=-1) public Packet(NetworkComponent start, string source, string dest, string payload, PacketType theType, int NewPacketID=-1, int startTTL = -1)
{ {
if (NewPacketID == -1) if (NewPacketID == -1)
{ {
@ -125,6 +125,7 @@ namespace EduNetworkBuilder
{ {
packetID = NewPacketID; packetID = NewPacketID;
} }
if (startTTL != -1) this.TTL = startTTL;
WhereAmI = start; WhereAmI = start;
payloadData = payload; payloadData = payload;
MyType = theType; MyType = theType;
@ -154,7 +155,7 @@ namespace EduNetworkBuilder
isFresh = true; isFresh = true;
} }
public Packet(NetworkComponent start, IPAddress dest, string payload, PacketType theType, int NewPacketID = -1) public Packet(NetworkComponent start, IPAddress dest, string payload, PacketType theType, int NewPacketID = -1, int startTTL =-1)
{ {
WhereAmI = start; WhereAmI = start;
payloadData = payload; payloadData = payload;
@ -168,6 +169,9 @@ namespace EduNetworkBuilder
packetID = NewPacketID; packetID = NewPacketID;
} }
if (startTTL != -1) this.TTL = startTTL;
if (theType != PacketType.arp_answer && theType != PacketType.arp_request) if (theType != PacketType.arp_answer && theType != PacketType.arp_request)
{ {
sourceIP = new IPAddress(NB.ZeroIPString); sourceIP = new IPAddress(NB.ZeroIPString);

View File

@ -1657,4 +1657,8 @@
<value>Device cannot respond - Packet Failed</value> <value>Device cannot respond - Packet Failed</value>
<comment>ND_DoInputFromLink_PowerOff = Device cannot respond - Packet Failed</comment> <comment>ND_DoInputFromLink_PowerOff = Device cannot respond - Packet Failed</comment>
</data> </data>
<data name="_Traceroute" xml:space="preserve">
<value>Traceroute</value>
<comment>_Traceroute = Traceroute</comment>
</data>
</root> </root>