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?
1. Does that mean the server is not replying? ( I have profiled a server with Echo Server profile)
2. 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;}
Last edit: Amit Khandelwal 2017-03-04
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?
1. Does that mean the server is not replying? ( I have profiled a server with Echo Server profile)
2. Or is there a fault in the logic?
Last edit: Amit Khandelwal 2017-03-04
See https://sourceforge.net/p/nessi2/discussion/Open/thread/8fddaa9a/?limit=25