1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
%global _empty_manifest_terminate_build 0
Name: python-csiread
Version: 1.4.0
Release: 1
Summary: A **fast** channel state information parser for Intel, Atheros, Nexmon, ESP32 and PicoScenes in Python.
License: MIT
URL: https://github.com/citysu/csiread
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/24/d6/086786333b83ea32f67e4c3b067331ba69e56d6b4e82bfac106d43eac58f/csiread-1.4.0.tar.gz
Requires: python3-numpy
%description
# csiread [](https://pypi.org/project/csiread/)
A **fast** channel state information parser for Intel, Atheros, Nexmon, ESP32 and PicoScenes in Python.
- Full support for [Linux 802.11n CSI Tool](https://dhalperi.github.io/linux-80211n-csitool/), [Atheros CSI Tool](https://wands.sg/research/wifi/AtherosCSI/), [nexmon_csi](https://github.com/seemoo-lab/nexmon_csi) and [ESP32-CSI-Tool](https://github.com/StevenMHernandez/ESP32-CSI-Tool)
- Support for [PicoScenes](https://ps.zpj.io) is **experimental**.
- At least 15 times faster than the implementation in Matlab
- Real-time parsing and visualization.
<center><b>real-time plotting</b></center>

## Introduction
Various CSI Tools only provide Matlab API parsing CSI data files. Those who want to process CSI with Python have to install Matlab to convert `.dat` to `.mat`. This process is redundant and inefficient. Therefore, **Python API** is recommended. Unfortunately, the API implemented in pure Python is inefficient. With this in mind, I implemented csiread in Cython(Pybind11 may be another great choice). The table below shows the performance of different implementations. They were all tested with **40k** packets on the same computer.
| Function | Matlab | Python3+Numpy | csiread | file size |
|-------------------------|----------|---------------|------------|-----------|
| Nexmon.read:bcm4339 | 3.2309s | 0.2739s | 0.0703s | 44.0MB |
| Nexmon.read:bcm4358 | 3.5987s | 23.0025s | 0.1227s | 44.0MB |
| Atheros.read | 3.3081s | 14.6021s | 0.0956s | 76.3MB |
| Intel.read | 1.6102s | 7.6624s | 0.0479s | 21.0MB |
| Intel.get_total_rss | 0.1786s | 0.0030s | 0.0030s | |
| Intel.get_scaled_csi | 0.5497s | 0.1225s | 0.0376s/0.0278s | |
| Intel.get_scaled_csi_sm | 5.0097s | 0.3627s | 0.0778s/0.0465s | |
This tool is not only the translation of the Matlab API, but also a **CSI toolbox**. I added some utilities, real-time visualization and algorithms code in the `examples` folder. These would be useful for Python-based CSI researchers.
## Install
```bash
pip3 install csiread
```
## Quickstart
```python
import csiread
# Linux 802.11n CSI Tool
csifile = "../material/5300/dataset/sample_0x1_ap.dat"
csidata = csiread.Intel(csifile, nrxnum=3, ntxnum=2, pl_size=10)
csidata.read()
csi = csidata.get_scaled_csi()
print(csidata.csi.shape)
# Atheros CSI Tool
csifile = "../material/atheros/dataset/ath_csi_1.dat"
csidata = csiread.Atheros(csifile, nrxnum=3, ntxnum=2, pl_size=10, tones=56)
csidata.read(endian='little')
print(csidata.csi.shape)
# nexmon_csi
csifile = "../material/nexmon/dataset/example.pcap"
csidata = csiread.Nexmon(csifile, chip='4358', bw=80)
csidata.read()
print(csidata.csi.shape)
# ESP32-CSI-Tool
csifile = "../material/esp32/dataset/example_csi.csv"
csidata = csiread.ESP32(csifile, csi_only=True)
csidata.read()
print(csidata.csi.shape)
# PicoScenes
csifile = "../material/picoscenes/dataset/rx_by_iwl5300.csi"
csidata = csiread.Picoscenes(csifile, {'CSI': [30, 3, 2], 'MPDU': 1522})
csidata.read()
csidata.check()
print(csidata.raw['CSI']['CSI'].shape)
```
`examples` are the best usage instructions. The API documentation can be found in `docstring` of file `core.py`, so we won't repeat them here.
## Build from source
```bash
cd csiread
pip3 install -r requirements.txt
python3 setup.py sdist bdist_wheel
pip3 install -U dist/csiread*.whl
```
`*` is a shell wildcard. After running `python3 setup.py sdist bdist_wheel`,there will be a wheel file like `csiread-1.3.4-cp36-cp36m-win_amd64.whl` in the `dist` folder. Replace `csiread*.whl` with it.
csiread is written in Cython, Cython requires a C compiler to be present on the system. You can refer to [Installing Cython](https://cython.readthedocs.io/en/latest/src/quickstart/install.html) for more details. If you don't want to install a C compiler, just fork the project and push a tag to the latest commit. Then wheel files can be found in `Github-Actions-Python package-Artifacts: csiread_dist`
## Design
csiread provides 7 classes: `Intel, Atheros, Nexmon, AtherosPull10, NexmonPull46, ESP32 and Picoscenes`. Each class has 4 key methods: `read(), seek()`, `pmsg()` and `display()` which are used for reading a file, reading a file from a specific position, real-time parsing and viewing the contents of a packet respectively. `csiread.utils` provides some common functions.
### Nexmon CSI
- `csiread.Nexmon` is based on the commit of nexmon_csi(Aug 29, 2020): `ba99ce12a6a42d7e4ec75e6f8ace8f610ed2eb60`
- `csiread.NexmonPull256` is the same as `csiread.NexmonPull46`. It works with the latest master branch (Dec 11, 2021): `c037576b7035619e2716229c7622f4e8c511635f`
- The `Nexmon.group` is experimental, it may be incorrect due to `core` and `spatial`. `core` and `spatial` are ZERO or not recorded correctly in some files. I don't know how to solve it.
### ESP32-CSI-Tool
- `pandas.read_csv` and `csiread.ESP32` have the similar performance, but `pandas.read_csv` is much more flexible.
### PicoScenes
The support for Picoscenes is an **experimental** feature. PicoScenes is still under active development, csiread cannot be updated synchronously.
- `csidata.raw` is a [structured array](https://numpy.org/doc/stable/user/basics.rec.html#structured-arrays) in numpy and stores the parsed result.
- `Mag` and `Phase` fileds have been removed, use `np.abs` and `np.angle` instead.
- Call `check()` method after `read()`, Then set `pl_size` according to the report.
- Edge padding are applied to `raw["xxx"]["SubcarrierIndex"]` for plotting.
- The method `pmsg` has been implemented, but not yet ready.
- Accessing CSI like `csidata.CSI.CSI` is only available after calling `read` method.
- 5-10 times faster than before
- `parseCSIMVM(...)` in `_picoscenes.pyx` may be incorrect.
`csiread.Picoscenes` is based on the PicoScenes MATLAB Toolbox(PMT)(Last modified at 2022-01-21).
%package -n python3-csiread
Summary: A **fast** channel state information parser for Intel, Atheros, Nexmon, ESP32 and PicoScenes in Python.
Provides: python-csiread
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
BuildRequires: python3-cffi
BuildRequires: gcc
BuildRequires: gdb
%description -n python3-csiread
# csiread [](https://pypi.org/project/csiread/)
A **fast** channel state information parser for Intel, Atheros, Nexmon, ESP32 and PicoScenes in Python.
- Full support for [Linux 802.11n CSI Tool](https://dhalperi.github.io/linux-80211n-csitool/), [Atheros CSI Tool](https://wands.sg/research/wifi/AtherosCSI/), [nexmon_csi](https://github.com/seemoo-lab/nexmon_csi) and [ESP32-CSI-Tool](https://github.com/StevenMHernandez/ESP32-CSI-Tool)
- Support for [PicoScenes](https://ps.zpj.io) is **experimental**.
- At least 15 times faster than the implementation in Matlab
- Real-time parsing and visualization.
<center><b>real-time plotting</b></center>

## Introduction
Various CSI Tools only provide Matlab API parsing CSI data files. Those who want to process CSI with Python have to install Matlab to convert `.dat` to `.mat`. This process is redundant and inefficient. Therefore, **Python API** is recommended. Unfortunately, the API implemented in pure Python is inefficient. With this in mind, I implemented csiread in Cython(Pybind11 may be another great choice). The table below shows the performance of different implementations. They were all tested with **40k** packets on the same computer.
| Function | Matlab | Python3+Numpy | csiread | file size |
|-------------------------|----------|---------------|------------|-----------|
| Nexmon.read:bcm4339 | 3.2309s | 0.2739s | 0.0703s | 44.0MB |
| Nexmon.read:bcm4358 | 3.5987s | 23.0025s | 0.1227s | 44.0MB |
| Atheros.read | 3.3081s | 14.6021s | 0.0956s | 76.3MB |
| Intel.read | 1.6102s | 7.6624s | 0.0479s | 21.0MB |
| Intel.get_total_rss | 0.1786s | 0.0030s | 0.0030s | |
| Intel.get_scaled_csi | 0.5497s | 0.1225s | 0.0376s/0.0278s | |
| Intel.get_scaled_csi_sm | 5.0097s | 0.3627s | 0.0778s/0.0465s | |
This tool is not only the translation of the Matlab API, but also a **CSI toolbox**. I added some utilities, real-time visualization and algorithms code in the `examples` folder. These would be useful for Python-based CSI researchers.
## Install
```bash
pip3 install csiread
```
## Quickstart
```python
import csiread
# Linux 802.11n CSI Tool
csifile = "../material/5300/dataset/sample_0x1_ap.dat"
csidata = csiread.Intel(csifile, nrxnum=3, ntxnum=2, pl_size=10)
csidata.read()
csi = csidata.get_scaled_csi()
print(csidata.csi.shape)
# Atheros CSI Tool
csifile = "../material/atheros/dataset/ath_csi_1.dat"
csidata = csiread.Atheros(csifile, nrxnum=3, ntxnum=2, pl_size=10, tones=56)
csidata.read(endian='little')
print(csidata.csi.shape)
# nexmon_csi
csifile = "../material/nexmon/dataset/example.pcap"
csidata = csiread.Nexmon(csifile, chip='4358', bw=80)
csidata.read()
print(csidata.csi.shape)
# ESP32-CSI-Tool
csifile = "../material/esp32/dataset/example_csi.csv"
csidata = csiread.ESP32(csifile, csi_only=True)
csidata.read()
print(csidata.csi.shape)
# PicoScenes
csifile = "../material/picoscenes/dataset/rx_by_iwl5300.csi"
csidata = csiread.Picoscenes(csifile, {'CSI': [30, 3, 2], 'MPDU': 1522})
csidata.read()
csidata.check()
print(csidata.raw['CSI']['CSI'].shape)
```
`examples` are the best usage instructions. The API documentation can be found in `docstring` of file `core.py`, so we won't repeat them here.
## Build from source
```bash
cd csiread
pip3 install -r requirements.txt
python3 setup.py sdist bdist_wheel
pip3 install -U dist/csiread*.whl
```
`*` is a shell wildcard. After running `python3 setup.py sdist bdist_wheel`,there will be a wheel file like `csiread-1.3.4-cp36-cp36m-win_amd64.whl` in the `dist` folder. Replace `csiread*.whl` with it.
csiread is written in Cython, Cython requires a C compiler to be present on the system. You can refer to [Installing Cython](https://cython.readthedocs.io/en/latest/src/quickstart/install.html) for more details. If you don't want to install a C compiler, just fork the project and push a tag to the latest commit. Then wheel files can be found in `Github-Actions-Python package-Artifacts: csiread_dist`
## Design
csiread provides 7 classes: `Intel, Atheros, Nexmon, AtherosPull10, NexmonPull46, ESP32 and Picoscenes`. Each class has 4 key methods: `read(), seek()`, `pmsg()` and `display()` which are used for reading a file, reading a file from a specific position, real-time parsing and viewing the contents of a packet respectively. `csiread.utils` provides some common functions.
### Nexmon CSI
- `csiread.Nexmon` is based on the commit of nexmon_csi(Aug 29, 2020): `ba99ce12a6a42d7e4ec75e6f8ace8f610ed2eb60`
- `csiread.NexmonPull256` is the same as `csiread.NexmonPull46`. It works with the latest master branch (Dec 11, 2021): `c037576b7035619e2716229c7622f4e8c511635f`
- The `Nexmon.group` is experimental, it may be incorrect due to `core` and `spatial`. `core` and `spatial` are ZERO or not recorded correctly in some files. I don't know how to solve it.
### ESP32-CSI-Tool
- `pandas.read_csv` and `csiread.ESP32` have the similar performance, but `pandas.read_csv` is much more flexible.
### PicoScenes
The support for Picoscenes is an **experimental** feature. PicoScenes is still under active development, csiread cannot be updated synchronously.
- `csidata.raw` is a [structured array](https://numpy.org/doc/stable/user/basics.rec.html#structured-arrays) in numpy and stores the parsed result.
- `Mag` and `Phase` fileds have been removed, use `np.abs` and `np.angle` instead.
- Call `check()` method after `read()`, Then set `pl_size` according to the report.
- Edge padding are applied to `raw["xxx"]["SubcarrierIndex"]` for plotting.
- The method `pmsg` has been implemented, but not yet ready.
- Accessing CSI like `csidata.CSI.CSI` is only available after calling `read` method.
- 5-10 times faster than before
- `parseCSIMVM(...)` in `_picoscenes.pyx` may be incorrect.
`csiread.Picoscenes` is based on the PicoScenes MATLAB Toolbox(PMT)(Last modified at 2022-01-21).
%package help
Summary: Development documents and examples for csiread
Provides: python3-csiread-doc
%description help
# csiread [](https://pypi.org/project/csiread/)
A **fast** channel state information parser for Intel, Atheros, Nexmon, ESP32 and PicoScenes in Python.
- Full support for [Linux 802.11n CSI Tool](https://dhalperi.github.io/linux-80211n-csitool/), [Atheros CSI Tool](https://wands.sg/research/wifi/AtherosCSI/), [nexmon_csi](https://github.com/seemoo-lab/nexmon_csi) and [ESP32-CSI-Tool](https://github.com/StevenMHernandez/ESP32-CSI-Tool)
- Support for [PicoScenes](https://ps.zpj.io) is **experimental**.
- At least 15 times faster than the implementation in Matlab
- Real-time parsing and visualization.
<center><b>real-time plotting</b></center>

## Introduction
Various CSI Tools only provide Matlab API parsing CSI data files. Those who want to process CSI with Python have to install Matlab to convert `.dat` to `.mat`. This process is redundant and inefficient. Therefore, **Python API** is recommended. Unfortunately, the API implemented in pure Python is inefficient. With this in mind, I implemented csiread in Cython(Pybind11 may be another great choice). The table below shows the performance of different implementations. They were all tested with **40k** packets on the same computer.
| Function | Matlab | Python3+Numpy | csiread | file size |
|-------------------------|----------|---------------|------------|-----------|
| Nexmon.read:bcm4339 | 3.2309s | 0.2739s | 0.0703s | 44.0MB |
| Nexmon.read:bcm4358 | 3.5987s | 23.0025s | 0.1227s | 44.0MB |
| Atheros.read | 3.3081s | 14.6021s | 0.0956s | 76.3MB |
| Intel.read | 1.6102s | 7.6624s | 0.0479s | 21.0MB |
| Intel.get_total_rss | 0.1786s | 0.0030s | 0.0030s | |
| Intel.get_scaled_csi | 0.5497s | 0.1225s | 0.0376s/0.0278s | |
| Intel.get_scaled_csi_sm | 5.0097s | 0.3627s | 0.0778s/0.0465s | |
This tool is not only the translation of the Matlab API, but also a **CSI toolbox**. I added some utilities, real-time visualization and algorithms code in the `examples` folder. These would be useful for Python-based CSI researchers.
## Install
```bash
pip3 install csiread
```
## Quickstart
```python
import csiread
# Linux 802.11n CSI Tool
csifile = "../material/5300/dataset/sample_0x1_ap.dat"
csidata = csiread.Intel(csifile, nrxnum=3, ntxnum=2, pl_size=10)
csidata.read()
csi = csidata.get_scaled_csi()
print(csidata.csi.shape)
# Atheros CSI Tool
csifile = "../material/atheros/dataset/ath_csi_1.dat"
csidata = csiread.Atheros(csifile, nrxnum=3, ntxnum=2, pl_size=10, tones=56)
csidata.read(endian='little')
print(csidata.csi.shape)
# nexmon_csi
csifile = "../material/nexmon/dataset/example.pcap"
csidata = csiread.Nexmon(csifile, chip='4358', bw=80)
csidata.read()
print(csidata.csi.shape)
# ESP32-CSI-Tool
csifile = "../material/esp32/dataset/example_csi.csv"
csidata = csiread.ESP32(csifile, csi_only=True)
csidata.read()
print(csidata.csi.shape)
# PicoScenes
csifile = "../material/picoscenes/dataset/rx_by_iwl5300.csi"
csidata = csiread.Picoscenes(csifile, {'CSI': [30, 3, 2], 'MPDU': 1522})
csidata.read()
csidata.check()
print(csidata.raw['CSI']['CSI'].shape)
```
`examples` are the best usage instructions. The API documentation can be found in `docstring` of file `core.py`, so we won't repeat them here.
## Build from source
```bash
cd csiread
pip3 install -r requirements.txt
python3 setup.py sdist bdist_wheel
pip3 install -U dist/csiread*.whl
```
`*` is a shell wildcard. After running `python3 setup.py sdist bdist_wheel`,there will be a wheel file like `csiread-1.3.4-cp36-cp36m-win_amd64.whl` in the `dist` folder. Replace `csiread*.whl` with it.
csiread is written in Cython, Cython requires a C compiler to be present on the system. You can refer to [Installing Cython](https://cython.readthedocs.io/en/latest/src/quickstart/install.html) for more details. If you don't want to install a C compiler, just fork the project and push a tag to the latest commit. Then wheel files can be found in `Github-Actions-Python package-Artifacts: csiread_dist`
## Design
csiread provides 7 classes: `Intel, Atheros, Nexmon, AtherosPull10, NexmonPull46, ESP32 and Picoscenes`. Each class has 4 key methods: `read(), seek()`, `pmsg()` and `display()` which are used for reading a file, reading a file from a specific position, real-time parsing and viewing the contents of a packet respectively. `csiread.utils` provides some common functions.
### Nexmon CSI
- `csiread.Nexmon` is based on the commit of nexmon_csi(Aug 29, 2020): `ba99ce12a6a42d7e4ec75e6f8ace8f610ed2eb60`
- `csiread.NexmonPull256` is the same as `csiread.NexmonPull46`. It works with the latest master branch (Dec 11, 2021): `c037576b7035619e2716229c7622f4e8c511635f`
- The `Nexmon.group` is experimental, it may be incorrect due to `core` and `spatial`. `core` and `spatial` are ZERO or not recorded correctly in some files. I don't know how to solve it.
### ESP32-CSI-Tool
- `pandas.read_csv` and `csiread.ESP32` have the similar performance, but `pandas.read_csv` is much more flexible.
### PicoScenes
The support for Picoscenes is an **experimental** feature. PicoScenes is still under active development, csiread cannot be updated synchronously.
- `csidata.raw` is a [structured array](https://numpy.org/doc/stable/user/basics.rec.html#structured-arrays) in numpy and stores the parsed result.
- `Mag` and `Phase` fileds have been removed, use `np.abs` and `np.angle` instead.
- Call `check()` method after `read()`, Then set `pl_size` according to the report.
- Edge padding are applied to `raw["xxx"]["SubcarrierIndex"]` for plotting.
- The method `pmsg` has been implemented, but not yet ready.
- Accessing CSI like `csidata.CSI.CSI` is only available after calling `read` method.
- 5-10 times faster than before
- `parseCSIMVM(...)` in `_picoscenes.pyx` may be incorrect.
`csiread.Picoscenes` is based on the PicoScenes MATLAB Toolbox(PMT)(Last modified at 2022-01-21).
%prep
%autosetup -n csiread-1.4.0
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-csiread -f filelist.lst
%dir %{python3_sitearch}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 1.4.0-1
- Package Spec generated
|