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: Axel
Subject: Re: [uracoli-devel] Timestamp in uracoli sniffer
Date: Wed, 27 Apr 2011 22:19:44 +0200
User-agent: KMail/1.9.9

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





reply via email to

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