uracoli-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [uracoli-devel] Timestamp in uracoli sniffer


From: Bedinek
Subject: Re: [uracoli-devel] Timestamp in uracoli sniffer
Date: Mon, 9 May 2011 20:57:03 +0200

Hi Axel,

thank you for your response. But I still have some problems with implementing this in C# code in Windows.
This is my code:

/************************************************/
// I save the bytes from sniffer to array byte b[]
// there should be changed endianness, am I right?
// b[1] thru b[8] is timestamp from sniffer
int sec = ((int)b[4] << 24 | (int)b[3] << 16 | (int)b[2] << 8 | (int)b[1]); // I change endianness and sum 4 bytes into one 32 bit number int usec = ((int)b[8] << 24 | (int)b[7] << 16 | (int)b[6] << 8 | (int)b[5]); // the same as previous

//following three lines of code should be the same as you explained me below, right?
double tstamp = ((sec * 65536) + usec) / 8000000;
long t_sec = (long)tstamp;
long t_usec = (long)((tstamp - sec) * 1.0e6);

/************************************************/

But in wireshark I get in Time column negative numbers - see attachment.
And for some frames get this error: "Arrival Time: Fractional second -1224586240 is invalid, the valid range is 0-1000000000"
Could you please help me with this? I am really begging of you :)

Regards,
Martin


-----Původní zpráva----- From: Axel
Sent: Wednesday, April 27, 2011 10:19 PM
To: address@hidden
Cc: address@hidden
Subject: Re: [uracoli-devel] Timestamp in uracoli sniffer

Hello bedinek,

The timestamp format on the serial line is really odd, but it is needed,
because arithmetic on AVR is too slow, so that you would miss packets
if you calculate a real time stamp. Therefore the computation is moved
to the PC.

The answer how this is done can be found in the file
Contrib/PacketCapture/ieee802154_io.py. I just annotate the code a bit.

# Byte 2..10 holds the firmware representation of the time.
# it consists of two 32 bit numbers
# ticks[0] - is the current count of clock overflows for this packet
# ticks[1] - is the current number of clock ticks for this packet
ticks,pkt = packet[2:10], packet[10:-1]

# These constants are also needed, they depend on the firmware
# (F_CPU and timer configuration)
# self.ticknb - number of clock ticks until overflow.
# self.tscale - is the timebase (e.g. how long lasts one tick)
ticks = struct.unpack('LL',ticks)
tstamp = ((ticks[0]*self.ticknb) + ticks[1]) * self.tscale

# now repack the values for wireshark
# self.timebase = int(time.time())
# (the Python code so far sends this value to the firmware too, but
# in fact it is not needed there anymore, because after some trials the
# conclusion was to compute the time value on the PC ... I'll remove it).
t_sec = int(tstamp)
t_usec = int((tstamp-t_sec)*1.0e6)
ts = struct.pack('LL',(t_sec + self.timebase),t_usec)

The constants can be derived, if you parse the output of the "parms"
command of the sniffer firmware:
=================================================
IDLE
parms
PLATFORM: stb230 V0.1
SUPP_CMSK: 0x07fff800
CURR_CMSK: 0x07fff800
CURR_CHAN: 11
CURR_PAGE: 0
CURR_RATE: OQPSK250
SUPP_RATES: OQPSK250
TIMER_SCALE: 1.0/8000000 -----> self.tscale (formula eval'd in python)
TICK_NUMBER: 65536 -----------> self.ticknb
CHKCRC: 0
MISSED_FRAMES: 0
=================================================

Hope that clearifies a bit the situation.
Regards, Axel


Am Mittwoch, 27. April 2011 21:39:32 schrieb Bedinek:
Hello,

I try to figure out how the timestamp operates. But I have no idea.
I need to implement operating with the timestamp in C# .NET.
Concretely, I have byte array with 4B of sec and 4B of usec. I don’t know
what should I do with these 8 bytes to convert them into libpcap format and
send them into wireshark. Could you please help me?

Thank you very much

Attachment: wireshark.PNG
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]