View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12913 Members
Join this group to post and comment.

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
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
guys 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 ch
durga ch • Jun 27, 2010
did you try to goggle then with the error message you received?

To interpret packets may be you can refer to this thread https://www.crazyengineers.com/forum/computer-science-engineering/32644-tcp-ip-design-breakdown.html
yeah i had searched on google about this ..
But the error was same that i commonly encountered during programming in java

ie null
Now 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 ch
durga ch • Jun 28, 2010
USB port numbers are different from your Ethernet port number right?
can you explain your program above? I am a JAVA illeterate
I 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 JpcapCaptor
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 ch
durga ch • Jun 29, 2010
alright
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.
But when i execute my program there is only one networkInterface it is showing on output, which i can open
durga ch
durga ch • Jun 29, 2010
..and which network interface does it show?
VIA RHINE II Fast Ethernet Adapter
I think the problem is with net connection .I am not sure whether this program works on dial up connection or not

Share this content on your social channels -