Search code examples
javajnetpcap

How can i check the data which is sent out internet?


I want to check data is sent out to the internet. I tried with jnetcap example here

I can use the below code to check receive packages:

PcapPacketHandler<String> jpacketHandler = new PcapPacketHandler<String>() {  

            public void nextPacket(PcapPacket packet, String user) {  

                System.out.printf("Received packet at %s caplen=%-4d len=%-4d %s\n",  
                    new Date(packet.getCaptureHeader().timestampInMillis()),   
                    packet.getCaptureHeader().caplen(),  // Length actually captured  
                    packet.getCaptureHeader().wirelen(), // Original length   
                    user                                 // User supplied object  
                    );  
            }  
        };  

but i did not see any example about sent package? How can i track the sent-package by this api or any similar api (java)

Thanks,


Solution

  • You've misunderstood.

    "Received" in that context means packets "received" from pcap by the application. It doesn't mean packets received by the machine from the network.

    That example captures both incoming and outgoing packets. It's up to you to determine the difference by examining the various protocol headers. See PcapPacket for more info about getting the actual captured data.