How to interpret packets?
I have developed a program using JPCAP in java,which will capture packets and display it received by my pc but the problem is that output is not understandable by me
when i execute that program and enter the url address in web browser say Google.com,it displays me output like this
1277469255:706879
1277469255:708581
what does it means?Is there any possible way to extract header ,length ,type of packet and data that resides in that program
This is my program
when i execute that program and enter the url address in web browser say Google.com,it displays me output like this
1277469255:706879
1277469255:708581
what does it means?Is there any possible way to extract header ,length ,type of packet and data that resides in that program
This is my program
import jpcap.*; import jpcap.packet.*; import java.io.*; import jpcap.packet.TCPPacket.*; import java.net.InetAddress; class NetworkList { public static void main(String args[])throws IOException { int i; try { NetworkInterface[] devices = JpcapCaptor.getDeviceList(); for (i = 0; i < devices.length; i++) { //print out its name and description System.out.println(i+": "+devices[i].name + "(" + devices[i].description+")"+devices[i].loopback); } JpcapCaptor captor=JpcapCaptor.openDevice(devices[0], 65535, false, 20); for(i=0;i<10;i++){ System.out.println(captor.getPacket()); } captor.close(); } catch(Exception e) { System.out.println(e.getMessage()); } } }I have also tried using captor.getPacket().data ,but then it throws null exception
Replies
-
Manish Goyalguys i have achieved what i want 😀 I have used 2nd method ie callback method for this
but still confused why there was exception in first case when i try to capture packets one by one -
durga chdid you try to goggle then with the error message you received?
To interpret packets may be you can refer to this thread #-Link-Snipped-# -
Manish Goyalyeah i had searched on google about this ..
But the error was same that i commonly encountered during programming in java
ie null -
Manish GoyalNow again there is new problem
Previously when i was using my broadband connection for accessing internet .I was able to capture packets, received by my system.
but now when i am accessing internet using my mobile as a modem(usb modem) ,i am not able to see even single packet .
can anyone explain me what's the reason? -
durga chUSB port numbers are different from your Ethernet port number right?
can you explain your program above? I am a JAVA illeterate -
Manish GoyalI have used jpcap which is a open source library for capturing and sending packets from java applications
To get the List of network Interfaces of my machine.jpcap provides JpcapCaptor.getDeviceList() method which is static method of JpcapCaptor class.It will return array of NetworkInterface objects and by using the fields of NetworkInterface class ,I can retrieve each and every information of networkinterface of my machine.
JpcapCaptor captor=JpcapCaptor.openDevice(device[index], 65535, false, 20);
Once we obtain the list of network interfaces and choose which network interface to capture packets from, you can open the interface by
using jpcap.opendevice() method
while calling openDevice(),we provide following parameters
NetworkInterface interface:-NetworkInterface which you want to open
int no:-Max no of bytes to cpature
boolean promics :-Whether to open device in promiscuous mode or not
int time_out:-to set capture time_out value
Once you obtain an instance of of jpcapcaptor,you can capture packets from the interface.
There are two major approaches to capture packets using a #-Link-Snipped-#
instance: using a callback method, and capturing packets one-by-one
In callback method we implement the interface named PacketReceiver then create a method named which will handle the packets gernerated
For capturing packets we can use either processPacket() or loopPacket() method.
For each captured packet it will call the method which i have created to handle that packet
and in one by one approach .I will simply create a loop and capture packets by using getPacket() method
I hope,you got an idea
If still confused then post your query -
durga chalright
By what you have said - since its our network interface device has changed < i think the problem might be here
"while calling openDevice(),we provide following parameters
NetworkInterface interface:-NetworkInterface which you want to open
int no:-Max no of bytes to cpature
boolean promics :-Whether to open device in promiscuous mode or not
int time_out:-to set capture time_out value"
this is a just a inference though. -
Manish GoyalBut when i execute my program there is only one networkInterface it is showing on output, which i can open
-
durga ch..and which network interface does it show?
-
Manish GoyalVIA RHINE II Fast Ethernet Adapter
-
Manish GoyalI think the problem is with net connection .I am not sure whether this program works on dial up connection or not
You are reading an archived discussion.
Related Posts
This is the question which has been striking in mind for a long time,I want to know the concept used behind working of fackbook (or any social networking site )....
I sometimes think that people actually enjoy corporate politics, insanity at work and cribbing about it almost every day. It gives them something to talk about apart from work.
Now,...
i am an instrumentation engineering student i need some good projects... please help me... mail me to
hi friends,i want to learn matlab,
plz help me what should i do for this
Hullo friends. I want to make a navigation system for the blind using RFID tags. Like they will have a RFID reader with them and can easily access the information...