# swx-tcpdump > [!NOTE] > **WHAT TO EXPECT** > > `swx-tcpdump` is a build of the well-known `tcpdump` packet analyzer that ships with the cloudSwXtch tools. It captures the multicast traffic of an xNIC, and the traffic the xNIC exchanges with the cloudSwXtch, with the same options and filters as `tcpdump`. > > **In this article,** users will learn where swx-tcpdump is installed, which interface to capture on, and the arguments it accepts. ### Where swx-tcpdump is installed `swx-tcpdump` is part of the `swx-tools` package, which the xNIC installer adds to Linux VMs. It is also available on the cloudSwXtch VM. It is not installed with the Windows xNIC. ```shell $ swx-tcpdump --version swx-tcpdump version 5.0.0-PRE-GIT libpcap version 1.10.4 (with TPACKET_V3) OpenSSL 3.0.13 30 Jan 2024 ``` ### Using swx-tcpdump Capturing packets requires root privileges, so run swx-tcpdump with `sudo`. Choose the interface with `-i`: ```shell sudo swx-tcpdump -i [options] [expression] ``` > [!WARNING] > **ALWAYS SELECT THE INTERFACE** > > Without `-i`, swx-tcpdump listens on the first interface in its list, which is usually the control interface of the VM, not `swx0`. Always pass `-i` with the interface to capture on. `-D` lists the interfaces swx-tcpdump can capture on (`ip a` shows them as well): ```shell $ sudo swx-tcpdump -D 1.enp39s0 [Up, Running, Connected] 2.enp40s0 [Up, Running, Connected] 3.swx0 [Up, Running, Connected] 4.any (Pseudo-device that captures on all interfaces) [Up, Running] 5.lo [Up, Running, Loopback] ... ``` #### Choosing the interface | Interface | xNIC type | What is captured | | --- | --- | --- | | `swx0` | Type 1 and Type 3 | The multicast streams as the applications on the VM send and receive them: the original source address, the multicast group and port, and the payload. | | Data interface (for example `eth1` or `enp40s0`) | All types (the only option on Type 2, which has no `swx0`) | The traffic between the xNIC and the cloudSwXtch. The multicast packets travel inside UDP packets on port `9999`, between the data IPs of the xNIC and the cloudSwXtch. | To troubleshoot a stream, start on `swx0`: if the packets are there, the xNIC is delivering them. If they are not, capture on the data interface with `udp port 9999` to check whether traffic from the cloudSwXtch reaches the VM. #### Examples **Example:** Capture 4 packets on swx0 ```shell $ sudo swx-tcpdump -i swx0 -n -c 4 swx-tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on swx0, link-type EN10MB (Ethernet), snapshot length 262144 bytes 21:21:15.209540 IP 10.203.105.206.62235 > 239.1.1.10.10000: UDP, length 200 21:21:15.259545 IP 10.203.105.206.62235 > 239.1.1.10.10000: UDP, length 200 21:21:15.309531 IP 10.203.105.206.62235 > 239.1.1.10.10000: UDP, length 200 21:21:15.359533 IP 10.203.105.206.62235 > 239.1.1.10.10000: UDP, length 200 4 packets captured 20 packets received by filter 0 packets dropped by kernel ``` **Example:** Capture one multicast group only, with IP header details (-v) ```shell $ sudo swx-tcpdump -i swx0 -n -v -c 2 dst 239.1.1.10 swx-tcpdump: listening on swx0, link-type EN10MB (Ethernet), snapshot length 262144 bytes 21:21:16.209545 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 228) 10.203.105.206.62235 > 239.1.1.10.10000: UDP, length 200 21:21:16.259539 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 228) 10.203.105.206.62235 > 239.1.1.10.10000: UDP, length 200 2 packets captured 20 packets received by filter 0 packets dropped by kernel ``` **Example:** Show the content of a packet in hex and ASCII (-X) ```shell $ sudo swx-tcpdump -i swx0 -n -X -c 1 dst 239.1.1.10 swx-tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on swx0, link-type EN10MB (Ethernet), snapshot length 262144 bytes 21:21:17.259559 IP 10.203.105.206.62235 > 239.1.1.10.10000: UDP, length 200 0x0000: 4500 00e4 0000 4000 4011 d564 0acb 69ce E.....@.@..d..i. 0x0010: ef01 010a f31b 2710 00d0 0000 5357 5832 ......'.....SWX2 0x0020: 0204 c800 0000 0000 6400 0000 0000 0000 ........d....... 0x0030: 44f5 3cf1 949b 2523 e49f b8c6 d638 bc03 D.<...%#.....8.. 0x0040: cde5 d2fb 970f 543e 709a 8568 e6d7 db40 ......T>p..h...@ 0x0050: 3737 cde7 90fa 02ab 68ce 0738 66c4 8903 77......h..8f... 0x0060: a9a3 dce7 fc10 b3b3 122e 188a 883d f8d3 .............=.. 0x0070: ad59 559e 2bf4 dc1d a9ab 83bb 4477 178f .YU.+.......Dw.. 0x0080: 82b1 5cc5 5ddf 19f2 6e2e ee9f 4bae e1bb ..\.]...n...K... 0x0090: 2ba7 59f1 a8e4 a0ee 5230 bc01 56a2 1152 +.Y.....R0..V..R 0x00a0: 4917 2f7f e96c bd16 fdbe 4ebf 567b e44f I./..l....N.V{.O 0x00b0: 8d68 e3de a630 fa92 e2f0 7cf2 44e6 6381 .h...0....|.D.c. 0x00c0: bbbb 9e22 a75c d993 e676 7eba 6b62 b826 ...".\...v~.kb.& 0x00d0: 6235 eea6 2def 7a28 a8ae a53c 8de4 fe13 b5..-.z(...<.... 0x00e0: a1d3 66b2 ..f. 1 packet captured 20 packets received by filter 0 packets dropped by kernel ``` To capture the traffic between the xNIC and the cloudSwXtch on the data interface (here `enp40s0`): ```shell sudo swx-tcpdump -i enp40s0 -n -c 4 udp port 9999 ``` The capture can be saved to a file with `-w` and read later with `-r`, for example to send it to swXtch.io support or to open it in Wireshark: ```shell sudo swx-tcpdump -i swx0 -n -c 100 -w /tmp/capture.pcap dst 239.1.1.10 swx-tcpdump -r /tmp/capture.pcap -n ``` On the cloudSwXtch VM, swx-tcpdump runs inside the `swx-swxtch` container, so the file path is a path inside the container. Write the capture to `/var/opt/swx/swxtch`, the folder the VM shares with the container, to find it on the VM: ```shell sudo swx-tcpdump -i -n -c 100 -w /var/opt/swx/swxtch/capture.pcap ``` > [!NOTE] > **NOTE** > > In these examples, `-n` prints addresses and ports as numbers, and `-c` stops after the given number of packets. Without `-c`, press `Ctrl+C` to stop the capture. #### Additional arguments Users can use the `-h` argument, as shown below, to get the list of arguments for swx-tcpdump: ```shell $ swx-tcpdump -h swx-tcpdump version 5.0.0-PRE-GIT libpcap version 1.10.4 (with TPACKET_V3) OpenSSL 3.0.13 30 Jan 2024 Usage: swx-tcpdump [-AbdDefhHIJKlLnNOpqStuUvxX#] [ -B size ] [ -c count ] [--count] [ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ] [ -i interface ] [ --immediate-mode ] [ -j tstamptype ] [ -M secret ] [ --number ] [ --print ] [ --print-sampling nth ] [ -Q in|out|inout ] [ -r file ] [ -s snaplen ] [ -T type ] [ --version ] [ -V file ] [ -w file ] [ -W filecount ] [ -y datalinktype ] [ --time-stamp-precision precision ] [ --micro ] [ --nano ] [ -z postrotate-command ] [ -Z user ] [ expression ] ``` The arguments and filter expressions are the same as in `tcpdump`. swx-tcpdump has no manual page of its own; see the manual page of tcpdump (`man tcpdump`, when tcpdump is installed) or [tcpdump.org](https://www.tcpdump.org/manpages/tcpdump.1.html).