Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

# of packets loaded does not match # of packets in the file #20

Open
RudyGOGOGO opened this issue Feb 22, 2022 · 2 comments
Open

# of packets loaded does not match # of packets in the file #20

RudyGOGOGO opened this issue Feb 22, 2022 · 2 comments

Comments

@RudyGOGOGO
Copy link

RudyGOGOGO commented Feb 22, 2022

Thanks for your tool!
I simply compared csiread with CSIKit, yours is much faster.

However, I am facing one weird issue: I used this Atheros CSI Tool Python RemoteReceive to generate a .dat file
In this script, I set the range with 1000 in this for loopfor i in range() which should generate a .dat file with 1000 packets.

CSIKit can read the file back with 1000 packets(the shape is [1000, 56, 2, 2]) which seems correct, however, csiread can only retrieve 986 packet(the shape is [986, 56, 2, 2]). I am not sure why there are several packets missing when I use csiread.

P.S.1 This is the file with CSI data I generated
with_router_in_realtime.dat.zip
P.S.2 I tried to generate a file with 986 packets, then csiread can only retrieve 972 packets, it seems there is always 14 packets missing

@citysu
Copy link
Owner

citysu commented Feb 22, 2022

This issue was caused by Atheros CSI Tool Python RemoteReceive

The format of one atheros packet contains two parts:

2 bytes xxx bytes
field_len payload

field_len = len(payload). In general, the same device should be used to save both parts, so that the two parts have the same byte order. This is the case that csiread can handle. Differently, your sample data was collected by Atheros CSI Tool Python RemoteReceive: payload part was first generated on device A(router), then sent to device B(your computer) via udp. field_len was calculated on device B. device B is little endian while device A is big endian.

In CSIKit, You used

SIZE_STRUCT = struct.Struct("<H").unpack
HEADER_STRUCT_BE = struct.Struct(">QHHBBBBBBBBBBBH").unpack

for parsing, so you can retrieve all packets. However, you didn't make the same changes to csiread.

To solve this issue, you can also

  • calculate filed_len part on device A and send it to device B.

or

  • use filehandle.write(np.uint16(length).newbyteorder()) in function save_to_file only if you find the two devices have different byte order.

@RudyGOGOGO
Copy link
Author

Sorry for the late reply. I do not get a chance to test until now. Thanks for pointing it out, it is really helpful!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants