Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

"packet length" or "captured length" in "Jpcap" library !?

Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I recently downloaded the jpcap library and read all docs and
I want to develop a very simple application just calculates the total
traffic (send/receive) on my network interface.
But i don't know which parameter i should consider, and i know this is
because of my knowledge lack in (inter)networking.
Also i don't know which types of packet i should consider(just guess
something,e.g:i should survey every packet for destination & source
address and if source are my address and destination is my router(or other
clients in LAN) i should not increment the total bytes with this packet's length or captured length

I also tried in last two days to find out resources in web(Google /Wikipedia) to find out what are all kinds of packets and didn't found anything useful .Although i learned some types from the API documentations (such IPPacket including TCPPacket, ICMPPacket, UDPPacket or ARPPacket and one or two more),so ,while i think i know how to capture packets and even how to filter them, but i am confusing about which packets i should consider for my goal (to just counting traffic to/from Internet).

And in this API there is two field in class packet: caplen as "captured length" and len as "packet length" and i used the example application "Jpcapdumper" and i see when it captures packets, in udp packets, the "packet length" and the "captured length" are different (captured length is bigger than packet length)

Thus i need you people to help
Sorry for long writing

Thanks in advance
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think you should brush up your networking knowledge because it's upto you what type of packets you want to capture.
You can find here, what type of packets you can capture.
Like for internet, you want to capture all the http packets, then you know that all request goes through port 80.
So, connect to that interface and filter packets on port 80.
You can use this for help :

And if you want to capture all the traffic of internet coming and going through your PC then,
connect to the interface that is associated with your internet, e.g., eth0.

Hope this helped
Esmaeil Ashrafi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for answering...
I posted this a while ago,however i wrote my application and by studying precisely on filter expression from libpcap/winpcap documentations i create the best filter based on my needs.
But beside the question "which packets..." about the library, my another main question was about what is captured length in compare with packet length and i posted this topic to SDN and finally figure out that i should read throughly the tcpdump documentation as soon as i can...

if you can briefly explain what is the difference would be great

Thank you very much
him jain
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Captured length is the length of your received packet and
packet length is the length of packet specified by you means how much bytes at maximum you want to capture.
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic