Hi,
I am trying to extend the Simple port Scanner so that it displays the open ports found. For which I made following changes and launched the application. '
But it turned out that the method "handleIncomingPacket" is never getting executed?
Does that mean the server is not replying? ( I have profiled a server with Echo Server profile)
Or is there a fault in the logic?
importde.dailab.nessi.core.api.annotations.Description;importde.dailab.nessi.core.api.annotations.IntegerField;importde.dailab.nessi.core.api.annotations.StringField;importde.dailab.nessi.core.api.events.Event;importde.dailab.nessi.core.api.events.TickedEvent;importde.dailab.nessi.ip.api.address.IPFactory;importde.dailab.nessi.ip.api.address.IPv4Address;importde.dailab.nessi.ip.api.layer.ILayerHandler;importde.dailab.nessi.ip.api.layer.ITransportLayer;importde.dailab.nessi.ip.api.protocols.Packet;importde.dailab.nessi.ip.api.protocols.ip.IPv4Header;importde.dailab.nessi.ip.api.protocols.udp.UDPHeader;importde.dailab.nessi.ip.handler.IPApplication;importjava.util.Random;publicclassPort_AKextendsIPApplication{publicPort_AK(){startPort=1;endPort=1024;targetIp="0.0.0.0";startTick=100;System.out.print("Inside constructor ");}publicvoidhandleEvent(Evente){System.out.print("Insie handleevent ");Randomran=newRandom(123L);for(inti=startPort;i<endPort;i++){System.out.print("Inside for loop ");bytepayload[]=newbyte[28];ran.nextBytes(payload);getLayerHandler().getTransportLayer().sendUDPPacket(7,i,destinationIP,payload);}System.out.print("Exiting handle event ");//super.handleEvent(e);}publicbooleanstart(){System.out.print("Inside start ");destinationIP=IPFactory.createIPv4Address(targetIp);TickedEvente=newTickedEvent(this,startTick);getLayerHandler().addEvent(e);System.out.print("Exiing start ");returnsuper.start();}@OverridepublicvoidhandleIncomingPacket(Packetpacket){System.out.print("Inside handle incoming packets ");IPv4HeaderipHeader=packet.findHeader(IPv4Header.class);UDPHeaderudpHeader=packet.findHeader(UDPHeader.class);if(ipHeader==null||udpHeader==null){return;}System.out.print("The port replied back is ");System.out.println(udpHeader.getSourcePort());}@IntegerField("Start Port")@Description("Start Port number")privateintstartPort;@IntegerField("End Port")@Description("End")privateintendPort;@StringField("IP Address")privateStringtargetIp;privateintstartTick;privateIPv4AddressdestinationIP;}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What do you mean by launched the application? Did you add your implemented application to profile and placed in the profile on a node in the network before launching a new simulation?
Also from the Javadoc of handleIncomingPacket: "Called when a packet arrives. It is only used for normal applications which have registered a UDP port (see
ITransportLayer#registerUDPPort(int, IIPApplication)). This should preferably be done by overriding the start method."
I could not see that you registered any port.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, by launching I mean : I created a elipse/maven prject with above source code. Then "mvn clean install". Then copied the .jar file into nessi backend and gui application folder. Then built a plug in project in Nessi2 GUI and placed this newly generatd appliction(profile) into a node. Then launched the simulation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am trying to extend the Simple port Scanner so that it displays the open ports found. For which I made following changes and launched the application. '
But it turned out that the method "handleIncomingPacket" is never getting executed?
What do you mean by launched the application? Did you add your implemented application to profile and placed in the profile on a node in the network before launching a new simulation?
Also from the Javadoc of handleIncomingPacket: "Called when a packet arrives. It is only used for normal applications which have registered a UDP port (see
ITransportLayer#registerUDPPort(int, IIPApplication)). This should preferably be done by overriding the start method."
I could not see that you registered any port.
Yes, by launching I mean : I created a elipse/maven prject with above source code. Then "mvn clean install". Then copied the .jar file into nessi backend and gui application folder. Then built a plug in project in Nessi2 GUI and placed this newly generatd appliction(profile) into a node. Then launched the simulation.
Thanks for the reply... I will try out your suggestions