import jpcap.JpcapCaptor; import jpcap.NetworkInterface; import jpcap.NetworkInterfaceAddress; import java.io.IOException; import java.util.Scanner; import javax.swing.JFrame; public class PacketAnalyser { static String text=""; public String capture(){ try { captor=JpcapCaptor.openDevice(devices[index], 65535, true, 20); long[] packs = new long[20]; int tcp = 0; int udp = 1; for(int j = 0;j<10;j++){ long count1 = 0; long count2 = 0; captor.setFilter("tcp and ip", true); for(int i=0;i<10;i++){ text1=text1+captor.getPacket()+"\n"; if(captor.getPacket()!=null){count1++;}} text1=text1+captor.dropped_packets + " packets dropped by kernel\n"; text1=text1+count1+"\n" ; captor.setFilter("udp and ip", true); for(int i=0;i<10;i++){ text1=text1+captor.getPacket()+"\n" ; if(captor.getPacket()!=null){count2++;} } text1=text1+captor.dropped_packets + " packets dropped by kernel\n"; text1=text1+count2+"\n"; packs[tcp]=count1; packs[udp]=count2; tcp+=2; udp+=2; } captor.close(); return text1; }}
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)