<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>RFtap</title>
    <description>RFtap is a simple protocol designed to provide Radio Frequency (RF) metadata about packets.
</description>
    <link>https://rftap.github.io/</link>
    <atom:link href="https://rftap.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Thu, 22 Sep 2016 12:30:02 +0000</pubDate>
    <lastBuildDate>Thu, 22 Sep 2016 12:30:02 +0000</lastBuildDate>
    <generator>Jekyll v3.2.1</generator>
    
      <item>
        <title>New RFtap Zigbee demo added</title>
        <description>&lt;h2 id=&quot;new-zigbee-demo&quot;&gt;New Zigbee Demo&lt;/h2&gt;

&lt;p&gt;Zigbee demo added to &lt;a href=&quot;https://github.com/rftap/gr-rftap&quot;&gt;gr-rftap&lt;/a&gt;. See gr-rftap examples directory. Notice the &lt;a href=&quot;/&quot;&gt;RFtap&lt;/a&gt; “Signal Quality” metric available in Wireshark for every packet:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/zigbee/zigbee_rftap_wireshark.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;RFtap Zigbee demo&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In order to achieve this result, available in the examples/zigbee_rftap.grc flowgraph, we add two blocks:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;RFtap Encapsulation&lt;/li&gt;
  &lt;li&gt;LQI to qual&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/zigbee/zigbee_rftap_flowgraph.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Zigbee flowgraph zoom - RFtap section&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In the RFtap encapsulation block, we specify a Custom Data Link Type of 195 (Zigbee), as per this &lt;a href=&quot;http://www.tcpdump.org/linktypes.html&quot;&gt;linktype list&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/zigbee/rftap_block.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;RFtap block properties&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;As for the Signal Quality property, we use the Link Quality Indicator (LQI) available from 802.15.4 block, and convert it to RFtap signal quality (qual) field using an embedded python block:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/zigbee/lqi_block.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Embedded python block properties - &quot;LQI to qual&quot;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The embedded code:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;gnuradio&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gr&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pmt&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;blk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;basic_block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;&quot;&quot;Convert Zigbee Link Quality Indicator (LQI) (0..255) 
       to RFtap signal quality field (qual) (0.0..1.0)&quot;&quot;&quot;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;gr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;basic_block&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'LQI to qual'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;   &lt;span class=&quot;c&quot;&gt;# will show up in GRC&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;in_sig&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[],&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;out_sig&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message_port_register_in&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;intern&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'in'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_msg_handler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;intern&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'in'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;handle_msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message_port_register_out&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;intern&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'out'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;handle_msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pdu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_python&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pdu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'qual'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'lqi'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;255.0&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pduout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cons&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_pmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_pmt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message_port_pub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;intern&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'out'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pduout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The modified Zigbee flowgraph is available in &lt;a href=&quot;https://github.com/rftap/gr-rftap/tree/master/examples&quot;&gt;gr-rftap/examples&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The demo uses the GNU Radio &lt;a href=&quot;https://www.wime-project.net/features/#zigbee&quot;&gt;802.15.4 Zigbee module&lt;/a&gt;, part of the &lt;a href=&quot;https://www.wime-project.net/&quot;&gt;WiME project&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/zigbee/zigbee_rx_wime.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;IEEE 802.15.4 ZigBee WiME project&lt;/div&gt;
&lt;/div&gt;

&lt;h2 id=&quot;what-is-rftap&quot;&gt;What is RFtap?&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;/&quot;&gt;RFtap&lt;/a&gt; is a simple protocol designed to provide RF (Radio Frequency) metadata about packets, such as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Accurate signal and noise power&lt;/li&gt;
  &lt;li&gt;Accurate timing and phase information&lt;/li&gt;
  &lt;li&gt;Accurate &lt;a href=&quot;https://en.wikipedia.org/wiki/Carrier_frequency&quot;&gt;Carrier&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Doppler_effect&quot;&gt;Doppler&lt;/a&gt; frequencies of every packet, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can think of RFtap as the “glue” between GNU Radio and Wireshark, allowing access to RF metadata from Wireshark or Scapy.&lt;/p&gt;

&lt;p&gt;The RFtap protocol is designed to encapsulate any type of packet: Wi-Fi, Bluetooth, or packets from any proprietary protocol.&lt;/p&gt;
</description>
        <pubDate>Sun, 04 Sep 2016 00:00:00 +0000</pubDate>
        <link>https://rftap.github.io/blog/2016/09/04/rftap-zigbee.html</link>
        <guid isPermaLink="true">https://rftap.github.io/blog/2016/09/04/rftap-zigbee.html</guid>
        
        
        <category>blog</category>
        
      </item>
    
      <item>
        <title>Using RFtap to Detect MAC Spoofing</title>
        <description>&lt;p&gt;In this post we’ll use &lt;a href=&quot;http://gnuradio.org/&quot;&gt;GNU Radio&lt;/a&gt;’s &lt;a href=&quot;https://github.com/bastibl/gr-ieee802-11&quot;&gt;Wi-Fi receiver&lt;/a&gt;, &lt;a href=&quot;/&quot;&gt;RFtap&lt;/a&gt; and &lt;a href=&quot;https://www.wireshark.org/&quot;&gt;Wireshark&lt;/a&gt; to detect Wi-Fi &lt;a href=&quot;https://en.wikipedia.org/wiki/MAC_spoofing&quot;&gt;MAC spoofing&lt;/a&gt; by using the unique &lt;a href=&quot;https://en.wikipedia.org/wiki/Carrier_frequency_offset&quot;&gt;carrier offset frequency&lt;/a&gt; of each Wi-Fi packet.&lt;/p&gt;

&lt;h2 id=&quot;what-is-rftap&quot;&gt;What is RFtap?&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;/&quot;&gt;RFtap&lt;/a&gt; is a simple protocol designed to provide RF (Radio Frequency) metadata about packets, such as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Accurate signal and noise power&lt;/li&gt;
  &lt;li&gt;Accurate timing and phase information&lt;/li&gt;
  &lt;li&gt;Accurate &lt;a href=&quot;https://en.wikipedia.org/wiki/Carrier_frequency&quot;&gt;Carrier&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Doppler_effect&quot;&gt;Doppler&lt;/a&gt; frequencies of every packet, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can think of RFtap as the “glue” between GNU Radio and Wireshark, allowing access to RF metadata from Wireshark or Scapy.&lt;/p&gt;

&lt;p&gt;The RFtap protocol is designed to encapsulate any type of packet: Wi-Fi, Bluetooth, or packets from any proprietary protocol. Here we’ll encapsulate Wi-Fi packets.&lt;/p&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;

&lt;p&gt;Plenty! :smile: You will need a fast Mac or Linux computer (I use Ubuntu 16.04 on Intel i5), a SDR receiver capable of receiving 20MHz bandwidth at a center frequency of ~5GHz such as Ettus &lt;a href=&quot;https://www.ettus.com/product/details/UN210-KIT&quot;&gt;N210&lt;/a&gt; or &lt;a href=&quot;https://www.ettus.com/product/details/USRP-B200mini&quot;&gt;B200&lt;/a&gt;. Install &lt;a href=&quot;http://gnuradio.org/redmine/projects/gnuradio/wiki/InstallingGRFromSource&quot;&gt;GNU Radio from source&lt;/a&gt; (I followed &lt;a href=&quot;https://github.com/gnuradio/pybombs/blob/master/README.md&quot;&gt;these instructions&lt;/a&gt;), install GNU Radio’s &lt;a href=&quot;https://github.com/bastibl/gr-ieee802-11&quot;&gt;Wi-Fi IEEE 802.11 a/g/p transceiver&lt;/a&gt;. Verify that you can receive Wi-Fi packets from nearby 5GHz access points by running: &lt;code class=&quot;highlighter-rouge&quot;&gt;gnuradio-companion gr-ieee-80211/examples/wifi_rx.grc&lt;/code&gt;. See &lt;a href=&quot;https://github.com/bastibl/gr-ieee802-11/blob/master/README.md&quot;&gt;gr-ieee802-11 README&lt;/a&gt; for troubleshooting. Install &lt;a href=&quot;https://github.com/rftap/gr-rftap&quot;&gt;gr-rftap&lt;/a&gt;. Install &lt;a href=&quot;https://www.wireshark.org/&quot;&gt;Wireshark&lt;/a&gt; version 2.3 or higher. You can verify that Wireshark supports RFtap by loading this &lt;a href=&quot;/assets/rftap/rftap_sample.pcap&quot;&gt;sample RFtap pcap file&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=-EvNOvg0USs&quot;&gt;Presentation about GNU Radio IEEE 802.11a/g/p OFDM Receiver&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/wifi/gr-802-11.png&quot; width=&quot;50%&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Test setup for demonstrating GNU Radio Wi-Fi transceiver&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Don’t have the required hardware? Try the &lt;a href=&quot;/blog/2016/08/27/decoding-rds-with-rftap.html&quot;&gt;RFtap RDS tutorial&lt;/a&gt; instead, using the low-cost &lt;a href=&quot;http://www.rtl-sdr.com/about-rtl-sdr/&quot;&gt;RTL-SDR&lt;/a&gt; receiver.&lt;/p&gt;

&lt;h2 id=&quot;wi-fi&quot;&gt;Wi-Fi&lt;/h2&gt;

&lt;p&gt;When observing Wi-Fi packets in the wild, we can notice that each packet has a slightly different carrier frequency. This &lt;a href=&quot;https://en.wikipedia.org/wiki/Carrier_frequency_offset&quot;&gt;frequency offset&lt;/a&gt;, colloquially named the Doppler shift, is caused by several factors, chief among them:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Inaccuracy of the crystal oscillator in the Wi-Fi transmitter and receiver&lt;/li&gt;
  &lt;li&gt;Velocity of the Wi-Fi transmitter and receiver (&lt;a href=&quot;https://en.wikipedia.org/wiki/Doppler_effect&quot;&gt;Doppler effect&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you can probably guess, that’s an interesting RF metadata to have, since it can reveal unique properties of the Wi-Fi transmitter.&lt;/p&gt;

&lt;p&gt;Despite considerable efforts of manufacturers to keep this frequency error as low as possible (typically less than 20 parts-per-million, or 0.002% of the carrier frequency), even this slight error can wreak havoc on the OFDM receiver. The frequency error typically manifests as a &lt;em&gt;rotation&lt;/em&gt; effect in the QAM constellation, as seen on the left:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/wifi/qam_rotating.gif&quot; width=&quot;98%&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Left: QAM constellation before correction; Right: QAM after frequency correction and symbol synchronization&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Because of the extreme sensitivity to frequency error, every Wi-Fi receiver in the world implements a complex algorithm to measure and correct for frequency offset. Without this correction, OFDM reception would be practically impossible. So fortunately for us, we don’t have to implement anything new to get this offset:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/wifi/flow_wifi_sync.png&quot; width=&quot;98%&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Frequency synchronization in wifi_rx.grc flowgraph&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In the GNU Radio Wi-Fi flowgraph, there are 3 blocks responsible for frequency synchronization:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;“Sync Short” block, making a coarse estimation of the frequency&lt;/li&gt;
  &lt;li&gt;“Sync Long” block, making a more accurate estimation of the carrier frequency offset&lt;/li&gt;
  &lt;li&gt;“Frame Equalizer” block, making &lt;em&gt;extra-fine&lt;/em&gt; corrections to the frequency while decoding the symbols of a single Wi-Fi packet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After all this hard work, the carrier frequency estimation for the packet is just thrown away… :cry:&lt;/p&gt;

&lt;h2 id=&quot;tapping-the-flowgraph&quot;&gt;Tapping the Flowgraph&lt;/h2&gt;

&lt;p&gt;We’ll save this frequency offset estimation using the RFtap Encapsulation block. Since PDU metadata is already passed between Wi-Fi blocks, all we need to do is connect the encapsulation block and a UDP output block:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/wifi/wifi_rftap.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Adding RFtap Encapsulation to Wi-Fi flowgraph&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The frequency offset can now be observed for each Wi-Fi packet in Wireshark:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rftap/rftap_wireshark_tree.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Adding RFtap Encapsulation to Wi-Fi flowgraph&lt;/div&gt;
&lt;/div&gt;

&lt;h2 id=&quot;detecting-mac-spoofing&quot;&gt;Detecting MAC Spoofing&lt;/h2&gt;

&lt;p&gt;The frequency offset can be used as a fingerprint for each Wi-Fi packet, differentiating it from other packets regardless of the Wi-Fi MAC address or packet content. We can show the raw frequency offset of each packet in real time:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ tshark -i lo -q -T fields -e wlan.ta -e rftap.freqofs
Capturing on 'Loopback'
00:a0:cc:23:af:4a	837.9016071558
3a:34:52:c4:69:b8	13188.2628193125
3a:34:52:c4:69:b8	15857.2173677385
3a:34:52:c4:69:b8	9895.83786576986
c8:60:00:ba:95:65	3073.38777929544
34:4d:ea:89:75:b2	-6725.89638270438
3a:34:52:c4:69:b8	10878.7475619465
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Or as a rudimentary plot, again in real-time:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ tshark -i lo -q -l -Y 'wlan.ta' -T fields -e wlan.ta -e rftap.freqofs | \
gawk '{printf(&quot;%s %*s\n&quot;,$1,($2+50000)/3000,&quot;*&quot;)}'

# scale: 1 text column is 3kHz

3a:34:52:c4:69:b8               *
3a:34:52:c4:69:b8               *
3a:34:52:c4:69:b8              *
00:a0:cc:23:af:4a         *
00:a0:cc:23:af:4a       *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8               *
3a:34:52:c4:69:b8               *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8               *
3a:34:52:c4:69:b8               *
34:4d:ea:89:75:b2    *
34:4d:ea:89:75:b2     *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8              *

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Notice that every device has a unique frequency offset identifying it, even at rest (no Doppler effect). If we change our test Wi-Fi device 34:4d:ea:89:75:b2 to a different MAC address (MAC Spoofing), it still retains its unique frequency offset characteristic:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;3a:34:52:c4:69:b8             *
3a:34:52:c4:69:b8             *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8              *
00:00:00:00:00:01      *
00:00:00:00:00:01     *
3a:34:52:c4:69:b8              *
3a:34:52:c4:69:b8               *
3a:34:52:c4:69:b8              *
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;

&lt;p&gt;In this post we have shown how to use RFtap to preserve RF metadata from GNU Radio, and how to use RF metadata such as Carrier Offset to uniquely identify devices regardless of the content of their packets. We’ve demonstrated the benefits RFtap can provide in bridging SDR platforms such as GNU radio and network analysis tools such as Wireshark.&lt;/p&gt;

&lt;p&gt;The modified Wi-Fi flowgraph is available in &lt;a href=&quot;https://github.com/rftap/gr-rftap/tree/master/examples&quot;&gt;gr-rftap/examples&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;future-study&quot;&gt;Future Study&lt;/h2&gt;

&lt;p&gt;This demonstration is using the frequency offset estimation from the &lt;strong&gt;Long Preamble&lt;/strong&gt; only. It should be possible to get a &lt;strong&gt;much better&lt;/strong&gt; frequency estimation by looking at the entire packet (not just the preamble). There is already a mechanism in frame_equalizer block to track the exact frequency from one symbol to the next. This would be useful to attain Doppler-level accuracies.&lt;/p&gt;

&lt;p&gt;It would be interesting to use the frequency offset estimation to measure the speed of vehicles (with on-board Wi-Fi) on the highway (going from +Doppler to -Doppler frequency as they pass the GNU Radio receiver).&lt;/p&gt;
</description>
        <pubDate>Thu, 01 Sep 2016 00:00:00 +0000</pubDate>
        <link>https://rftap.github.io/blog/2016/09/01/rftap-wifi.html</link>
        <guid isPermaLink="true">https://rftap.github.io/blog/2016/09/01/rftap-wifi.html</guid>
        
        
        <category>blog</category>
        
      </item>
    
      <item>
        <title>Tutorial: Using RFtap to Decode RDS</title>
        <description>&lt;p&gt;In this post we’ll demonstrate:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;how to use &lt;a href=&quot;/&quot;&gt;RFtap&lt;/a&gt; to connect a &lt;a href=&quot;http://gnuradio.org/&quot;&gt;GNU Radio&lt;/a&gt; flowgraph to Wireshark,&lt;/li&gt;
  &lt;li&gt;how to use Wireshark to easily dissect a new protocol, and&lt;/li&gt;
  &lt;li&gt;how to add metadata (such as the &lt;a href=&quot;https://en.wikipedia.org/wiki/Carrier_frequency&quot;&gt;carrier frequency&lt;/a&gt;) to each RFtap packet.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rds/rds_drawing.svg.png&quot; /&gt;
&lt;/div&gt;

&lt;h2 id=&quot;what-is-rftap&quot;&gt;What is RFtap?&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;/&quot;&gt;RFtap&lt;/a&gt; is a simple protocol designed to provide RF (Radio Frequency) metadata about packets, such as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Accurate signal and noise power&lt;/li&gt;
  &lt;li&gt;Accurate timing and phase information&lt;/li&gt;
  &lt;li&gt;Accurate &lt;a href=&quot;https://en.wikipedia.org/wiki/Carrier_frequency&quot;&gt;Carrier&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Doppler_effect&quot;&gt;Doppler&lt;/a&gt; frequencies of every packet, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can think of RFtap as the “glue” between GNU Radio and Wireshark, allowing access to RF metadata from &lt;a href=&quot;https://www.wireshark.org/&quot;&gt;Wireshark&lt;/a&gt; or Scapy. Read an &lt;a href=&quot;/&quot;&gt;Introduction on RFtap&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The RFtap protocol is designed to encapsulate any type of packet: Wi-Fi, Bluetooth, or packets from any proprietary protocol.&lt;/p&gt;

&lt;h2 id=&quot;radio-data-system-rds&quot;&gt;Radio Data System (RDS)&lt;/h2&gt;

&lt;p&gt;Radio Data System (RDS) is a digital sub-channel in commercial FM radio broadcasts. RDS standardizes several types of information transmitted, including time, station name, song name and alternate frequencies, read more about &lt;a href=&quot;https://en.wikipedia.org/wiki/Radio_Data_System&quot;&gt;RDS on Wikipedia&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rds/rds_display.jpg&quot; style=&quot;max-width:50%;&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;RDS data displayed on a car radio&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;We’ll start with the excellent GNU Radio FM/RDS receiver.
You’ll need to install &lt;a href=&quot;http://gnuradio.org/redmine/projects/gnuradio/wiki/InstallingGRFromSource&quot;&gt;GNU Radio from source&lt;/a&gt; (I followed &lt;a href=&quot;https://github.com/gnuradio/pybombs/blob/master/README.md&quot;&gt;these instructions&lt;/a&gt;), install GNU Radio’s &lt;a href=&quot;https://github.com/bastibl/gr-rds&quot;&gt;RDS receiver (gr-rds)&lt;/a&gt; and &lt;a href=&quot;https://github.com/rftap/gr-rftap&quot;&gt;gr-rftap&lt;/a&gt;. You’ll also need some SDR hardware, such as the &lt;a href=&quot;http://www.rtl-sdr.com/about-rtl-sdr/&quot;&gt;RTL-SDR&lt;/a&gt; receiver.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://archive.fosdem.org/2015/schedule/event/sdr_rds_tmc/&quot;&gt;Presentation about GNU Radio RDS receiver (video and slides)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Running the rds_rx.grc flowgraph demonstrates all the stages of receiving a stereo FM+RDS signal, each tab showing a different view of the demodulation process. Verify that you can tune to a local FM station with RDS data:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ gnuradio-companion gr-rds/apps/rds_rx.grc
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rds/rds_gui.gif&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;rds_rx.grc GUI, showing the RDS constellation tab&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The RDS decoding is done at the bottom-right part of the flowgraph. It consists of:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The RDS decoder, receiving raw bits and sending completed RDS frames&lt;/li&gt;
  &lt;li&gt;The RDS parser, receiving RDS frames and sending station/song names to the GUI&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;div&gt;
&lt;img src=&quot;/assets/rds/rds_rx.grc.png&quot; style=&quot;max-width:32%;&quot; /&gt;
&lt;img src=&quot;/assets/rds/rds_flowgraph_zoom.png&quot; style=&quot;max-width:66%;&quot; /&gt;
&lt;/div&gt;
&lt;div class=&quot;thecap&quot;&gt;1. The entire rds_rx.grc flowgraph; 2. Zoom-in of the bottom-right of the flowgraph, showing the RDS decoding section&lt;/div&gt;
&lt;/div&gt;

&lt;h2 id=&quot;tapping-the-flowgraph&quot;&gt;Tapping the Flowgraph&lt;/h2&gt;

&lt;p&gt;To send RDS frames to Wireshark, we will use the &lt;em&gt;RFtap Encapsulation&lt;/em&gt; block to tap RDS frames as they’re exiting the &lt;em&gt;RDS decoder&lt;/em&gt;. The RFtap block can be attached to any PDU message ports (the gray-colored ports in the flowgraph). It wraps the incoming PDU messages with an appropriate RFtap header. The packet can then be streamed to a pcap file, or to a local UDP port for Wireshark.&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rds/rds_rftap_block.gif&quot; /&gt;
&lt;/div&gt;

&lt;h3 id=&quot;sidenote-data-link-type-dlt-or-dissector-name&quot;&gt;Sidenote: Data Link Type (DLT) or Dissector Name?&lt;/h3&gt;

&lt;p&gt;In order to be able to correctly interpret the (RDS) data packets, Wireshark needs to know the type of packet (Wi-Fi, Bluetooth, RDS, etc). There are several ways to do that. If the packet is of one of the standard types appearing in the &lt;a href=&quot;http://www.tcpdump.org/linktypes.html&quot;&gt;Data Link Type (DLT) list&lt;/a&gt;, you can just specify the DLT value in the RFtap block itself, or in the PDU metadata as “dlt” field. For example, Wi-Fi packets would have a DLT of 105.&lt;/p&gt;

&lt;p&gt;Alternatively, if the packet type isn’t listed in the &lt;a href=&quot;http://www.tcpdump.org/linktypes.html&quot;&gt;DLT list&lt;/a&gt;, you can specify a Wireshark &lt;em&gt;dissector name&lt;/em&gt; to be used for dissecting the packets. This can be specified in the RFtap block itself (option: Custom Dissector), or as part the incoming PDU metadata, as “dissector” field. We will use the “Custom Dissector” option, and specify the dissector name as &lt;code class=&quot;highlighter-rouge&quot;&gt;rds&lt;/code&gt; (Wireshark dissector names are typically all-lowercase).&lt;/p&gt;

&lt;h2 id=&quot;receiving-the-packets-in-wireshark&quot;&gt;Receiving the Packets in Wireshark&lt;/h2&gt;

&lt;p&gt;Upon running the modified flowgraph (and tuning to an RDS-capable FM station), RFtap packets should start flowing to localhost interface (127.0.0.1). Install &lt;a href=&quot;https://www.wireshark.org/&quot;&gt;Wireshark&lt;/a&gt; version 2.3 or higher. We’re ready to fire up wireshark:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ wireshark -v
Wireshark 2.3.0

$ wireshark -i lo -k
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Success! We can see the packets arriving to wireshark, each RDS packet is encapsulated in a RFtap packet. Since wireshark doesn’t have a &lt;code class=&quot;highlighter-rouge&quot;&gt;rds&lt;/code&gt; dissector yet, all RDS packets are labeled as plain “data” frames embedded in a RFtap frame:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rds/wireshark_no_plugin.png&quot; /&gt;
&lt;/div&gt;

&lt;h2 id=&quot;adding-a-dissector&quot;&gt;Adding a Dissector&lt;/h2&gt;

&lt;p&gt;Next we’ll add a RDS dissector to wireshark. There are two ways to write a dissector: c and lua. For simplicity we’ll choose lua. Our &lt;code class=&quot;highlighter-rouge&quot;&gt;rds&lt;/code&gt; dissector will decode the station identification (PI), the station name fragments and the alternate frequencies where the station can be received:&lt;/p&gt;

&lt;div class=&quot;language-lua highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;-- lua wireshark dissector for RDS (Radio Data System)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- put this file in: ~/.config/wireshark/plugins/rds.lua&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- or in (old location): ~/.wireshark/plugins/rds.lua&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- RDS Standard: http://www.nrscstandards.org/sg/nrsc-4-b.pdf&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;rds_proto&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Proto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;rds&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Radio Data System (RDS)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_pi&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ProtoField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;rds.pi&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;PI code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;HEX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Program Identification (PI) code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_group_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ProtoField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;rds.group&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Group type code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DEC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0xf000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Group type code (0-15)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_version_code&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ProtoField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;rds.version&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Version code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DEC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x0800&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Version code (A=0, B=1)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_af1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ProtoField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;rds.af1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;AF1 code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DEC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;First Alternate Frequency (AF) code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_af2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ProtoField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;rds.af2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;AF2 code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DEC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Second Alternate Frequency (AF) code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_altfreq&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ProtoField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;rds.altfreq&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Alternate Frequency&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Alternate Frequency for this station&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;rds_proto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fields&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f_pi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_group_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_version_code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_af1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_af2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f_altfreq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;rds_proto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;dissector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pinfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pinfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cols&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;protocol&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;RDS&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pinfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cols&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tree&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rds_proto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;-- Program Identification (PI), aka station ID&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pi_code&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;            &lt;span class=&quot;c1&quot;&gt;-- fetch value&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f_pi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;                      &lt;span class=&quot;c1&quot;&gt;-- put in tree&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;-- RDS frame type and version&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;group_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bitfield&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;-- fetch value&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f_group_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;              &lt;span class=&quot;c1&quot;&gt;-- put in tree&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;version_code&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bitfield&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;-- etc...&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f_version_code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;-- Wireshark INFO column&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;string.format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'PI=%04X GRP=%u%s'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pi_code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;group_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;version_code&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'A'&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'B'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pinfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cols&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;-- Add station name to INFO column&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;group_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name_fragment&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pinfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cols&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;' &amp;lt;'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;..&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name_fragment&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;..&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'&amp;gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;-- helper function for decoding Alternate Frequency code&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;decode_altfreq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;af&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;af&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;af&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;204&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;freq_Hz&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;87&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;6e6&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1e6&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;af&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;-- field value (Hz)&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;freq_MHz&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;freq_Hz&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1e6&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;01&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;-- for display (MHz)&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;-- add Alternate Frequency field to dissection tree&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;string.format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Alternate Frequency: %.1f MHz'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;freq_MHz&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f_altfreq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;freq_Hz&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;-- Add Alternate Frequency to INFO column&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;pinfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cols&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;string.format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;' AF=%.1fMHz'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;freq_MHz&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;-- Decode Alternate Frequency fields&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;group_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;version_code&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f_af1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;-- rds.af1 (raw code)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;decode_altfreq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;             &lt;span class=&quot;c1&quot;&gt;-- rds.altfreq (frequency in Hertz)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f_af2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tvb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;-- rds.af2 (raw code)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;decode_altfreq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;             &lt;span class=&quot;c1&quot;&gt;-- rds.altfreq (frequency in Hertz)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Result:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rds/wireshark_rds_plugin.png&quot; /&gt;
&lt;/div&gt;

&lt;p&gt;Notice that we can also access the new RDS fields programatically, for example we can type this in Wireshark display filter: &lt;code class=&quot;highlighter-rouge&quot;&gt;rds.altfreq &amp;gt; 100e6&lt;/code&gt; to see all the packets with alternative frequency higher than 100 MHz.&lt;/p&gt;

&lt;h2 id=&quot;adding-rf-metadata&quot;&gt;Adding RF metadata&lt;/h2&gt;

&lt;p&gt;Now that we have the basic infrastructure in place, we can start adding interesting RF metadata to the packets. For demonstration, we’ll add the &lt;a href=&quot;https://en.wikipedia.org/wiki/Carrier_frequency&quot;&gt;Carrier Frequency&lt;/a&gt; metadata to all RFtap packets.&lt;/p&gt;

&lt;p&gt;Adding the carrier frequency is easy: there is already a &lt;code class=&quot;highlighter-rouge&quot;&gt;freq&lt;/code&gt; variable in the flowgraph, representing the &lt;em&gt;nominal carrier frequency&lt;/em&gt; of the radio station. We’ll add the string key &lt;code class=&quot;highlighter-rouge&quot;&gt;&quot;nomfreq&quot;&lt;/code&gt; and its respective floating-point value to the PDU using the &lt;code class=&quot;highlighter-rouge&quot;&gt;PDU set&lt;/code&gt; block, just before the &lt;em&gt;RFtap Encapsulation&lt;/em&gt; block:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;div&gt;
&lt;img src=&quot;/assets/rds/pdu_set_dialog.png&quot; style=&quot;max-width:49%;&quot; /&gt;
&lt;img src=&quot;/assets/rds/pdu_set.png&quot; style=&quot;max-width:49%;&quot; /&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;h3 id=&quot;sidenote-what-is-a-pdu&quot;&gt;Sidenote: What is a PDU?&lt;/h3&gt;

&lt;p&gt;GNU Radio terminology can be overwhelming at times: there are streams, stream tags, message ports, asynchronous message passing interface, polymorphic types (PMT), messages, protocol data units (PDU)…&lt;/p&gt;

&lt;p&gt;A PDU in GNU Radio is a special kind of message used to store raw packet data and its associated metadata in a convenient package. It consists of a vector of bytes (the raw data of the “packet”), paired with a dictionary containing arbitrary metadata about the packet:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;PDU:
    metadata:
        key1: value1
        key2: value2
        key3: value3, etc...
    data:
        68 65 6c 6c 6f 20 77 6f 72 6c 64 ... (raw data bytes)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The RFtap Encapsulation block looks for known keys in the received PDU metadata, such as &lt;code class=&quot;highlighter-rouge&quot;&gt;freq&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;freqofs&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;snr&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;dlt&lt;/code&gt;, and encodes these keys (and values) into an RFtap header, which is then prefixed to the raw data bytes, thus creating a RFtap packet containing user’s encapsulated data packet. These fields can then be accessed in Wireshark for each individual packet. The key names in GNU Radio are identical to the key names used in the Wireshark RFtap dissector (&lt;code class=&quot;highlighter-rouge&quot;&gt;rftap.freq&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;rftap.freqofs&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;rftap.dlt&lt;/code&gt;, etc).&lt;/p&gt;

&lt;p&gt;END OF SIDENOTE&lt;/p&gt;

&lt;p&gt;That’s all! We can now see the same RDS packets in Wireshark, with each packet having a carrier frequency property accessible via &lt;code class=&quot;highlighter-rouge&quot;&gt;rftap.nomfreq&lt;/code&gt;. Notice that when the radio frequency is changed in GNU Radio, the RFtap carrier frequency is updated in real-time in Wireshark.&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rds/wireshark_rftap_nomfreq.png&quot; /&gt;
&lt;/div&gt;

&lt;p&gt;We can now save all RDS packets with their associated RF metadata in a pcap file:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ tshark -i lo -w allmypackets.pcap
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Run analytics, such as collecting all station IDs (rds.pi, aka “Program Identification”):&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ tshark -i lo -q -T fields -e rds.pi
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Retrieve frequencies and alternate frequencies used:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ tshark -i lo -q -T fields -e rftap.nomfreq -e rds.altfreq
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Run analytics on all RDS and TMC messages received, etc.&lt;/p&gt;

&lt;h2 id=&quot;conclusions&quot;&gt;Conclusions&lt;/h2&gt;

&lt;p&gt;In this post we’ve shown the basic use of the RFtap protocol, including how to generate and process RFtap packets and how to add support to a new protocol in Wireshark. We’ve demonstrated the benefits RFtap can provide in bridging SDR platforms such as GNU radio and network analysis tools such as Wireshark.&lt;/p&gt;

&lt;p&gt;The modified RDS flowgraph and lua dissector are available in &lt;a href=&quot;https://github.com/rftap/gr-rftap/tree/master/examples&quot;&gt;gr-rftap/examples&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Ready for more? Read &lt;a href=&quot;/blog/2016/09/01/rftap-wifi.html&quot;&gt;Using RFtap to Detect Wi-Fi MAC Spoofing&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.nrscstandards.org/sg/nrsc-4-b.pdf&quot;&gt;RDS Standard (PDF)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Radio_Data_System&quot;&gt;RDS on Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sat, 27 Aug 2016 00:00:00 +0000</pubDate>
        <link>https://rftap.github.io/blog/2016/08/27/decoding-rds-with-rftap.html</link>
        <guid isPermaLink="true">https://rftap.github.io/blog/2016/08/27/decoding-rds-with-rftap.html</guid>
        
        
        <category>blog</category>
        
      </item>
    
      <item>
        <title>What is RFtap?</title>
        <description>&lt;p&gt;RFtap is a simple protocol designed to provide Radio Frequency (RF) metadata about packets, such as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Accurate signal and noise power&lt;/li&gt;
  &lt;li&gt;Accurate timing and phase information&lt;/li&gt;
  &lt;li&gt;Accurate &lt;a href=&quot;https://en.wikipedia.org/wiki/Carrier_frequency&quot;&gt;Carrier&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Doppler_effect&quot;&gt;Doppler&lt;/a&gt; frequencies of every packet, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;RFtap bridges the gap between &lt;a href=&quot;https://en.wikipedia.org/wiki/Software-defined_radio&quot;&gt;Software Defined Radio (SDR)&lt;/a&gt; platforms (such as &lt;a href=&quot;http://gnuradio.org/&quot;&gt;GNU Radio&lt;/a&gt;, &lt;a href=&quot;http://www.pothosware.com/&quot;&gt;Pothos&lt;/a&gt;, &lt;a href=&quot;http://liquidsdr.org/&quot;&gt;liquidsdr&lt;/a&gt;, &lt;a href=&quot;http://luaradio.io/&quot;&gt;LuaRadio&lt;/a&gt;) and conventional network monitoring and packet analysis tools (such as &lt;a href=&quot;https://www.wireshark.org/&quot;&gt;Wireshark&lt;/a&gt;, &lt;a href=&quot;https://www.wireshark.org/docs/man-pages/tshark.html&quot;&gt;TShark&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Tcpdump&quot;&gt;tcpdump&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Scapy&quot;&gt;Scapy&lt;/a&gt;), allowing the access and manipulation of novel RF metadata from packets while remaining within the comfortable and mature environment of conventional networking tools.&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rftap/rftap_cloud.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;RFtap bridging the gap between SDR platforms and networking tools&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The RFtap protocol is inspired by the &lt;a href=&quot;http://www.radiotap.org/&quot;&gt;radiotap protocol&lt;/a&gt;; however it is designed to encapsulate any type of packet (not just Wi-Fi), and preserve the exact RF attributes of each packet without loss of accuracy.&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rftap/rftap_wireshark_tree.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Sample RFtap attributes in Wireshark&lt;/div&gt;
&lt;/div&gt;

&lt;h2 id=&quot;specifications&quot;&gt;Specifications&lt;/h2&gt;

&lt;p&gt;Read about all the RFtap header, the various RFtap tags and field names in the &lt;a href=&quot;/specifications/&quot;&gt;RFtap specifications&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;using-rftap-as-a-consumer&quot;&gt;Using RFtap (as a Consumer)&lt;/h2&gt;

&lt;p&gt;The most natural way to process RFtap packets is through standard networking tools and file formats such as Wireshark, TShark, pcap files, editcap, mergecap, etc. Use Wireshark/TShark built-in RFtap dissector for filtering and analytics. Some examples:&lt;/p&gt;

&lt;p&gt;Filter packets above a &lt;a href=&quot;https://en.wikipedia.org/wiki/Signal-to-noise_ratio&quot;&gt;Signal-to-Noise ratio&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rftap/rftap_wireshark_filter.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Filtering packets in Wireshark based on RF metadata&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Print the transmitter &lt;a href=&quot;https://en.wikipedia.org/wiki/MAC_address&quot;&gt;MAC address&lt;/a&gt; and the received &lt;a href=&quot;https://en.wikipedia.org/wiki/Doppler_effect&quot;&gt;Doppler frequency&lt;/a&gt; (in Hertz) of each Wi-Fi packet:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ tshark -i lo -q -T fields -e wlan.ta -e rftap.freqofs
Capturing on 'Loopback'
00:a0:cc:23:af:4a	837.9016071558
3a:34:52:c4:69:b8	13188.2628193125
3a:34:52:c4:69:b8	15857.2173677385
3a:34:52:c4:69:b8	9895.83786576986
c8:60:00:ba:95:65	3073.38777929544
34:4d:ea:89:75:b2	-6725.89638270438
3a:34:52:c4:69:b8	10878.7475619465
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;using-rftap-as-a-producer&quot;&gt;Using RFtap (as a Producer)&lt;/h2&gt;

&lt;p&gt;RFtap packets can be produced using GNU Radio &lt;strong&gt;RFtap encapsulation&lt;/strong&gt; block. This block can be connected to any GNU Radio block that produces PDU messages (the grey-colored port in GNU Radio blocks). The encapsulation block automatically extracts common metadata fields from the PDU, encoding them into the appropriate RFtap fields.&lt;/p&gt;

&lt;p&gt;See &lt;a href=&quot;/blog/2016/08/27/decoding-rds-with-rftap.html&quot;&gt;Tutorial: encapsulating RDS packets with RFtap&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;imgcap&quot;&gt;
&lt;img src=&quot;/assets/rftap/rftap_rds_encap.png&quot; /&gt;
&lt;div class=&quot;thecap&quot;&gt;Encapsulating RDS data into RFtap packets and sending them via UDP to Wireshark&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Alternatively, RFtap packets can be easily created in any language, because of the simple structure:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rftap_hdr&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;le32&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;magic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// signature: &quot;RFta&quot;
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;le16&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;len32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// length
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;le16&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;flags&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// bitfield indicating presence of fields
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;le32&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[];&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// the rftap fields
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__attribute__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;packed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;For example, to encode Signal-to-Noise (SNR) metadata for an arbitrary packet:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;my_packet&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// RFtap header + optional fields
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;le32&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;magic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;le16&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;len32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;le16&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;flags&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;snr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;packet_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;123&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// packet data
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__attribute__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;packed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;prepare_packet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;my_packet&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pkt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pkt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;magic&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x61744652UL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// fixed signature (&quot;RFta&quot; in hex)
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;pkt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;len32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// we use 3x 32-bit words: magic, len+flags, snr
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;pkt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flags&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x0080&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// &quot;SNR&quot; field is present (bit #7 is ON)
&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pkt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;snr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// fill your Signal-to-Noise, in dB (decibels)
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;pkt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// fill your packet data here.
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;// Done! Packet is ready to be sent, or saved to pcap file...
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;downloads&quot;&gt;Downloads&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.wireshark.org/&quot;&gt;Wireshark&lt;/a&gt; - built-in support for RFtap in version 2.3 and above&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rftap/gr-rftap&quot;&gt;gr-rftap - RFtap Encapsulation block for GNU Radio&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.pothosware.com/&quot;&gt;Pothos&lt;/a&gt; - built-in support for RFtap in latest version&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 26 Aug 2016 00:00:00 +0000</pubDate>
        <link>https://rftap.github.io/blog/2016/08/26/rftap.html</link>
        <guid isPermaLink="true">https://rftap.github.io/blog/2016/08/26/rftap.html</guid>
        
        
        <category>blog</category>
        
      </item>
    
  </channel>
</rss>
