Forum Topic - strange behavior of using pcap.h: Page 2 of 4 (82 Items)
   
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