[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] bbn_80211b_rx.py: how is the received packet hand
From: |
masond |
Subject: |
Re: [Discuss-gnuradio] bbn_80211b_rx.py: how is the received packet handled please? |
Date: |
Tue, 29 Jul 2008 17:16:05 -0500 |
User-agent: |
Internet Messaging Program (IMP) H3 (4.1.3) |
Inlined responses:
Quoting yyzhuang <address@hidden>:
Hello,
Hi,
In the BBN 802.11 package, I see the scripts for receiver, and some lines of
code for packet handling as well.
======================================================
def rx_callback(ok, payload):
size = struct.calcsize("@qHBB");
packet_data = payload[size:];
hdr = struct.unpack("@qHbB", payload[0:size]);
if len(packet_data) > 16:
data_hdr = struct.unpack("@BBBBBB", packet_data[10:16])
What does the struct.unpack do? Is it for formatting the packet for display?
Pretty much -- though it does more than that as well.
http://docs.python.org/lib/module-struct.html
struct.unpack() is also used by the mainline gnuradio code (see
gnuradio-examples/python/(digital|ofdm)/benchmark_* for instance).
coz when I tried to do this: print "payload: %s" % payload, what got
displayed on the screen is like this:
payload: <binary garbage snipped>
That's because the 'payload' string isn't ascii- or unicode-formatted;
it's raw binary data packed into a string because that's how python
handles things that would be stored in a c struct.
If you unpack it with an appropriate format string, you can display
the actual data received. (something close to but less ugly than
struct.unpack('!' + `len(payload)` + 'B',payload)
depending on what you want to see.)
And what exactly the "time" is? As I see in the script, is it in ticks?
means the time instance, or the inter-arrival time?
I'll defer to someone who's familiar with the BBN code.
--Mason
Re: [Discuss-gnuradio] bbn_80211b_rx.py: how is the received packet handled please?, Daniel Sumorok, 2008/07/29