Forum Topic - strange behavior of using pcap.h:
   
strange behavior of using pcap.h  
Dear All,

Fortunately I was able to use pcap.h to capture packet in QNX. I am using below command to open a session

/* Open the session in promiscuous mode */
handle = pcap_open_live(dev, 65536, 1, 1000, errbuf);


I am also using below commands to capture and store packets

for(i=0;i<32000;i++)
	{
		packet=pcap_next(handle, &header);
		local_tv_sec = header.ts.tv_sec;
		ltime=localtime(&local_tv_sec);
		strftime( timestr, sizeof(timestr), "%H:%M:%S", ltime);
		fprintf(stream1,"%s,%.6d len:%d\n", timestr, header.ts.tv_usec, header.len);
	}

I have a testing device which sends two packets per 250usec. Therefore, I am expecting to capture packets in the same 
trend.

By the way, two network cards are connected to my QNX target machine and I am using one of them only for data capturing 
from tester.

let's see some part of the captured data. Instead of getting two packets every 250usec I am getting 64 to 65 packets 
every 8389 usec. Is there anything wrong with the settings or netwrok driver in QNX. I tested the same network card in 
windows XP embedded with winpcap and it was working very well. I would be very thankful if you help me.

10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,599566 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955 len:121
10:23:11,607955...
View Full Message
RE: strange behavior of using pcap.h  
> I am getting 64 to 65 packets every 8389 usec.

I think the system time which localtime() is 
fetching is only being updated every 10ms timer 
tick.

I think you want a better timestamp - try 
clockcycles() or something like that.

--
aboyd
Re: strange behavior of using pcap.h  
On Tue, Jul 28, 2009 at 10:51:19AM -0400, Mohammad Dadashzadeh wrote:
> Dear All,
> let's see some part of the captured data. Instead of getting two packets every 250usec I am getting 64 to 65 packets 
every 8389 usec. Is there anything wrong with the settings or netwrok driver in QNX. I tested the same network card in 
windows XP embedded with winpcap and it was working very well. I would be very thankful if you help me.

That's the clockrate in io-pkt:

# sysctl kern.clockrate
kern.clockrate: tick = 8403, hz = 119

-seanb
Re: strange behavior of using pcap.h  
can I change it?
Re: strange behavior of using pcap.h  
On Tue, Jul 28, 2009 at 11:14:11AM -0400, Mohammad Dadashzadeh wrote:
> can I change it?

It would involve a re-compile.

Regards,

-seanb
Re: strange behavior of using pcap.h  
Sorry I did not get it,

Recompile of what, Could you please let me know How I can do it?

Regards,
Mohammad
Re: strange behavior of using pcap.h  
On Tue, Jul 28, 2009 at 11:18:22AM -0400, Mohammad Dadashzadeh wrote:
> Sorry I did not get it,
> 
> Recompile of what, Could you please let me know How I can do it?

You'd need to check out the source from the networking
repo and follow the instructions here:

http://community.qnx.com/sf/wiki/do/viewPage/projects.networking/wiki/Source_Guide

The defines that control this are in io-pkt/sys/sys/time_bsd.h
(look for __QNXNTO__)

Regards,

-seanb
Re: strange behavior of using pcap.h  
Could I do this in evaluation version where I have QNX Momentics IDE Version 4.6.0?

Mohammad



Re: strange behavior of using pcap.h  
> Could I do this in evaluation version where I have QNX Momentics IDE Version 4
> .6.0?
> 
> Mohammad
> 
> 
> 


Should I have website downloader to download all the files.
http://community.qnx.com/svn/repos/coreos_pub/trunk/

Mohammad
Re: strange behavior of using pcap.h  
when I use my user name in this command it does not work?

 svn checkout --username <username> http://community.qnx.com/svn/repos/coreos_pub/trunk


Mohammad
Re: strange behavior of using pcap.h  
> when I use my user name in this command it does not work?
> 
>  svn checkout --username <username> http://community.qnx.com/svn/repos/coreos_pub/trunk
> 
> 
> Mohammad


it shows :

PRPOFIND request failed on .......
........... 405 method Not allowed
Re: strange behavior of using pcap.h  
I am trying to recompile the source based on below document

http://community.qnx.com/sf/sfmain/do/downloadAttachment/projects.core_os/wiki/BuildKernelWithIDE?id=atch1253


at the end when I run it says:

/cygdrive/c/QNX641/workspace not a directory


Re: strange behavior of using pcap.h  
On Tue, Jul 28, 2009 at 05:13:12PM -0400, Mohammad Dadashzadeh wrote:
> I am trying to recompile the source based on below document
> 
> http://community.qnx.com/sf/sfmain/do/downloadAttachment/projects.core_os/wiki/BuildKernelWithIDE?id=atch1253
> 
> 
> at the end when I run it says:
> 
> /cygdrive/c/QNX641/workspace not a directory

I'm not sure that applies to the networking source...
I've never tried building under the IDE but a
straight 'make' as described here should work.

http://community.qnx.com/sf/wiki/do/viewPage/projects.networking/wiki/Source_Guide

Regards,

-seanb
Re: strange behavior of using pcap.h  
> On Tue, Jul 28, 2009 at 05:13:12PM -0400, Mohammad Dadashzadeh wrote:
> > I am trying to recompile the source based on below document
> > 
> > http://community.qnx.com/sf/sfmain/do/downloadAttachment/projects.core_os/
> wiki/BuildKernelWithIDE?id=atch1253
> > 
> > 
> > at the end when I run it says:
> > 
> > /cygdrive/c/QNX641/workspace not a directory
> 
> I'm not sure that applies to the networking source...
> I've never tried building under the IDE but a
> straight 'make' as described here should work.
> 
> http://community.qnx.com/sf/wiki/do/viewPage/projects.networking/wiki/
> Source_Guide
> 
> Regards,
> 
> -seanb


Should I do this in QNX machine or in development machine I am really confused.
Should I rebuild the entire OS or just Networking core.
svn command works in QNX machine not in development machine.

Regards,
Mohammad


Re: strange behavior of using pcap.h  
On Wed, Jul 29, 2009 at 10:30:40AM -0400, Mohammad Dadashzadeh wrote:
> > On Tue, Jul 28, 2009 at 05:13:12PM -0400, Mohammad Dadashzadeh wrote:
> > > I am trying to recompile the source based on below document
> > > 
> > > http://community.qnx.com/sf/sfmain/do/downloadAttachment/projects.core_os/
> > wiki/BuildKernelWithIDE?id=atch1253
> > > 
> > > 
> > > at the end when I run it says:
> > > 
> > > /cygdrive/c/QNX641/workspace not a directory
> > 
> > I'm not sure that applies to the networking source...
> > I've never tried building under the IDE but a
> > straight 'make' as described here should work.
> > 
> > http://community.qnx.com/sf/wiki/do/viewPage/projects.networking/wiki/
> > Source_Guide
> > 
> > Regards,
> > 
> > -seanb
> 
> 
> Should I do this in QNX machine or in development machine I am really confused.
> Should I rebuild the entire OS or just Networking core.
> svn command works in QNX machine not in development machine.

The development machine (note a QNX machine can also
be a development machine).  For this particular issue
only the io-pkt binary need to be touched but it's
often easier to build the entire networking tree as
described in the above link.

Regards,

-seanb
Re: strange behavior of using pcap.h  
in order to change the 8.39 msec to 32 usec

this is the default
 * 2^23ns = 2^23ns * (1000ms / 10^9ns) = 8.39ms = 119.209Hz
 */
#define NTO_TSHIFT 23
#define NTO_HZ 119
#define NTO_mHZ 119209

I am going to change it to

 * 2^15ns = 2^15ns * (1000ms / 10^9ns) = 32.77us = 30517.578Hz
 */
#define NTO_TSHIFT 15
#define NTO_HZ 30517
#define NTO_mHZ 30517578

and then compile,

is this correct?

Mohammad
Re: strange behavior of using pcap.h  
that is correct but probably it won't work as many places are assuming 1 HZ is 8ms but now it is not. but you could try.
Re: strange behavior of using pcap.h  
I downloaded kernel source from
svn checkout --username <username> http://community.qnx.com/svn/repos/coreos_pub/trunk

and followed all the instructions and was able to compile and build the OS.

Now should I download all the below links or one of the is enough?

 svn checkout --username <userid> http://community.qnx.com/svn/repos/core_networking/trunk

Where <userid> is the email address used to create your account on the QNX site.

To check out the 6.4.0 GA release branch source, use

svn checkout --username <userid> http://community.qnx.com/svn/repos/core_networking/tags/6.4.0/GA

To check out the 6.4.0 maintenance branch source (which includes critical fixes to the GA release), use

svn checkout --username <userid> http://community.qnx.com/svn/repos/core_networking/branches/6.4.0/trunk 

Mohammad
Re: strange behavior of using pcap.h  
what do you want to do? recompile io-pkt or the whole OS?
Re: strange behavior of using pcap.h  
recompile  io-pkt
Re: strange behavior of using pcap.h  
On an X86 (at least), the clock interrupts happen at a rate close to one per millisecond, so you can never achieve a 
pcap timestamp resolution better than about one millisecond.

If what you're after is better resolution, it might be easier to just build your own bpf.c.


Murf
Re: strange behavior of using pcap.h  
> On an X86 (at least), the clock interrupts happen at a rate close to one per 
> millisecond, so you can never achieve a pcap timestamp resolution better than 
> about one millisecond.
> 
> If what you're after is better resolution, it might be easier to just build 
> your own bpf.c.
> 
> 
> Murf


From where should I start to learn how to write my own bpf.c file. I was getting very good resolution in win XP using 
winpcap.

Regards,
Mohammad
Re: strange behavior of using pcap.h  
Take a look at sys/net/bpf.c in the networking trunk. I believe it sets the timestamp via a call to microtime, which is 
in sys/currenttime.c, which calsl mtime in the same file), which get the current time, then maks off a bunch of the 
least significant digits.

I may be way off base here, and this might just lead you into another round of "what's going on here?", but I'd sure 
take a look at the other possibilities before I tried to rebuild all of io-pkt with a rather fundamental change --- but 
that's just me.


Murf
Re: strange behavior of using pcap.h  
On Wed, Jul 29, 2009 at 11:58:55AM -0400, John Murphy wrote:
> Take a look at sys/net/bpf.c in the networking trunk. I believe it sets the timestamp via a call to microtime, which 
is in sys/currenttime.c, which calsl mtime in the same file), which get the current time, then maks off a bunch of the 
least significant digits.
> 
> I may be way off base here, and this might just lead you into another round of "what's going on here?", but I'd sure 
take a look at the other possibilities before I tried to rebuild all of io-pkt with a rather fundamental change --- but 
that's just me.

It seems to boil down to pcap_open_live() taking a timeout
the smallest value of which boils down to HZ in the stack
(stack rounds up to that value).  A value of zero means wait
until the buffer's full.  There's a BIOCIMMEDIATE bpf ioctl
that would probably help here but libpcap currently only
uses it for AIX.

Soo... The easier 'fix' would be to set BIOCIMMEDIATE in
pcap_open_live() if the timeout is less than a tick which
you can get from sysctl() / sysctlbyname().

-seanb
Re: strange behavior of using pcap.h  
Sean,  are we talking about the resolution of the timestamps, or how often pcap satisfies a read request?

Murf
Re: strange behavior of using pcap.h  
On Wed, Jul 29, 2009 at 01:03:04PM -0400, John Murphy wrote:
> Sean,  are we talking about the resolution of the timestamps, or how often pcap satisfies a read request?

I guess I probably didn't reply on the proper leaf
on the thread.  I'm talking about the delay in
replying to the read().  I can't see that the timestamp
here is used for anything but you're right in that
it's not all that granular.

Regards,

-seanb
Re: strange behavior of using pcap.h  
> I guess I probably didn't reply on the proper leaf
> on the thread.  I'm talking about the delay in
> replying to the read().  I can't see that the timestamp
> here is used for anything but you're right in that
> it's not all that granular.
> 
> Regards,
> 
> -seanb


I think I may have missed the whole point of this thread!  I thought the concern was for the lack of granularity, as 
evidenced by the printed timestamps.

Murf
Re: strange behavior of using pcap.h  
in which file I can change BIOCIMMEDIATE ?


Regards,
Mohammad
Re: strange behavior of using pcap.h  
On Wed, Jul 29, 2009 at 01:12:48PM -0400, Mohammad Dadashzadeh wrote:
> in which file I can change BIOCIMMEDIATE ?

Please try this libpcap.  By default it should
work the same way,  if you pass a negative timeout
to pcap_open_live() you should get immediate mode.
If you can verify both I'll check it in.

Regards,

-seanb
Attachment: Text libpcap.a 135.78 KB
Re: strange behavior of using pcap.h  
> On Wed, Jul 29, 2009 at 01:12:48PM -0400, Mohammad Dadashzadeh wrote:
> > in which file I can change BIOCIMMEDIATE ?
> 
> Please try this libpcap.  By default it should
> work the same way,  if you pass a negative timeout
> to pcap_open_live() you should get immediate mode.
> If you can verify both I'll check it in.
> 
> Regards,
> 
> -seanb


Should copy libpcap.a into the target machine or Momentics IDE or both?
Re: strange behavior of using pcap.h  
On Wed, Jul 29, 2009 at 03:06:56PM -0400, Mohammad Dadashzadeh wrote:
> > On Wed, Jul 29, 2009 at 01:12:48PM -0400, Mohammad Dadashzadeh wrote:
> > > in which file I can change BIOCIMMEDIATE ?
> > 
> > Please try this libpcap.  By default it should
> > work the same way,  if you pass a negative timeout
> > to pcap_open_live() you should get immediate mode.
> > If you can verify both I'll check it in.
> > 
> > Regards,
> > 
> > -seanb
> 
> 
> Should copy libpcap.a into the target machine or Momentics IDE or both?

Just link against it via your favourite method.  It's not
needed at runtime as it's a static variant.  I'm trying to
'bring the mountain to Mohammad' but as I'm not at your
build environment I can't be more specific than that :)

-seanb
Re: strange behavior of using pcap.h  
On Wed, Jul 29, 2009 at 03:06:56PM -0400, Mohammad Dadashzadeh wrote:
> > On Wed, Jul 29, 2009 at 01:12:48PM -0400, Mohammad Dadashzadeh wrote:
> > > in which file I can change BIOCIMMEDIATE ?
> > 
> > Please try this libpcap.  By default it should
> > work the same way,  if you pass a negative timeout
> > to pcap_open_live() you should get immediate mode.
> > If you can verify both I'll check it in.
> > 
> > Regards,
> > 
> > -seanb
> 
> 
> Should copy libpcap.a into the target machine or Momentics IDE or both?

BTW that was an x86 static variant.

-seanb
Re: strange behavior of using pcap.h  
> On Wed, Jul 29, 2009 at 03:06:56PM -0400, Mohammad Dadashzadeh wrote:
> > > On Wed, Jul 29, 2009 at 01:12:48PM -0400, Mohammad Dadashzadeh wrote:
> > > > in which file I can change BIOCIMMEDIATE ?
> > > 
> > > Please try this libpcap.  By default it should
> > > work the same way,  if you pass a negative timeout
> > > to pcap_open_live() you should get immediate mode.
> > > If you can verify both I'll check it in.
> > > 
> > > Regards,
> > > 
> > > -seanb
> > 
> > 
> > Should copy libpcap.a into the target machine or Momentics IDE or both?
> 
> BTW that was an x86 static variant.
> 
> -seanb


Unfortunately I do not understand  "BTW that was an x86 static variant"

Could you please explain more?

I copied into C:\QNX641\target\qnx6\x86\usr\lib but code can not ve compiled. It shows many error.

Regards,
Mohammad
Re: strange behavior of using pcap.h  
On Wed, Jul 29, 2009 at 03:20:29PM -0400, Mohammad Dadashzadeh wrote:
> > On Wed, Jul 29, 2009 at 03:06:56PM -0400, Mohammad Dadashzadeh wrote:
> > > > On Wed, Jul 29, 2009 at 01:12:48PM -0400, Mohammad Dadashzadeh wrote:
> > > > > in which file I can change BIOCIMMEDIATE ?
> > > > 
> > > > Please try this libpcap.  By default it should
> > > > work the same way,  if you pass a negative timeout
> > > > to pcap_open_live() you should get immediate mode.
> > > > If you can verify both I'll check it in.
> > > > 
> > > > Regards,
> > > > 
> > > > -seanb
> > > 
> > > 
> > > Should copy libpcap.a into the target machine or Momentics IDE or both?
> > 
> > BTW that was an x86 static variant.
> > 
> > -seanb
> 
> 
> Unfortunately I do not understand  "BTW that was an x86 static variant"
> 
> Could you please explain more?
> 
> I copied into C:\QNX641\target\qnx6\x86\usr\lib but code can not ve compiled. It shows many error.

What are the errors?

-seanb
Re: strange behavior of using pcap.h  
> On Wed, Jul 29, 2009 at 03:20:29PM -0400, Mohammad Dadashzadeh wrote:
> > > On Wed, Jul 29, 2009 at 03:06:56PM -0400, Mohammad Dadashzadeh wrote:
> > > > > On Wed, Jul 29, 2009 at 01:12:48PM -0400, Mohammad Dadashzadeh wrote:
> > > > > > in which file I can change BIOCIMMEDIATE ?
> > > > > 
> > > > > Please try this libpcap.  By default it should
> > > > > work the same way,  if you pass a negative timeout
> > > > > to pcap_open_live() you should get immediate mode.
> > > > > If you can verify both I'll check it in.
> > > > > 
> > > > > Regards,
> > > > > 
> > > > > -seanb
> > > > 
> > > > 
> > > > Should copy libpcap.a into the target machine or Momentics IDE or both?
> > > 
> > > BTW that was an x86 static variant.
> > > 
> > > -seanb
> > 
> > 
> > Unfortunately I do not understand  "BTW that was an x86 static variant"
> > 
> > Could you please explain more?
> > 
> > I copied into C:\QNX641\target\qnx6\x86\usr\lib but code can not ve compiled
> . It shows many error.
> 
> What are the errors?
> 
> -seanb


Description	Resource	Path	Location	Type
make[2]: *** [C:/ide-4.6-workspace/newPacketcap/x86/o-g/newPacketcap_g] Error 1	newPacketcap		line 0	C/C++ Problem
make[2]: *** [C:/ide-4.6-workspace/newPacketcap/x86/o/newPacketcap] Error 1	newPacketcap		line 0	C/C++ Problem
newPacketcap.c: undefined reference to `pcap_close'	newPacketcap		line 0	C/C++ Problem
newPacketcap.c: undefined reference to `pcap_findalldevs'	newPacketcap		line 0	C/C++ Problem
newPacketcap.c: undefined reference to `pcap_freealldevs'	newPacketcap		line 0	C/C++ Problem
newPacketcap.c: undefined reference to `pcap_lookupdev'	newPacketcap		line 0	C/C++ Problem
newPacketcap.c: undefined reference to `pcap_lookupnet'	newPacketcap		line 0	C/C++ Problem
newPacketcap.c: undefined reference to `pcap_next'	newPacketcap		line 0	C/C++ Problem
newPacketcap.c: undefined reference to `pcap_open_live'	newPacketcap		line 0	C/C++ Problem
undefined reference to `pcap_close'	newPacketcap.c	newPacketcap	line 109	C/C++ Problem
undefined reference to `pcap_findalldevs'	newPacketcap.c	newPacketcap	line 32	C/C++ Problem
undefined reference to `pcap_freealldevs'	newPacketcap.c	newPacketcap	line 65	C/C++ Problem
undefined reference to `pcap_lookupdev'	newPacketcap.c	newPacketcap	line 75	C/C++ Problem
undefined reference to `pcap_lookupnet'	newPacketcap.c	newPacketcap	line 82	C/C++ Problem
undefined reference to `pcap_next'	newPacketcap.c	newPacketcap	line 100	C/C++ Problem
undefined reference to `pcap_open_live'	newPacketcap.c	newPacketcap	line 88	C/C++ Problem
Re: strange behavior of using pcap.h  
On Wed, Jul 29, 2009 at 03:36:31PM -0400, Mohammad Dadashzadeh wrote:
> 
> Description	Resource	Path	Location	Type
> make[2]: *** [C:/ide-4.6-workspace/newPacketcap/x86/o-g/newPacketcap_g] Error 1	newPacketcap		line 0	C/C++ Problem

Hmm, try this one.

-seanb
Attachment: Text libpcap.a 189.87 KB
Re: strange behavior of using pcap.h  
> On Wed, Jul 29, 2009 at 03:36:31PM -0400, Mohammad Dadashzadeh wrote:
> > 
> > Description	Resource	Path	Location	Type
> > make[2]: *** [C:/ide-4.6-workspace/newPacketcap/x86/o-g/newPacketcap_g] 
> Error 1	newPacketcap		line 0	C/C++ Problem
> 
> Hmm, try this one.
> 
> -seanb


I tried , no error but I am getting 64-65  packets every 8.3 msec.

Mohammad
Re: strange behavior of using pcap.h  
On Wed, Jul 29, 2009 at 03:46:36PM -0400, Mohammad Dadashzadeh wrote:
> > On Wed, Jul 29, 2009 at 03:36:31PM -0400, Mohammad Dadashzadeh wrote:
> > > 
> > > Description	Resource	Path	Location	Type
> > > make[2]: *** [C:/ide-4.6-workspace/newPacketcap/x86/o-g/newPacketcap_g] 
> > Error 1	newPacketcap		line 0	C/C++ Problem
> > 
> > Hmm, try this one.
> > 
> > -seanb
> 
> 
> I tried , no error but I am getting 64-65  packets every 8.3 msec.
> 

You changed the timeout to a negative value?

-seanb
Re: strange behavior of using pcap.h  
> On Wed, Jul 29, 2009 at 03:46:36PM -0400, Mohammad Dadashzadeh wrote:
> > > On Wed, Jul 29, 2009 at 03:36:31PM -0400, Mohammad Dadashzadeh wrote:
> > > > 
> > > > Description	Resource	Path	Location	Type
> > > > make[2]: *** [C:/ide-4.6-workspace/newPacketcap/x86/o-g/newPacketcap_g] 
> 
> > > Error 1	newPacketcap		line 0	C/C++ Problem
> > > 
> > > Hmm, try this one.
> > > 
> > > -seanb
> > 
> > 
> > I tried , no error but I am getting 64-65  packets every 8.3 msec.
> > 
> 
> You changed the timeout to a negative value?
> 
> -seanb


yes handle = pcap_open_live(dev, 1000, 1, -1, errbuf);



#include <pcap.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/netmgr.h>
#include <sys/neutrino.h>


int main(int argc, char *argv[])
{
	pcap_t *handle;			/* Session handle */
	char *dev;			/* The device to sniff on */
	pcap_if_t *alldevs;
	pcap_if_t *d;
	char errbuf[PCAP_ERRBUF_SIZE];	/* Error string */
	struct bpf_program fp;		/* The compiled filter */
	bpf_u_int32 mask;		/* Our netmask */
	bpf_u_int32 net;		/* Our IP */
	struct pcap_pkthdr header;	/* The header that pcap gives us */
	const u_char *packet;		/* The actual packet */
	time_t local_tv_sec;
	struct tm *ltime;
	int i=0;
	char timestr[16];
	int inum;
	FILE *stream1;
	//const u_char *packet;



	/* Retrieve the device list on the local machine */
	if (pcap_findalldevs(&alldevs, errbuf) == -1)
	{
		fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
		exit(1);
	}

	stream1=fopen("test2.txt","w");


	/* Print the list */
	for(d=alldevs; d; d=d->next)
	{
		printf("%d. %s", ++i, d->name);
		if (d->description)
			printf(" (%s)\n", d->description);
		else
			printf(" (No description available)\n");
	}

	if(i==0)
	{
		printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
		return -1;
	}

	printf("Enter the interface number (1-%d):",i);
	//scanf("%d", &inum);
	inum=1;

	if(inum < 1 || inum > i)
	{
		printf("\nInterface number out of range.\n");
		/* Free the device list */
		pcap_freealldevs(alldevs);
		return -1;
	}

	/* Jump to the selected adapter */
	for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++);


	/* Define the device */

	dev = pcap_lookupdev(errbuf);
	strcpy(dev,"wm0");
	if (dev == NULL) {
		fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
		return(2);
	}
	/* Find the properties for the device */
	if (pcap_lookupnet(dev, &net, &mask, errbuf) == -1) {
		fprintf(stderr, "Couldn't get netmask for device %s: %s\n", dev, errbuf);
		net = 0;
		mask = 0;
	}
	/* Open the session in promiscuous mode */
	handle = pcap_open_live(dev, 1000, 1, -1, errbuf);
	if (handle == NULL) {
		fprintf(stderr, "Couldn't open device %s: %s\n", errbuf);
		return(2);
	}

	/* Grab a packet */
	//packet = pcap_next(handle, &header);


	for(i=0;i<32000;i++)
	{
		packet=pcap_next(handle, &header);
		local_tv_sec = header.ts.tv_sec;
		ltime=localtime(&local_tv_sec);
		strftime( timestr, sizeof(timestr), "%H:%M:%S", ltime);
		fprintf(stream1,"%s,%.6d len:%d\n", timestr, header.ts.tv_usec, header.len);
	}
	/* Print its length */
	//printf("Jacked a packet with length of [%d]\n", header.len);
	/* And close the session */
	pcap_close(handle);
	fclose(stream1);
	printf("\n done");
	return(0);
}
Re: strange behavior of using pcap.h  
> > On Wed, Jul 29, 2009 at 03:46:36PM -0400, Mohammad Dadashzadeh wrote:
> > > > On Wed, Jul 29, 2009 at 03:36:31PM -0400, Mohammad Dadashzadeh wrote:
> > > > > 
> > > > > Description	Resource	Path	Location	Type
> > > > > make[2]: *** [C:/ide-4.6-workspace/newPacketcap/x86/o-g/newPacketcap_g
> ] 
> > 
> > > > Error 1	newPacketcap		line 0	C/C++ Problem
> > > > 
> > > > Hmm, try this one.
> > > > 
> > > > -seanb
> > > 
> > > 
> > > I tried , no error but I am getting 64-65  packets every 8.3 msec.
> > > 
> > 
> > You changed the timeout to a negative value?
> > 
> > -seanb
> 
> 
> yes handle = pcap_open_live(dev, 1000, 1, -1, errbuf);
> 

Whatever I put as to_ms, there is no change in interval of reading packets.

Mohammad
RE: strange behavior of using pcap.h  

> -----Original Message-----
> From: John Murphy [mailto:community-noreply@qnx.com]
> Sent: Wednesday, July 29, 2009 11:48 AM
> To: ionetmig-networking
> Subject: Re: strange behavior of using pcap.h
> 
> On an X86 (at least), the clock interrupts happen at a rate close to
> one per millisecond, so you can never achieve a pcap timestamp
> resolution better than about one millisecond.
> 

Sure you can with ClockCycles()

> If what you're after is better resolution, it might be easier to just
> build your own bpf.c.
> 
> 
> Murf
> 
> 
> 
> _______________________________________________
> 
> io-net migration
> http://community.qnx.com/sf/go/post34809
> 
Re: RE: strange behavior of using pcap.h  
Exactly!  But that's a bit different than monkeying with constants that affect all of the networking code.

Murf
Re: RE: strange behavior of using pcap.h  
in mtime it is using tick not microsecond so I think you can modify it to use microsecond then you should be able to get
 microsecond precision.
if mtime is not local then you should be able to preload to override it but it is static.
Re: RE: strange behavior of using pcap.h  
Where is mtime? how can I change it?

Re: RE: strange behavior of using pcap.h  
0805ca45 <mtime>:
 805ca45:       55                      push   %ebp
 805ca46:       89 e5                   mov    %esp,%ebp
 805ca48:       83 ec 28                sub    $0x28,%esp
 805ca4b:       89 5d f4                mov    %ebx,-0xc(%ebp)
 805ca4e:       89 75 f8                mov    %esi,-0x8(%ebp)
 805ca51:       89 7d fc                mov    %edi,-0x4(%ebp)
 805ca54:       89 cf                   mov    %ecx,%edi
 805ca56:       85 d2                   test   %edx,%edx
 805ca58:       0f 94 c0                sete   %al
 805ca5b:       0f b6 c0                movzbl %al,%eax
 805ca5e:       89 04 24                mov    %eax,(%esp)
 805ca61:       e8 a0 fe ff ff          call   805c906 <currtime_nto>
 805ca66:       89 c3                   mov    %eax,%ebx
 805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
 805ca6e:       89 d6                   mov    %edx,%esi
 805ca70:       8b 15 4c 63 0c 08       mov    0x80c634c,%edx
 805ca76:       31 f2                   xor    %esi,%edx
 805ca78:       a1 48 63 0c 08          mov    0x80c6348,%eax
 805ca7d:       31 d8                   xor    %ebx,%eax
 805ca7f:       09 c2                   or     %eax,%edx
 805ca81:       74 6a                   je     805caed <mtime+0xa8>
0805ca45 <mtime>:
 805ca45:       55                      push   %ebp
 805ca46:       89 e5                   mov    %esp,%ebp
 805ca48:       83 ec 28                sub    $0x28,%esp
 805ca4b:       89 5d f4                mov    %ebx,-0xc(%ebp)
 805ca4e:       89 75 f8                mov    %esi,-0x8(%ebp)
 805ca51:       89 7d fc                mov    %edi,-0x4(%ebp)
 805ca54:       89 cf                   mov    %ecx,%edi
 805ca56:       85 d2                   test   %edx,%edx
 805ca58:       0f 94 c0                sete   %al
 805ca5b:       0f b6 c0                movzbl %al,%eax
 805ca5e:       89 04 24                mov    %eax,(%esp)
 805ca61:       e8 a0 fe ff ff          call   805c906 <currtime_nto>
 805ca66:       89 c3                   mov    %eax,%ebx
 805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
 805ca6e:       89 d6                   mov    %edx,%esi
 805ca70:       8b 15 4c 63 0c 08       mov    0x80c634c,%edx
 805ca76:       31 f2                   xor    %esi,%edx
 805ca78:       a1 48 63 0c 08          mov    0x80c6348,%eax
 805ca7d:       31 d8                   xor    %ebx,%eax
 805ca7f:       09 c2                   or     %eax,%edx
 805ca81:       74 6a                   je     805caed <mtime+0xa8>

Here curtick = cur & ~((1 << NTO_TSHIFT) -1); so it is rounding to tick.
You can change it to curtick = cur & ~(1024-1) then you will get microsend precision not tick any more.
so hack io-pkt-*(you don't need to recompile) and find the address 
 805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
and change 00 00 80 ff to 0xfffffc00(00 fc ff ff)

static void
mtime(int get, int up, struct timeval *tv)
{
	static uint64_t		mtlast;
	static struct timeval	mt_tv;
	uint64_t		cur, curtick;

	/*
	 * See comments in <sys/timevar.h>. 'get' variants
	 * are allowed to return a less precise result.
	 */

	cur = currtime_nto(!up);
	curtick = cur & ~((1 << NTO_TSHIFT) -1);

	if (1 /* get */) {
		/*
		 * Try to only do the 64 bit division every tick.
		 * Makes microtime() not so micro...
		 */
		if (mtlast != curtick) {
			mtlast = curtick;
			mt_tv.tv_sec  = mtlast / 1000000000;
			mt_tv.tv_usec = (mtlast % 1000000000) / 1000;
		}
	}
	else {
		mtlast = curtick;
		mt_tv.tv_sec  = cur / 1000000000;
		mt_tv.tv_usec = (cur % 1000000000) / 1000;
	}
Re: RE: strange behavior of using pcap.h  
Or change the 'if (1 /* get */)' to 'if (get)'.

> 
> Here curtick = cur & ~((1 << NTO_TSHIFT) -1); so it is rounding to tick.
> You can change it to curtick = cur & ~(1024-1) then you will get microsend precision not tick any more.
> so hack io-pkt-*(you don't need to recompile) and find the address 
>  805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
> and change 00 00 80 ff to 0xfffffc00(00 fc ff ff)
> 
> static void
> mtime(int get, int up, struct timeval *tv)
> {
> 	static uint64_t		mtlast;
> 	static struct timeval	mt_tv;
> 	uint64_t		cur, curtick;
> 
> 	/*
> 	 * See comments in <sys/timevar.h>. 'get' variants
> 	 * are allowed to return a less precise result.
> 	 */
> 
> 	cur = currtime_nto(!up);
> 	curtick = cur & ~((1 << NTO_TSHIFT) -1);
> 
> 	if (1 /* get */) {
> 		/*
> 		 * Try to only do the 64 bit division every tick.
> 		 * Makes microtime() not so micro...
> 		 */
> 		if (mtlast != curtick) {
> 			mtlast = curtick;
> 			mt_tv.tv_sec  = mtlast / 1000000000;
> 			mt_tv.tv_usec = (mtlast % 1000000000) / 1000;
> 		}
> 	}
> 	else {
> 		mtlast = curtick;
> 		mt_tv.tv_sec  = cur / 1000000000;
> 		mt_tv.tv_usec = (cur % 1000000000) / 1000;
> 	}
> 
> 
> 
> 
> _______________________________________________
> 
> io-net migration
> http://community.qnx.com/sf/go/post34926
> 
Re: RE: strange behavior of using pcap.h  
Where can I find this mtime function to modify it?

Mohammad
Re: RE: strange behavior of using pcap.h  
> 0805ca45 <mtime>:
>  805ca45:       55                      push   %ebp
>  805ca46:       89 e5                   mov    %esp,%ebp
>  805ca48:       83 ec 28                sub    $0x28,%esp
>  805ca4b:       89 5d f4                mov    %ebx,-0xc(%ebp)
>  805ca4e:       89 75 f8                mov    %esi,-0x8(%ebp)
>  805ca51:       89 7d fc                mov    %edi,-0x4(%ebp)
>  805ca54:       89 cf                   mov    %ecx,%edi
>  805ca56:       85 d2                   test   %edx,%edx
>  805ca58:       0f 94 c0                sete   %al
>  805ca5b:       0f b6 c0                movzbl %al,%eax
>  805ca5e:       89 04 24                mov    %eax,(%esp)
>  805ca61:       e8 a0 fe ff ff          call   805c906 <currtime_nto>
>  805ca66:       89 c3                   mov    %eax,%ebx
>  805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
>  805ca6e:       89 d6                   mov    %edx,%esi
>  805ca70:       8b 15 4c 63 0c 08       mov    0x80c634c,%edx
>  805ca76:       31 f2                   xor    %esi,%edx
>  805ca78:       a1 48 63 0c 08          mov    0x80c6348,%eax
>  805ca7d:       31 d8                   xor    %ebx,%eax
>  805ca7f:       09 c2                   or     %eax,%edx
>  805ca81:       74 6a                   je     805caed <mtime+0xa8>
> 0805ca45 <mtime>:
>  805ca45:       55                      push   %ebp
>  805ca46:       89 e5                   mov    %esp,%ebp
>  805ca48:       83 ec 28                sub    $0x28,%esp
>  805ca4b:       89 5d f4                mov    %ebx,-0xc(%ebp)
>  805ca4e:       89 75 f8                mov    %esi,-0x8(%ebp)
>  805ca51:       89 7d fc                mov    %edi,-0x4(%ebp)
>  805ca54:       89 cf                   mov    %ecx,%edi
>  805ca56:       85 d2                   test   %edx,%edx
>  805ca58:       0f 94 c0                sete   %al
>  805ca5b:       0f b6 c0                movzbl %al,%eax
>  805ca5e:       89 04 24                mov    %eax,(%esp)
>  805ca61:       e8 a0 fe ff ff          call   805c906 <currtime_nto>
>  805ca66:       89 c3                   mov    %eax,%ebx
>  805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
>  805ca6e:       89 d6                   mov    %edx,%esi
>  805ca70:       8b 15 4c 63 0c 08       mov    0x80c634c,%edx
>  805ca76:       31 f2                   xor    %esi,%edx
>  805ca78:       a1 48 63 0c 08          mov    0x80c6348,%eax
>  805ca7d:       31 d8                   xor    %ebx,%eax
>  805ca7f:       09 c2                   or     %eax,%edx
>  805ca81:       74 6a                   je     805caed <mtime+0xa8>
> 
> Here curtick = cur & ~((1 << NTO_TSHIFT) -1); so it is rounding to tick.
> You can change it to curtick = cur & ~(1024-1) then you will get microsend precision not tick any more.
> so hack io-pkt-*(you don't need to recompile) and find the address 
>  805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
> and change 00 00 80 ff to 0xfffffc00(00 fc ff ff)
> 
> static void
> mtime(int get, int up, struct timeval *tv)
> {
> 	static uint64_t		mtlast;
> 	static struct timeval	mt_tv;
> 	uint64_t		cur, curtick;
> 
> 	/*
> 	 * See comments in <sys/timevar.h>. 'get' variants
> 	 * are allowed to return a less precise result.
> 	 */
> 
> 	cur = currtime_nto(!up);
> 	curtick = cur & ~((1 << NTO_TSHIFT) -1);
> 
> 	if (1 /* get */) {
> 		/*
> 		 * Try to only do the 64 bit division every tick.
> 		 * Makes microtime() not so micro...
> 		 */
> 		if (mtlast != curtick) {
> 			mtlast = curtick;
> 			mt_tv.tv_sec  = mtlast / 1000000000;
> 			mt_tv.tv_usec = (mtlast % 1000000000) / 1000;
> 		}
> 	}
>...
Re: RE: strange behavior of using pcap.h  
> > 0805ca45 <mtime>:
> >  805ca45:       55                      push   %ebp
> >  805ca46:       89 e5                   mov    %esp,%ebp
> >  805ca48:       83 ec 28                sub    $0x28,%esp
> >  805ca4b:       89 5d f4                mov    %ebx,-0xc(%ebp)
> >  805ca4e:       89 75 f8                mov    %esi,-0x8(%ebp)
> >  805ca51:       89 7d fc                mov    %edi,-0x4(%ebp)
> >  805ca54:       89 cf                   mov    %ecx,%edi
> >  805ca56:       85 d2                   test   %edx,%edx
> >  805ca58:       0f 94 c0                sete   %al
> >  805ca5b:       0f b6 c0                movzbl %al,%eax
> >  805ca5e:       89 04 24                mov    %eax,(%esp)
> >  805ca61:       e8 a0 fe ff ff          call   805c906 <currtime_nto>
> >  805ca66:       89 c3                   mov    %eax,%ebx
> >  805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
> >  805ca6e:       89 d6                   mov    %edx,%esi
> >  805ca70:       8b 15 4c 63 0c 08       mov    0x80c634c,%edx
> >  805ca76:       31 f2                   xor    %esi,%edx
> >  805ca78:       a1 48 63 0c 08          mov    0x80c6348,%eax
> >  805ca7d:       31 d8                   xor    %ebx,%eax
> >  805ca7f:       09 c2                   or     %eax,%edx
> >  805ca81:       74 6a                   je     805caed <mtime+0xa8>
> > 0805ca45 <mtime>:
> >  805ca45:       55                      push   %ebp
> >  805ca46:       89 e5                   mov    %esp,%ebp
> >  805ca48:       83 ec 28                sub    $0x28,%esp
> >  805ca4b:       89 5d f4                mov    %ebx,-0xc(%ebp)
> >  805ca4e:       89 75 f8                mov    %esi,-0x8(%ebp)
> >  805ca51:       89 7d fc                mov    %edi,-0x4(%ebp)
> >  805ca54:       89 cf                   mov    %ecx,%edi
> >  805ca56:       85 d2                   test   %edx,%edx
> >  805ca58:       0f 94 c0                sete   %al
> >  805ca5b:       0f b6 c0                movzbl %al,%eax
> >  805ca5e:       89 04 24                mov    %eax,(%esp)
> >  805ca61:       e8 a0 fe ff ff          call   805c906 <currtime_nto>
> >  805ca66:       89 c3                   mov    %eax,%ebx
> >  805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
> >  805ca6e:       89 d6                   mov    %edx,%esi
> >  805ca70:       8b 15 4c 63 0c 08       mov    0x80c634c,%edx
> >  805ca76:       31 f2                   xor    %esi,%edx
> >  805ca78:       a1 48 63 0c 08          mov    0x80c6348,%eax
> >  805ca7d:       31 d8                   xor    %ebx,%eax
> >  805ca7f:       09 c2                   or     %eax,%edx
> >  805ca81:       74 6a                   je     805caed <mtime+0xa8>
> > 
> > Here curtick = cur & ~((1 << NTO_TSHIFT) -1); so it is rounding to tick.
> > You can change it to curtick = cur & ~(1024-1) then you will get microsend precision not tick any more.
> > so hack io-pkt-*(you don't need to recompile) and find the address 
> >  805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
> > and change 00 00 80 ff to 0xfffffc00(00 fc ff ff)
> > 
> > static void
> > mtime(int get, int up, struct timeval *tv)
> > {
> > 	static uint64_t		mtlast;
> > 	static struct timeval	mt_tv;
> > 	uint64_t		cur, curtick;
> > 
> > 	/*
> > 	 * See comments in <sys/timevar.h>. 'get' variants
> > 	 * are allowed to return a less precise result.
> > 	 */
> > 
> > 	cur = currtime_nto(!up);
> > 	curtick = cur & ~((1 << NTO_TSHIFT) -1);
> > 
> >...
View Full Message
Re: RE: strange behavior of using pcap.h  
Should I sreach my QNX nto machine or development machine. In which file should I exactly search

Regards,
Mohammad
Re: RE: strange behavior of using pcap.h  
> Should I sreach my QNX nto machine or development machine. In which file 
> should I exactly search
> 
> Regards,
> Mohammad


If you mean source code then take a look the source tree: trunk/sys/current_time.c or tags/GA/6.4.0/sys...
if you mean binary, I refer io-pkt-v4. On you development machine, ntox86-objdump -d $QNX_TARGET/x86/sbin/io-pkt-v4 to 
find <mtime>:    If you can do this on your nto machine(target?) it would be better.
Re: RE: strange behavior of using pcap.h  
What software can open the file so I can edit it.
Thanks
Mohammad
Re: RE: strange behavior of using pcap.h  
I am using xvi32 to open the file it finds one mtime but the codes around it is completely different than what you 
mentioned above. I attached the file. Could you please modify this and send it for me.

Regards,
Mohammad
Attachment: Text io-pkt-v4 575.02 KB
Re: RE: strange behavior of using pcap.h  
there are two more similar files

io-pkt-v4-hc
io-pkt-v6-hc

I could not find below in these files

                 0805ca45 <mtime>:
 805ca45:       55                      push   %ebp
 805ca46:       89 e5                   mov    %esp,%ebp
 805ca48:       83 ec 28                sub    $0x28,%esp
 805ca4b:       89 5d f4                mov    %ebx,-0xc(%ebp)
 805ca4e:       89 75 f8                mov    %esi,-0x8(%ebp)
 805ca51:       89 7d fc                mov    %edi,-0x4(%ebp)
 805ca54:       89 cf                   mov    %ecx,%edi
 805ca56:       85 d2                   test   %edx,%edx
 805ca58:       0f 94 c0                sete   %al
 805ca5b:       0f b6 c0                movzbl %al,%eax
 805ca5e:       89 04 24                mov    %eax,(%esp)
 805ca61:       e8 a0 fe ff ff          call   805c906 <currtime_nto>
 805ca66:       89 c3                   mov    %eax,%ebx
 805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
 805ca6e:       89 d6                   mov    %edx,%esi
 805ca70:       8b 15 4c 63 0c 08       mov    0x80c634c,%edx
 805ca76:       31 f2                   xor    %esi,%edx
 805ca78:       a1 48 63 0c 08          mov    0x80c6348,%eax
 805ca7d:       31 d8                   xor    %ebx,%eax
 805ca7f:       09 c2                   or     %eax,%edx
 805ca81:       74 6a                   je     805caed <mtime+0xa8>
0805ca45 <mtime>:
 805ca45:       55                      push   %ebp
 805ca46:       89 e5                   mov    %esp,%ebp
 805ca48:       83 ec 28                sub    $0x28,%esp
 805ca4b:       89 5d f4                mov    %ebx,-0xc(%ebp)
 805ca4e:       89 75 f8                mov    %esi,-0x8(%ebp)
 805ca51:       89 7d fc                mov    %edi,-0x4(%ebp)
 805ca54:       89 cf                   mov    %ecx,%edi
 805ca56:       85 d2                   test   %edx,%edx
 805ca58:       0f 94 c0                sete   %al
 805ca5b:       0f b6 c0                movzbl %al,%eax
 805ca5e:       89 04 24                mov    %eax,(%esp)
 805ca61:       e8 a0 fe ff ff          call   805c906 <currtime_nto>
 805ca66:       89 c3                   mov    %eax,%ebx
 805ca68:       81 e3 00 00 80 ff       and    $0xff800000,%ebx
 805ca6e:       89 d6                   mov    %edx,%esi
 805ca70:       8b 15 4c 63 0c 08       mov    0x80c634c,%edx
 805ca76:       31 f2                   xor    %esi,%edx
 805ca78:       a1 48 63 0c 08          mov    0x80c6348,%eax
 805ca7d:       31 d8                   xor    %ebx,%eax
 805ca7f:       09 c2                   or     %eax,%edx
 805ca81:       74 6a                   je     805caed <mtime+0xa8>
Re: RE: strange behavior of using pcap.h  
it is hacked then run this on your qnx target.
run "pidin arg|grep io-pkt*" on your target find which io-pkt you are using and make sure you are replace it with this 
io-pkt-v4 not others.
keep a copy!

Attachment: Text io-pkt-v4 575.02 KB
Re: RE: strange behavior of using pcap.h  
when I run pidin arg|grep io-pkt* it responses

114708  io-pkt-v4-hc -ptcpip
1220648 io-pkt*


now am I using io-pkt-v4-hc?
if yes, should I replace hacked version (io-pkt-v4) with (io-pkt-v4-hc) or with io-pkt-hc

or should we hack io-pkt-v4-hc



Regards,
Mohammad 


Attachment: Text io-pkt-v4-hc 998.1 KB
Re: RE: strange behavior of using pcap.h  
I learned how to hack io-pkt-v4-hc now the accuracy is 1msec, I am getting 8 packets per 1 msec

How can I reduce that to 100usec or less

Thanks,
Mohammad


Re: RE: strange behavior of using pcap.h  
I would like to get packets one by one. What should I do?

Mohammad
Re: RE: strange behavior of using pcap.h  
> I would like to get packets one by one. What should I do?
> 
> Mohammad


take a look at source of pcap_open_live, in pcap_open_live there is code for AIX how to call 	if (ioctl(p->fd, 
BIOCIMMEDIATE, &v) < 0) {
		snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCIMMEDIATE: %s",
		    pcap_strerror(errno));
		goto bad;
	}
you need to find out how to get fd.

another way probably you are ok now: still hack io-pkt-v4-hc, 
	if (d->bd_immediate || d->bd_state == BPF_TIMED_OUT)
		/*
		 * Immediate mode is set, or the read timeout has
		 * already expired during a select call.  A packet
		 * arrived, so the reader should be woken up.
		 */
		bpf_wakeup(d);
}

disassembly io-pkt-v4-hc's catchpacket, change d->bd_immediate to 1 then you will always get packet one by one.
default it won't be set in pcap_open_alive as it is fox AIX.

/*
 * Move the packet data from interface memory (pkt) into the
 * store buffer.  Return 1 if it's time to wakeup a listener (buffer full),
 * otherwise 0.  "copy" is the routine called to do the actual data
 * transfer.  memcpy is passed in to copy contiguous chunks, while
 * bpf_mcpy is passed in to copy mbuf chains.  In the latter case,
 * pkt is really an mbuf.
 */
static void
catchpacket(struct bpf_d *d, u_char *pkt, u_int pktlen, u_int snaplen,
	    void *(*cpfn)(void *, const void *, size_t), struct timeval *tv)
{
	struct bpf_hdr *hp;
	int totlen, curlen;
	int hdrlen = d->bd_bif->bif_hdrlen;

	++d->bd_ccount;
	++bpf_gstats.bs_capt;
	/*
	 * Figure out how many bytes to move.  If the packet is
	 * greater or equal to the snapshot length, transfer that
	 * much.  Otherwise, transfer the whole packet (unless
	 * we hit the buffer size limit).
	 */
	totlen = hdrlen + min(snaplen, pktlen);
	if (totlen > d->bd_bufsize)
		totlen = d->bd_bufsize;

	/*
	 * Round up the end of the previous packet to the next longword.
	 */
	curlen = BPF_WORDALIGN(d->bd_slen);
	if (curlen + totlen > d->bd_bufsize) {
		/*
		 * This packet will overflow the storage buffer.
		 * Rotate the buffers if we can, then wakeup any
		 * pending reads.
		 */
		if (d->bd_fbuf == 0) {
			/*
			 * We haven't completed the previous read yet,
			 * so drop the packet.
			 */
			++d->bd_dcount;
			++bpf_gstats.bs_drop;
			return;
		}
		ROTATE_BUFFERS(d);
		bpf_wakeup(d);
		curlen = 0;
	}

	/*
	 * Append the bpf header.
	 */
	hp = (struct bpf_hdr *)(d->bd_sbuf + curlen);
	hp->bh_tstamp = *tv;
	hp->bh_datalen = pktlen;
	hp->bh_hdrlen = hdrlen;
	/*
	 * Copy the packet data into the store buffer and update its length.
	 */
	(*cpfn)((u_char *)hp + hdrlen, pkt, (hp->bh_caplen = totlen - hdrlen));
	d->bd_slen = curlen + totlen;

	/*
	 * Call bpf_wakeup after bd_slen has been updated so that kevent(2)
	 * will cause filt_bpfread() to be called with it adjusted.
	 */
	if (d->bd_immediate || d->bd_state == BPF_TIMED_OUT)
		/*
		 * Immediate mode is set, or the read timeout has
		 * already expired during a select call.  A packet
		 * arrived, so the reader should be woken up.
		 */
		bpf_wakeup(d);
}


I suggest you read source as it is not difficult. that is why open source is popular and we publish source code.
Re: RE: strange behavior of using pcap.h  
So the easiest way is to disassemble io-pkt-v4-hc's catchpacket, change d->bd_immediate to 1 then I will always get 
packet one by one.

How can I disassemble  io-pkt-v4-hc. Is there any software which can do the job for me.

I am attaching my io-pkt-v4-hc. Could you do me a favor and change d->bd_immediate to 1. I think after this I am done 
and I can verify QNX for may application.

Regards
Mohammad
Attachment: Text io-pkt-v4-hc 998.1 KB
Re: RE: strange behavior of using pcap.h  
On Fri, Jul 31, 2009 at 10:01:17AM -0400, Yao Zhao wrote:
> > I would like to get packets one by one. What should I do?
> > 
> > Mohammad
> 
> 
> take a look at source of pcap_open_live, in pcap_open_live there is code for AIX how to call 	if (ioctl(p->fd, 
BIOCIMMEDIATE, &v) < 0) {
> 		snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCIMMEDIATE: %s",
> 		    pcap_strerror(errno));
> 		goto bad;
> 	}
> you need to find out how to get fd.
> 
> another way probably you are ok now: still hack io-pkt-v4-hc, 
> 	if (d->bd_immediate || d->bd_state == BPF_TIMED_OUT)
> 		/*
> 		 * Immediate mode is set, or the read timeout has
> 		 * already expired during a select call.  A packet
> 		 * arrived, so the reader should be woken up.
> 		 */
> 		bpf_wakeup(d);
> }
> 
> disassembly io-pkt-v4-hc's catchpacket, change d->bd_immediate to 1 then you will always get packet one by one.
> default it won't be set in pcap_open_alive as it is fox AIX.

You can get the fd with pcap_fileno(), but I'm not convinced
anymore that he want's to get packets one at a time.  I think
he's worried about the timestamp...

-seanb
Re: strange behavior of using pcap.h  
> I would like to get packets one by one. What should I do?
>
> Mohammad
>
>
>
> _______________________________________________
>
>
>   
Sean sent you a libpcap.a that lets you enable immediate mode.  That 
should be all you need.

Murf
Re: strange behavior of using pcap.h  
On Fri, Jul 31, 2009 at 10:12:06AM -0400, John Murphy wrote:
> 
> > I would like to get packets one by one. What should I do?
> >
> > Mohammad
> >
> >
> >
> > _______________________________________________
> >
> >
> >   
> Sean sent you a libpcap.a that lets you enable immediate mode.  That 
> should be all you need.
> 

I think that's the confusion in this thread.  I think Mohammad's
under the impression that the timestamp in the packet is when
he's actually getting it.  I'm not convinced anyore that the wait
on the read() is the concern.  If the timestamp on the packet
is the primary sticking point the attached diff will get the
resolution of the system clock which by default is 1ms.  The
system clock can then be changed with ClockPeriod() but I suspect
32us will be too much overhead.

Regards,

-seanb
Attachment: Text diff 409 bytes
Re: strange behavior of using pcap.h  
In this case I have to recompile io-pkt, am I write, I am not familiar with this procedure, any way to hack io-pkt-v4-hc


why this is not optional in QNX, so user can determine what they want.


Regards,
Mohammad 
Re: strange behavior of using pcap.h  
> 
> > I would like to get packets one by one. What should I do?
> >
> > Mohammad
> >
> >
> >
> > _______________________________________________
> >
> >
> >   
> Sean sent you a libpcap.a that lets you enable immediate mode.  That 
> should be all you need.
> 
> Murf


I did that, didn't work, even when I reboot my target machine it can  not connect to net anymore.

Mohammad 
Re: strange behavior of using pcap.h  
> > 
> > > I would like to get packets one by one. What should I do?
> > >
> > > Mohammad
> > >
> > >
> > >
> > > _______________________________________________
> > >
> > >
> > >   
> > Sean sent you a libpcap.a that lets you enable immediate mode.  That 
> > should be all you need.
> > 
> > Murf
> 
> 
> I did that, didn't work, even when I reboot my target machine it can  not 
> connect to net anymore.
> 
> Mohammad 


Don't panic.
give me your source code(to make sure I can compile) and I can finish all for you. that will save all of us time.
RE: strange behavior of using pcap.h  

> -----Original Message-----
> From: Yao Zhao [mailto:community-noreply@qnx.com]
> Sent: Friday, July 31, 2009 11:19 AM
> To: ionetmig-networking
> Subject: Re: strange behavior of using pcap.h
> 
> > >
> > > > I would like to get packets one by one. What should I do?
> > > >
> > > > Mohammad
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > >
> > > >
> > > >
> > > Sean sent you a libpcap.a that lets you enable immediate mode.
> That
> > > should be all you need.
> > >
> > > Murf
> >
> >
> > I did that, didn't work, even when I reboot my target machine it can
> not
> > connect to net anymore.
> >
> > Mohammad
> 
> 
> Don't panic.
> give me your source code(to make sure I can compile) and I can finish
> all for you. that will save all of us time.

I also have some source code that need fixing, can I send it to you?

> 
> 
> 
> _______________________________________________
> 
> io-net migration
> http://community.qnx.com/sf/go/post35055
> 
Re: RE: strange behavior of using pcap.h  
I just installed QNX few days ago and I have not changed anything, I think the source is untouched and available in the 
QNX website. Am I right?

Thanks alot,
Mohammad
Re: strange behavior of using pcap.h  
> > > 
> > > > I would like to get packets one by one. What should I do?
> > > >
> > > > Mohammad
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > >
> > > >
> > > >   
> > > Sean sent you a libpcap.a that lets you enable immediate mode.  That 
> > > should be all you need.
> > > 
> > > Murf
> > 
> > 
> > I did that, didn't work, even when I reboot my target machine it can  not 
> > connect to net anymore.
> > 
> > Mohammad 
> 
> 
> Don't panic.
> give me your source code(to make sure I can compile) and I can finish all for 
> you. that will save all of us time.


Source code of packet capturing, it is attached. 
Attachment: Text newPacketcap.zip 132.6 KB
Re: strange behavior of using pcap.h  
Mohammad Dadashzadeh wrote:
>>> I would like to get packets one by one. What should I do?
>>>
>>> Mohammad
>>>
>>>
>>>
>>> _______________________________________________
>>>
>>>
>>>   
>>>       
>> Sean sent you a libpcap.a that lets you enable immediate mode.  That 
>> should be all you need.
>>
>> Murf
>>     
>
>
> I did that, didn't work, even when I reboot my target machine it can  not connect to net anymore.
>
> Mohammad 
>   
I compiled the code you published on this thread and linked it with 
Sean's libpcap and it worked fine.  I don't think we understand what you 
mean by "not working".

Murf
Re: strange behavior of using pcap.h  
> Mohammad Dadashzadeh wrote:
> >>> I would like to get packets one by one. What should I do?
> >>>
> >>> Mohammad
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>>
> >>>
> >>>   
> >>>       
> >> Sean sent you a libpcap.a that lets you enable immediate mode.  That 
> >> should be all you need.
> >>
> >> Murf
> >>     
> >
> >
> > I did that, didn't work, even when I reboot my target machine it can  not 
> connect to net anymore.
> >
> > Mohammad 
> >   
> I compiled the code you published on this thread and linked it with 
> Sean's libpcap and it worked fine.  I don't think we understand what you 
> mean by "not working".
> 
> Murf


I replaced linpcap.a which Sean sent with all libpcap.a files in my development and target machine. I recompiled and 
built the project yet I am getting 8 packets every 1 ms while the packets are transmitted two every 250 usec.

Regards,
Mohammad
Re: strange behavior of using pcap.h  
> > Mohammad Dadashzadeh wrote:
> > >>> I would like to get packets one by one. What should I do?
> > >>>
> > >>> Mohammad
> > >>>
> > >>>
> > >>>
> > >>> _______________________________________________
> > >>>
> > >>>
> > >>>   
> > >>>       
> > >> Sean sent you a libpcap.a that lets you enable immediate mode.  That 
> > >> should be all you need.
> > >>
> > >> Murf
> > >>     
> > >
> > >
> > > I did that, didn't work, even when I reboot my target machine it can  not 
> 
> > connect to net anymore.
> > >
> > > Mohammad 
> > >   
> > I compiled the code you published on this thread and linked it with 
> > Sean's libpcap and it worked fine.  I don't think we understand what you 
> > mean by "not working".
> > 
> > Murf
> 
> 
> I replaced linpcap.a which Sean sent with all libpcap.a files in my 
> development and target machine. I recompiled and built the project yet I am 
> getting 8 packets every 1 ms while the packets are transmitted two every 250 
> usec.
> 
> Regards,
> Mohammad


this is part of captured packets, compared to the packets shown in the first post I am getting 1 msec resolution. If I 
use Wireshark, it captures two packets almost every 250 msec.

Thanks
Mohammad


11:35:29,160460 len:121
11:35:29,160460 len:121
11:35:29,160460 len:121
11:35:29,160460 len:121
11:35:29,160460 len:121
11:35:29,160460 len:121
11:35:29,160460 len:121
11:35:29,160460 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,161459 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,162460 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,163459 len:121
11:35:29,164460 len:121
11:35:29,164460 len:121
11:35:29,164460 len:121
11:35:29,164460 len:121
Re: strange behavior of using pcap.h  
> > Mohammad Dadashzadeh wrote:
> > >>> I would like to get packets one by one. What should I do?
> > >>>
> > >>> Mohammad
> > >>>
> > >>>
> > >>>
> > >>> _______________________________________________
> > >>>
> > >>>
> > >>>   
> > >>>       
> > >> Sean sent you a libpcap.a that lets you enable immediate mode.  That 
> > >> should be all you need.
> > >>
> > >> Murf
> > >>     
> > >
> > >
> > > I did that, didn't work, even when I reboot my target machine it can  not 
> 
> > connect to net anymore.
> > >
> > > Mohammad 
> > >   
> > I compiled the code you published on this thread and linked it with 
> > Sean's libpcap and it worked fine.  I don't think we understand what you 
> > mean by "not working".
> > 
> > Murf
> 
> 
> I replaced linpcap.a which Sean sent with all libpcap.a files in my 
> development and target machine. I recompiled and built the project yet I am 
> getting 8 packets every 1 ms while the packets are transmitted two every 250 
> usec.
> 
> Regards,
> Mohammad


You don't need to replace libpcap.a on target, it is only needed when you linking. 
Post the io-pkt-v4-hc you modified here and output of your application, if you modified correctly it should be stamped 
with microsecond, not millisecond. 
in bpf_deliver it will only call microtime once in a packet loop so that is another guess.

Murf: can you get different timestamp for flood packets?
Re: strange behavior of using pcap.h  
> > > Mohammad Dadashzadeh wrote:
> > > >>> I would like to get packets one by one. What should I do?
> > > >>>
> > > >>> Mohammad
> > > >>>
> > > >>>
> > > >>>
> > > >>> _______________________________________________
> > > >>>
> > > >>>
> > > >>>   
> > > >>>       
> > > >> Sean sent you a libpcap.a that lets you enable immediate mode.  That 
> > > >> should be all you need.
> > > >>
> > > >> Murf
> > > >>     
> > > >
> > > >
> > > > I did that, didn't work, even when I reboot my target machine it can  
> not 
> > 
> > > connect to net anymore.
> > > >
> > > > Mohammad 
> > > >   
> > > I compiled the code you published on this thread and linked it with 
> > > Sean's libpcap and it worked fine.  I don't think we understand what you 
> > > mean by "not working".
> > > 
> > > Murf
> > 
> > 
> > I replaced linpcap.a which Sean sent with all libpcap.a files in my 
> > development and target machine. I recompiled and built the project yet I am 
> 
> > getting 8 packets every 1 ms while the packets are transmitted two every 250
>  
> > usec.
> > 
> > Regards,
> > Mohammad
> 
> 
> You don't need to replace libpcap.a on target, it is only needed when you 
> linking. 
> Post the io-pkt-v4-hc you modified here and output of your application, if you
>  modified correctly it should be stamped with microsecond, not millisecond. 
> in bpf_deliver it will only call microtime once in a packet loop so that is 
> another guess.
> 
> Murf: can you get different timestamp for flood packets?


I do not know how to change d->bd_immediate to 1 in io-pkt-v4-hc. I attached my io-pkt-v4-hc

Regards,
Mohammad

Attachment: Text io-pkt-v4-hc 998.1 KB
Re: strange behavior of using pcap.h  
Yao Zhao wrote:
>
> Murf: can you get different timestamp for flood packets?
>
>
>   
I get timestamps with the normal 8 us. resolution, as expected.  The 
changes that were suggested for mtime will produce ms., not us., 
resolution, since the hardware clock interrupts (approximately) once per 
millisecond.

Murf
Re: strange behavior of using pcap.h  
> Yao Zhao wrote:
> >
> > Murf: can you get different timestamp for flood packets?
> >
> >
> >   
> I get timestamps with the normal 8 us. resolution, as expected.  The 
> changes that were suggested for mtime will produce ms., not us., 
> resolution, since the hardware clock interrupts (approximately) once per 
> millisecond.
> 
> Murf


You should get 8ms resolution not 8us. as the tick.

Murf is right I forgot qtime is updated by timer so curtime_nto won't get better than 1 ms.
you should write a small program to call ClockPeriod to change system clock to smaller, like 250us. then run your app.
Re: strange behavior of using pcap.h  
>> I get timestamps with the normal 8 us. resolution, as expected.  The 
>> changes that were suggested for mtime will produce ms., not us., 
>> resolution, since the hardware clock interrupts (approximately) once per 
>> millisecond.
>>
>> Murf
>>     
>
>
> You should get 8ms resolution not 8us. as the tick.
>
> Murf is right I forgot qtime is updated by timer so curtime_nto won't get better than 1 ms.
> you should write a small program to call ClockPeriod to change system clock to smaller, like 250us. then run your app.

>
>   
Yea, of course I meant 8ms., not 8us.!  Even when I reread messages two 
or three times before I hit the send button, I still make mistakes.  
Guess I need a smarter "spell" checker....

Murf
Re: strange behavior of using pcap.h  
> > Yao Zhao wrote:
> > >
> > > Murf: can you get different timestamp for flood packets?
> > >
> > >
> > >   
> > I get timestamps with the normal 8 us. resolution, as expected.  The 
> > changes that were suggested for mtime will produce ms., not us., 
> > resolution, since the hardware clock interrupts (approximately) once per 
> > millisecond.
> > 
> > Murf
> 
> 
> You should get 8ms resolution not 8us. as the tick.
> 
> Murf is right I forgot qtime is updated by timer so curtime_nto won't get 
> better than 1 ms.
> you should write a small program to call ClockPeriod to change system clock to
>  smaller, like 250us. then run your app.


Well done. It worked. I really appreciate. I am going to summarize the discussion and make it more useful for anyone who
 may face the same problem. Just one thing I wanna confirm, was replacing libpcap.a necessary or not.
Best Regards,
Mohammad



12:12:13,165995 len:121
12:12:13,165995 len:121
12:12:13,165995 len:121
12:12:13,166206 len:121
12:12:13,166206 len:121
12:12:13,166336 len:121
12:12:13,166336 len:121
12:12:13,166538 len:121
12:12:13,166547 len:121
12:12:13,166547 len:121
12:12:13,166769 len:121
12:12:13,166769 len:121
12:12:13,166769 len:121
12:12:13,166990 len:121
12:12:13,166990 len:121
12:12:13,166990 len:121
12:12:13,166990 len:121
12:12:13,167211 len:121
12:12:13,167211 len:121
12:12:13,167322 len:121
12:12:13,167322 len:121
12:12:13,167543 len:121
12:12:13,167543 len:121
12:12:13,167543 len:121
12:12:13,167773 len:121
12:12:13,167773 len:121
12:12:13,167773 len:121
12:12:13,167773 len:121
12:12:13,167985 len:121
12:12:13,168004 len:121
12:12:13,168004 len:121
12:12:13,168217 len:121
12:12:13,168217 len:121
12:12:13,168327 len:121
12:12:13,168327 len:121
12:12:13,168539 len:121
12:12:13,168548 len:121
12:12:13,168548 len:121
12:12:13,168770 len:121
12:12:13,168770 len:121
12:12:13,168770 len:121
12:12:13,168991 len:121
12:12:13,168991 len:121
12:12:13,169212 len:121
12:12:13,169212 len:121
12:12:13,169323 len:121
12:12:13,169323 len:121
12:12:13,169534 len:121
12:12:13,169544 len:121
12:12:13,169544 len:121
12:12:13,169765 len:121
12:12:13,169765 len:121
12:12:13,169765 len:121
12:12:13,169986 len:121
Re: strange behavior of using pcap.h  
> > > Yao Zhao wrote:
> > > >
> > > > Murf: can you get different timestamp for flood packets?
> > > >
> > > >
> > > >   
> > > I get timestamps with the normal 8 us. resolution, as expected.  The 
> > > changes that were suggested for mtime will produce ms., not us., 
> > > resolution, since the hardware clock interrupts (approximately) once per 
> > > millisecond.
> > > 
> > > Murf
> > 
> > 
> > You should get 8ms resolution not 8us. as the tick.
> > 
> > Murf is right I forgot qtime is updated by timer so curtime_nto won't get 
> > better than 1 ms.
> > you should write a small program to call ClockPeriod to change system clock 
> to
> >  smaller, like 250us. then run your app.
> 
> 
> Well done. It worked. I really appreciate. I am going to summarize the 
> discussion and make it more useful for anyone who may face the same problem. 
> Just one thing I wanna confirm, was replacing libpcap.a necessary or not.
> Best Regards,
> Mohammad
> 
> 
> 
> 12:12:13,165995 len:121
> 12:12:13,165995 len:121
> 12:12:13,165995 len:121
> 12:12:13,166206 len:121
> 12:12:13,166206 len:121
> 12:12:13,166336 len:121
> 12:12:13,166336 len:121
> 12:12:13,166538 len:121
> 12:12:13,166547 len:121
> 12:12:13,166547 len:121
> 12:12:13,166769 len:121
> 12:12:13,166769 len:121
> 12:12:13,166769 len:121
> 12:12:13,166990 len:121
> 12:12:13,166990 len:121
> 12:12:13,166990 len:121
> 12:12:13,166990 len:121
> 12:12:13,167211 len:121
> 12:12:13,167211 len:121
> 12:12:13,167322 len:121
> 12:12:13,167322 len:121
> 12:12:13,167543 len:121
> 12:12:13,167543 len:121
> 12:12:13,167543 len:121
> 12:12:13,167773 len:121
> 12:12:13,167773 len:121
> 12:12:13,167773 len:121
> 12:12:13,167773 len:121
> 12:12:13,167985 len:121
> 12:12:13,168004 len:121
> 12:12:13,168004 len:121
> 12:12:13,168217 len:121
> 12:12:13,168217 len:121
> 12:12:13,168327 len:121
> 12:12:13,168327 len:121
> 12:12:13,168539 len:121
> 12:12:13,168548 len:121
> 12:12:13,168548 len:121
> 12:12:13,168770 len:121
> 12:12:13,168770 len:121
> 12:12:13,168770 len:121
> 12:12:13,168991 len:121
> 12:12:13,168991 len:121
> 12:12:13,169212 len:121
> 12:12:13,169212 len:121
> 12:12:13,169323 len:121
> 12:12:13,169323 len:121
> 12:12:13,169534 len:121
> 12:12:13,169544 len:121
> 12:12:13,169544 len:121
> 12:12:13,169765 len:121
> 12:12:13,169765 len:121
> 12:12:13,169765 len:121
> 12:12:13,169986 len:121

libpcap.a modification is not related to your timestamp problem so no.
Re: strange behavior of using pcap.h  
On Fri, Jul 31, 2009 at 12:40:49PM -0400, Yao Zhao wrote:
> > 
> > Well done. It worked. I really appreciate. I am going to summarize the 
> > discussion and make it more useful for anyone who may face the same problem. 
> > Just one thing I wanna confirm, was replacing libpcap.a necessary or not.
> > Best Regards,
> > Mohammad
> > 
> 
> libpcap.a modification is not related to your timestamp problem so no.

The final I have in mind likely will require a new stack
and libpcap.

Regards,

-seanb
Re: strange behavior of using pcap.h  

Mohammad Dadashzadeh wrote:
>> Mohammad Dadashzadeh wrote:
>>     
>>>>> I would like to get packets one by one. What should I do?
>>>>>
>>>>> Mohammad
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>>
>>>>>
>>>>>   
>>>>>       
>>>>>           
>>>> Sean sent you a libpcap.a that lets you enable immediate mode.  That 
>>>> should be all you need.
>>>>
>>>> Murf
>>>>     
>>>>         
>>> I did that, didn't work, even when I reboot my target machine it can  not 
>>>       
>> connect to net anymore.
>>     
>>> Mohammad 
>>>   
>>>       
>> I compiled the code you published on this thread and linked it with 
>> Sean's libpcap and it worked fine.  I don't think we understand what you 
>> mean by "not working".
>>
>> Murf
>>     
>
>
> I replaced linpcap.a which Sean sent with all libpcap.a files in my development and target machine. I recompiled and 
built the project yet I am getting 8 packets every 1 ms while the packets are transmitted two every 250 usec.
>
> Regards,
> Mohammad
>   
Sean's change was to enable immediate mode in BPF, and had nothing to do 
with timestamps.  You are seeing all the packets that get transmitted, 
and, as has been explained several times in this thread, the resolution 
of the timestamps you see on those packets is limited by the resolution 
of the system clock.  If you really think you need greater resolution on 
the timestamps, it might be better to design you own packet capture 
system, rather than make fundamental changes to the operating system, 
especially by hacking the binaries.

By the way, please understand that I am in no way associated with QNX 
other than being a happy user with about 30 years of experience in 
packet sniffing --- and a little too much time on my hands this week.

Murf
Re: strange behavior of using pcap.h  
I would really appreciate your help and support.