RadioTap Archive on lore.kernel.org
 help / color / Atom feed
* A modified, and maybe final, proposal for an S1G header for RadioTap
@ 2019-04-14 15:57 Richard Sharpe
  0 siblings, 0 replies; only message in thread
From: Richard Sharpe @ 2019-04-14 15:57 UTC (permalink / raw)
  To: radiotap-sUITvd46vNxg9hUCZPvPmw, Ray Wang, Aaron Lee, Tasheng Lin

[-- Attachment #1: Type: text/plain, Size: 3385 bytes --]

Hi folks,

Here is an updated proposal for this header.

It has undergone some modifications.

I include the patch to the radiotap git repo as well as a small C
program for generating such headers.

I have moved to using TLVs and have integrated Johannes' code for
handling Radiotap RLVs into Wireshark 2.6.2 and used my test program
to test the code.

The test code only generates three frames so far, but it could be
modified to provide broarder coverage.

I suggest that people making Radiotap proposals in the future should
also include code for generating such headers as it is pretty easy to
do so and makes it easier for people writing parsers.

We want to move forward with this and I have code now that dissects it
in Wireshark. Of course, that code is easy to change as well.

Here are the changes for the Channel field. Add three seemingly unused values:

| 0x0002 | S1G 700MHz spectrum channel |
| 0x0004 | S1G 800MHz spectrum channel |
| 0x0008 | S1G 900MHz spectrum channel |

Here is the new S1G field. It uses TLV Type value 32.

Note, we have also explicitly decided to place the Null Data Packet
(NDP) info into the S1G header. This reduces the amount of change
needed in dissectors but it does mean that the zero_length_ppdu
infrastructure that is already in Wireshark for example.

TLV Type Number
: 32

Structure
: u16 known, u16 data1, u16 data2, u8 ndp_type, u8[5] ndp_data;

Required Alignment
: 4

Unit(s)
: none

The presence of this field indicates the frame was capture using an S1G phy.

This field contains data to allow correct handling by programs like
Wireshark etc.

Is NDP indicates that this is an NDP frame, however, the content might
not be known.

## known

| **`0x0001`** | S1G PPDU Format known |
| **`0x0002`** | Response indication known |
| **`0x0004`** | Guard interval known |
| **`0x0008`** | NSS known |
| **`0x0010`** | Bandwidth known |
| **`0x0020`** | MCS known |
| **`0x0040`** | Color known |
| **`0x0080`** | Is NDP, which means no packet data follows this header! |
| **`0x0100`** | NDP content known |
| **`0xFE00`** | Reserved |

## data1

| **`0x0003`** | S1G PPDU Format: 0=S1G_1M, 1=S1G_SHORT, 2=S1G_LONG |
| **`0x000C`** | Response indication: 0=NO_RESPONSE, 1=NDP_RESPONSE,
2=NORMAL_RESPONSE, 3=LONG_RESPPNSE |
| **`0x0010`** | Reserved |
| **`0x0020`** | Guard interval: 0=Long GI, 1=Short GI |
| **`0x00C0`** | Number spatial streams: 0=1 Spatial stream, 1=2, ..
3=4 Spatial streams |
| **`0x0700`** | Bandwidth: 0=1MHz, 1=2MHz, 2=4MHz, 3=8MHz, 4=16MHz,
5-15 reserved |
| **`0x0800`** | Reserved |
| **`0xF000`** | MCS (MCS rate index, 0-10, 11-15 reserved) |

## data2

| **`0x0007`** | Color: 0-7 |
| **`0xFFF8`** | Reserved |

## ndp_type

This value is only defined if ndp_known is true.

| **ndp_type value** | **Meaning** |
| 0x00 | NDP Control frame |
| 0x01 | NDP Management Frame |
| 0x02-0xFF | Reserved |

## ndp_data

This value is only defined if ndp_known is true. The bytes are as
defined in IEEE802.11ah, Section 9.9, except that ndp_data[4] is
defined as:

| **`0x3F`** | used and unused bits depending on the BW field and type |
| **`0xC0`** | Bandwidth: 0 = 1Mhz, 1 = 2MHz, 2-3 Reserved |

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)(传说杜康是酒的发明者)

[-- Attachment #2: pkt-gen.c --]
[-- Type: text/plain, Size: 3432 bytes --]

/*
 * A generic packet generator application.
 *
 * Copyright Richard Sharpe, 2019.
 *
 * You are welcome to use, modify, otherwise, this code.
 *
 * You will need libpcap installed.
 *
 * Create a Makefile with this:
 * 
 * all:
 *	cc -g -o pkt-gen pkt-gen.c -I . -lpcap
 *
 */

#include <errno.h>
#include <pcap/pcap.h>
#include <stdlib.h>
#include <string.h>

struct s1g_radiotap_hdr {
	uint16_t type;
	uint16_t len;
	uint16_t known;
	uint16_t data1;
	uint16_t data2;
	uint8_t ndp_type;
	uint8_t ndp_data[5];
} __attribute__((packed));

struct radiotap_hdr {
	uint8_t vers;
	uint8_t pad;
	uint16_t len;
	uint32_t presence_flags;
	uint32_t MAC_timestamp[2];
	uint8_t flags;
	uint8_t data_rate;
	uint16_t pad2;
	struct s1g_radiotap_hdr s1g_hdr;
} __attribute__((packed));

struct complete_pkt {
	struct radiotap_hdr radiotap;
	uint8_t pkt_data[26];
} __attribute__((packed));

uint8_t pkt_data[26] = { 0x1c, 0x0b, 0x00, 0x00, 0x02, 0x00, 0xeb, 0x4b,
			 0x02, 0x8b, 0x12, 0x52, 0xa7, 0x6b, 0x00, 0x62,
			 0x9c, 0x6b, 0x64, 0x4e, 0x35, 0xae, 0x05, 0x02,
			 0x00, 0x02 };

int main(int argc, char *argv[])
{
	int err = -1;
	pcap_t *pd = NULL;
	void *ctx = NULL;
	struct pcap_pkthdr hdr;
	struct timeval ts;
	pcap_dumper_t *dumper = NULL;
	struct complete_pkt pkt;

	if (argc < 2) {
		printf("Usage: %s <pcap-file-name>\n", argv[0]);
		return 1;
	}

	pd = pcap_open_dead(DLT_IEEE802_11_RADIO, 65535);
	if (pd == NULL) {
		fprintf(stderr, "Unable to open pcap device: %s\n",
			strerror(errno));
		return -1;
	}

	dumper = pcap_dump_open(pd, argv[1]);
        if (dumper == NULL) {
		fprintf(stderr, "Unable to create dump file %s: %s\n",
			argv[1], pcap_geterr(pd));
		goto close_pd;
	}

	/*
	 * Now create the comlete packet.
	 */
	pkt.radiotap.vers = 0;
	pkt.radiotap.pad = 0;
	pkt.radiotap.len = sizeof(struct radiotap_hdr);
	pkt.radiotap.presence_flags = 0x10000007;
	pkt.radiotap.MAC_timestamp[0] = 0x17860500;
	pkt.radiotap.MAC_timestamp[1] = 0x22ac9b1a;
	pkt.radiotap.flags = 0;
	pkt.radiotap.data_rate = 0x0c;
	pkt.radiotap.pad2 = 0xffff;
	pkt.radiotap.s1g_hdr.type = 32;
	pkt.radiotap.s1g_hdr.len = 12;
	pkt.radiotap.s1g_hdr.known = 0x0005; /* S1G PPDU forman and GU known */
	pkt.radiotap.s1g_hdr.data1 = 0x0020;
	pkt.radiotap.s1g_hdr.data2 = 0x0;
	pkt.radiotap.s1g_hdr.ndp_type = 0;
	pkt.radiotap.s1g_hdr.ndp_data[0] = 0;
	pkt.radiotap.s1g_hdr.ndp_data[1] = 0;
	pkt.radiotap.s1g_hdr.ndp_data[2] = 0;
	pkt.radiotap.s1g_hdr.ndp_data[3] = 0;
	pkt.radiotap.s1g_hdr.ndp_data[4] = 0;
	memcpy(pkt.pkt_data, pkt_data, sizeof(pkt.pkt_data));

	gettimeofday(&ts, NULL);
	hdr.ts = ts;
	hdr.caplen = sizeof(struct complete_pkt);
	hdr.len = sizeof(struct complete_pkt);

	pcap_dump((u_char *)dumper, &hdr, (u_char *)&pkt);

	/* Dump another with different values */
	pkt.radiotap.s1g_hdr.known = 0x0035;
	pkt.radiotap.s1g_hdr.data1 = 0xB421;

	pcap_dump((u_char *)dumper, &hdr, (u_char *)&pkt);

	pkt.radiotap.s1g_hdr.known = 0x0180;
	pkt.radiotap.s1g_hdr.data1 = 0;
	pkt.radiotap.s1g_hdr.ndp_type = 0;
	pkt.radiotap.s1g_hdr.ndp_data[0] = 0xe2;
	pkt.radiotap.s1g_hdr.ndp_data[1] = 0xd9;
	pkt.radiotap.s1g_hdr.ndp_data[2] = 0x03;
	pkt.radiotap.s1g_hdr.ndp_data[3] = 0x00;
	pkt.radiotap.s1g_hdr.ndp_data[4] = 0x80;

	hdr.caplen = sizeof(struct radiotap_hdr);
	hdr.len = sizeof(struct radiotap_hdr);

	pcap_dump((u_char *)dumper, &hdr, (u_char *)&pkt);

close_dumper:
	pcap_dump_close(dumper);
close_pd:
	pcap_close(pd);
	return err;
}

[-- Attachment #3: 0001-Add-an-S1G-field-as-well-as-add-some-Channel-values.patch --]
[-- Type: application/octet-stream, Size: 3643 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-14 15:57 A modified, and maybe final, proposal for an S1G header for RadioTap Richard Sharpe

RadioTap Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/radiotap/0 radiotap/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 radiotap radiotap/ https://lore.kernel.org/radiotap \
		radiotap@radiotap.org
	public-inbox-index radiotap

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.netbsd.radiotap


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git