This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Capture filter equivalent of a given display filter for 802.11 frames encapsulated into TZSP

0

I want to write a capture filter for this display filter "tzsp && wlan.ra==<some mac="" address="">" in tshark. I can write "udp port 37008" in place for tzsp but I cannot find anywhere about how to write capture filter for wlan.ra==<some mac="" address=""> .

EDIT: I am using a mikrotik routerboard to stream the sniffed 802.11 frames to my laptop over an IP network using TZSP encapsulation.

Please help, Thanks in advance.

asked 02 Sep '16, 05:42

tatsugot's gravatar image

tatsugot
16558
accept rate: 0%

edited 06 Sep '16, 05:28

sindy's gravatar image

sindy
6.0k4851


2 Answers:

1

Tzsp means that Mikrotik encapsulates the captured 802.11 frames into UDP, so the fact that the interface on which you capture indicates link type as Ethernet is OK. But this also means that the libpcap's capture filter processes the captured frames as Ethernet ones. Unfortunately, you cannot tell libpcap to ignore first N octets of an Ethernet frame and interpret the rest as 802.11.

So you would have to use a complex capture filter expression like port tzsp and udp[X:4] = 0xaabbccdd and udp[X+4:2] = 0xeeff, where aa:bb:cc:dd:ee:ff is the recipient mac address you are interested in and X is the offset of ra from the beginning of the UDP portion of the tzsp packet.

I am afraid that the absolute position of the ra in the 802.11 frame depends on frame type, so the X above may not be constant and so you would have to use an even more complex filter, looking at the frame type first and choosing the proper X value accordingly, like

(udp[T:1] & 0xf = type1 and udp[X1:4] = 0xaabbccdd and udp[X1+4:2]=0xeeff) or (udp[T:1] & 0xf = type2 and udp[X2:4] = 0xaabbccdd and udp[X2+4:2]=0xeeff) or (udp[T:1] & 0xf = type3 and udp[X3:4] = 0xaabbccdd and udp[X3+4:2]=0xeeff)

The display filter works another way, it doesn't care at which place in the protocol hierarchy inside a frame the protocol field in question is placed. So in your particular case, where the IP layer may occur twice in a frame, a display filter ip.addr == a.b.c.d would match both if e.g. the Mikrotik's own IP address would be a.b.c.d or if an IP address inside an 802.11 frame encapsulated into tzsp would be a.b.c.d.

answered 06 Sep '16, 04:51

sindy's gravatar image

sindy
6.0k4851
accept rate: 24%

edited 06 Sep '16, 05:17

@sindy udp[X1:4] = 0xaabbccdd and udp[X1+4:2]=0xeeff why have you broken it in two parts

(06 Sep '16, 05:13) tatsugot
1

because the capture filter can work with maximum 32 bits (4 bytes) at a time, so a 6-octet MAC address needs to be handled this way. As stated at the pcap-filter man page, "Size is optional and indicates the number of bytes in the field of interest; it can be either one, two, or four, and defaults to one."

(06 Sep '16, 05:20) sindy

0

According to the pcap-filter manual page you should be looking at wlan ra ehost

answered 02 Sep '16, 07:32

Jaap's gravatar image

Jaap ♦
11.7k16101
accept rate: 14%

thanks for answering sir. I had tried it earlier like---

Input: tshark -i eno1 -f "udp port 37008 && wlan ra 01:40:96:00:00:03"

and I am getting this

Output: tshark: Invalid capture filter "udp port 37008 && wlan ra 01:40:96:00:00:03" for interface 'wlo1'.

That string isn't a valid capture filter ('ra' is only supported on 802.11 with 802.11 headers). See the User's Guide for a description of the capture filter syntax.

What should I do?

(04 Sep '16, 05:27) tatsugot

what does tshark -i eno1 -L say?

(04 Sep '16, 06:37) sindy

@sindy it returns Data link types of interface eno1 (use option -y to set): EN10MB (Ethernet) DOCSIS (DOCSIS)

(05 Sep '16, 23:01) tatsugot

And despite that, if you capture on that interface without any filter, you get 802.11 frames with radiotap header etc.?

(06 Sep '16, 01:54) sindy

@sindy In wireshark if I put the display filter as tzsp && wlan.ra == 01:40:96:00:00:03 I can see the packets I need to see.

(06 Sep '16, 02:44) tatsugot

That sounds strange, so:

  • how do you switch eno1 to monitoring mode when capturing using Wireshark? Using some utility before or from the Wireshark GUI (sorry, I have only Windows version of Wireshark)?

  • have you switched eno1 to monitoring mode before issuing tshark -i eno1 -L?

  • what happens if you try to use the capture filter suggested by @Jaap from the GUI Wireshark?

(06 Sep '16, 02:53) sindy

@sindy I am using a mikrotik routerboard to stream the sniffer stream to my laptop. Then I am using tshark to capture traffic and store it in pcap files. The traffic is streamed via ethernet so I am using eno1.

If I use the filter Jaap suggested it gives me this

tshark: Invalid capture filter "udp port 37008 && wlan ra 01:40:96:00:00:03" for interface 'wlo1'.

That string isn't a valid capture filter ('ra' is only supported on 802.11 with 802.11 headers). See the User's Guide for a description of the capture filter syntax.

(06 Sep '16, 04:25) tatsugot
showing 5 of 7 show 2 more comments