Skip to content

Commit 24ea80f

Browse files
authored
Merge pull request RIOT-OS/applications#43 from miri64/sniffer/fix/doc
sniffer: various documentation improvements
2 parents 76a98e3 + 9f50194 commit 24ea80f

File tree

3 files changed

+20
-35
lines changed

3 files changed

+20
-35
lines changed

sniffer/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
About
22
=====
33

4-
This application is build to run together with the script `RIOTBASE/dist/tools/sniffer/sniffer.py` as sniffer for (wireless) data traffic. This application works with any board with any network device that supports the gnrc network stack (or precisely the gnrc parts up to the link-layer). Further the network device (and it's driver) needs to support promiscuous and raw mode for usable output. Finally the board needs to include auto-initialization code for the targeted network device.
4+
This application is build to run together with the script `./tools/sniffer.py` as sniffer for (wireless) data traffic. This application works with any board with any network device that supports the gnrc network stack (or precisely the gnrc parts up to the link-layer). Further the network device (and it's driver) needs to support promiscuous and raw mode for usable output. Finally the board needs to include auto-initialization code for the targeted network device.
55

66

77
Usage

sniffer/tools/README.md

+13-31
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,18 @@ $ RIOTBASE=<path/to/RIOT> BOARD=<name> make clean all flash
4646
2. Run the `sniffer.py` script (change to subfolder `tools/`) as follows :
4747
For serial port:
4848
```
49-
$ ./sniffer.py serial <tty> <baudrate> <channel> [outfile]
49+
$ ./sniffer.py [-b baudrate] <tty> <channel> [outfile]
5050
```
5151
For network socket:
5252
```
53-
$ ./sniffer.py socket <host> <port> <channel> [outfile]
54-
```
55-
56-
The script has the following parameters:
57-
58-
- **connType:** The type of connection to use. Either `serial` for serial ports or
59-
`socket` for network sockets.
60-
- **host:** The host if the `socket` connection type is in use.
61-
- **port:** The port of the host if the `socket` connection type is in use.
62-
- **tty:** The serial port the RIOT board is connected to. Under Linux, this is
63-
typically something like /dev/ttyUSB0 or /dev/ttyACM0. Under Windows,
64-
this is typically something like COM0 or COM1. This option is used
65-
for the `serial` connection type.
66-
- **baudrate:** The baudrate the serial port is configured to. The default in
67-
RIOT is 115200, though this is defined per board and some boards
68-
have some other value defined per default. NOTE: when sniffing
69-
networks where the on-air bitrate is > baudrate, it makes sense
70-
to increase the baudrate so no data is skipped when sniffing.
71-
This option is used for the `serial` connection type.
72-
- **channel:** The radio channel to use when sniffing. Possible values vary and
73-
depend on the link-layer that is sniffed. This parameter is
74-
ignored when sniffing wired networks.
75-
- **[outfile]:** When this parameter is specified, the sniffer output is saved
76-
into this file. See the examples below for alternatives to
77-
specifying this parameter. (optional)
53+
$ ./sniffer.py <host>:<port> <channel> [outfile]
54+
```
55+
56+
For detailed information on the parameters use the scripts on-line help:
7857

58+
```
59+
./sniffer.py -h
60+
```
7961

8062
### Examples
8163

@@ -88,14 +70,14 @@ is used.
8870

8971
Dump packets to a file:
9072
```
91-
$ ./sniffer.py serial /dev/ttyUSB1 500000 17 > foo.pcap
73+
$ ./sniffer.py -b 500000 /dev/ttyUSB1 17 foo.pcap
9274
```
9375

9476
This .pcap can then be opened in Wireshark.
9577

9678
Alternatively for live captures, you can pipe directly into Wireshark with:
9779
```
98-
$ ./sniffer.py serial /dev/ttyUSB1 500000 17 | wireshark -k -i -
80+
$ ./sniffer.py -b 500000 /dev/ttyUSB1 17 | wireshark -k -i -
9981
```
10082

10183
#### Windows (serial)
@@ -104,7 +86,7 @@ For windows you can use the optional third argument to output to a
10486
.pcap:
10587

10688
```
107-
$ ./sniffer.py serial COM1 500000 17 foo.pcap
89+
$ ./sniffer.py -b 500000 COM1 17 foo.pcap
10890
```
10991

11092
#### IoT-Lab Testbed (socket)
@@ -119,6 +101,6 @@ ssh -L 20000:_node-id_:20000 _user_@_site_.iot-lab.info
119101
Then you can dump or observe the traffic generated by the other nodes running the `gnrc_networking`
120102
application via one of the following commands:
121103
```
122-
$ ./sniffer.py socket localhost 20000 26 > foo.pcap
123-
$ ./sniffer.py socket localhost 20000 26 | wireshark -k -i -
104+
$ ./sniffer.py localhost:20000 26 foo.pcap
105+
$ ./sniffer.py localhost:20000 26 | wireshark -k -i -
124106
```

sniffer/tools/sniffer.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
SNAPLEN = 0xffff
5151
NETWORK = 230 # 802.15.4 no FCS
5252

53+
DEFAULT_BAUDRATE = 115200
54+
5355

5456
def configure_interface(port, channel):
5557
line = ""
@@ -141,16 +143,17 @@ def main():
141143
else:
142144
default_outfile = sys.stdout
143145
p = argparse.ArgumentParser()
144-
p.add_argument("-b", "--baudrate", type=int, default=115200,
146+
p.add_argument("-b", "--baudrate", type=int, default=DEFAULT_BAUDRATE,
145147
help="Baudrate of the serial port (only evaluated "
146-
"for non TCP-terminal)")
148+
"for non TCP-terminal, default: %d)" %
149+
DEFAULT_BAUDRATE)
147150
p.add_argument("conn", metavar="tty/host:port", type=str,
148151
help="Serial port or TCP (host, port) tuple to "
149152
"terminal with sniffer application")
150153
p.add_argument("channel", type=int, help="Channel to sniff on")
151154
p.add_argument("outfile", type=argparse.FileType("w+b"),
152155
default=default_outfile, nargs="?",
153-
help="PCAP file to output to")
156+
help="PCAP file to output to (default: stdout)")
154157
args = p.parse_args()
155158

156159
conn = connect(args)

0 commit comments

Comments
 (0)