Skip to contentSkip to conversation

timestamp field

RFA Johannes Berg 2 participants 7 messages Dec 4, 2015 – Jun 2, 2016 4 messages not in the archive Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

Hi all,

This is a request for adoption of the timestamp field as documented on
http://www.radiotap.org/suggested-fields/timestamp

I've attached the necessary wireshark patch, as well as a patch to the Linux hardware simulator (mac80211_hwsim) to generate a dummy field for experimentation.

I'd previously sent an RFC, but I didn't receive that much feedback so I've just tried to be fairly generic here.

johannes

epan/dissectors/packet-ieee80211-radiotap-defs.h +17 -2
index 25dd231bd7b9..6ea0ff23af14 100644
@@ -207,6 +207,7 @@ enum ieee80211_radiotap_type {
 	IEEE80211_RADIOTAP_MCS = 19,
 	IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
 	IEEE80211_RADIOTAP_VHT = 21,
+	IEEE80211_RADIOTAP_TIMESTAMP = 22,
 
 	/* valid in every it_present bitmap, even vendor namespaces */
 	IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
@@ -215,8 +216,8 @@ enum ieee80211_radiotap_type {
 };
 
 /* not (yet) defined Radiotap present flag */
-/* Bit 22 to 28 are not defined (in binary : 0001 1111 1100 0000 0000 0000 0000 0000 */
-#define IEEE80211_RADIOTAP_NOTDEFINED 0x1FC00000
+/* Bit 23 to 28 are not defined (in binary : 0001 1111 1000 0000 0000 0000 0000 0000 */
+#define IEEE80211_RADIOTAP_NOTDEFINED 0x1F800000
 
 /* Channel flags. */
 /* 0x00000001 through 0x00000008 undefined (reserved?) */
@@ -362,5 +363,19 @@ enum ieee80211_radiotap_type {
 #define IEEE80211_RADIOTAP_VHT_BW_20UUL		24
 #define IEEE80211_RADIOTAP_VHT_BW_20UUU		25
 
+/* for IEEE80211_RADIOTAP_TIMESTAMP */
+#define IEEE80211_RADIOTAP_TS_UNIT_MASK		0x0F
+#define IEEE80211_RADIOTAP_TS_UNIT_MSEC		0x00
+#define IEEE80211_RADIOTAP_TS_UNIT_USEC		0x01
+#define IEEE80211_RADIOTAP_TS_UNIT_NSEC		0x02
+#define IEEE80211_RADIOTAP_TS_SPOS_MASK		0xF0
+#define IEEE80211_RADIOTAP_TS_SPOS_SHIFT	4
+#define IEEE80211_RADIOTAP_TS_SPOS_MPDU		0x0
+#define IEEE80211_RADIOTAP_TS_SPOS_ACQ		0x1
+#define IEEE80211_RADIOTAP_TS_SPOS_EOF		0x2
+#define IEEE80211_RADIOTAP_TS_SPOS_UNDEF	0xF
+
+#define IEEE80211_RADIOTAP_TS_FLG_32BIT		0x01
+#define IEEE80211_RADIOTAP_TS_FLG_ACCURACY	0x02
 
 #endif				/* IEEE80211_RADIOTAP_H */
epan/dissectors/packet-ieee80211-radiotap-iter.c +2 -1
index 799a78ecdc2d..1d1053d3dd8d 100644
@@ -62,7 +62,8 @@ static const struct radiotap_align_size rtap_namespace_sizes[] = {
 	/* [IEEE80211_RADIOTAP_XCHANNEL] = 18 */		{ 0, 0 }, /* Unofficial, used by FreeBSD */
 	/* [IEEE80211_RADIOTAP_MCS] = 19 */			{ 1, 3 },
 	/* [IEEE80211_RADIOTAP_AMPDU_STATUS] = 20 */		{ 4, 8 },
-	/* [IEEE80211_RADIOTAP_VHT] = 21 */			{ 2, 12 }
+	/* [IEEE80211_RADIOTAP_VHT] = 21 */			{ 2, 12 },
+	/* [IEEE80211_RADIOTAP_TIMESTAMP] = 22 */		{ 8, 12 }
 
 	/*
 	 * add more here as they are defined in
epan/dissectors/packet-ieee80211-radiotap.c +107 -1

162 lines not on this page · raw message

drivers/net/wireless/mac80211_hwsim.c +12 -0
index c32889a1e39c..6b1082797861 100644
@@ -551,6 +551,13 @@ struct hwsim_radiotap_hdr {
 	u8 rt_rate;
 	__le16 rt_channel;
 	__le16 rt_chbitmask;
+	__le16 reserved;
+	struct {
+		__le64 ts;
+		__le16 accuracy;
+		u8 unit_pos;
+		u8 flags;
+	} ts;
 } __packed;
 
 struct hwsim_radiotap_ack_hdr {
@@ -831,6 +838,7 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
 	hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
 					  (1 << IEEE80211_RADIOTAP_RATE) |
 					  (1 << IEEE80211_RADIOTAP_TSFT) |
+					  BIT(22) |
 					  (1 << IEEE80211_RADIOTAP_CHANNEL));
 	hdr->rt_tsft = __mac80211_hwsim_get_tsf(data);
 	hdr->rt_flags = 0;
@@ -842,6 +850,10 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
 	else
 		flags |= IEEE80211_CHAN_CCK;
 	hdr->rt_chbitmask = cpu_to_le16(flags);
+	hdr->ts.ts = cpu_to_le64(ktime_get_boot_ns());
+	hdr->ts.accuracy = 0;
+	hdr->ts.unit_pos = 0x22;
+	hdr->ts.flags = 0x02;
 
 	skb->dev = hwsim_mon;
 	skb_set_mac_header(skb, 0);

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Repost, since a few weeks have passed.

Any comments?

Simon, would this help you at all?

johannes

Quoted 13 lines · Johannes Berg

Hi all,

This is a request for adoption of the timestamp field as documented on
http://www.radiotap.org/suggested-fields/timestamp

I've attached the necessary wireshark patch, as well as a patch to the Linux hardware simulator (mac80211_hwsim) to generate a dummy field for experimentation.

I'd previously sent an RFC, but I didn't receive that much feedback so I've just tried to be fairly generic here.

johannes

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

I like this proposal. One aspect that is missing is to define the meaning of the timestamp with aggregates. Should this field be present for all subframes, or just the first/last? Should the timestamp refer to the subframes, or the whole A-MPDU? Currently what I see in different generators is the MACTIME field is either the same for all subframes, and always refers to the whole A-MPDU - not individual subframes. For one generator the MACTIME was 0 for subframes after the 1st. Sometimes the signal strength is only present on the last subframe.

Macbooks generate radtiotap files with incorrect rate fields for subframes with CRC errors.

If you look in the wireshark gerrit, you will see I have been porting my timeline viewer code over to the current devel mainline.

Simon

Quoted 22 lines · Johannes Berg

Repost, since a few weeks have passed.

Any comments?

Simon, would this help you at all?

johannes

Quoted 13 lines · Johannes Berg

Hi all,

This is a request for adoption of the timestamp field as documented on
http://www.radiotap.org/suggested-fields/timestamp

I've attached the necessary wireshark patch, as well as a patch to the Linux hardware simulator (mac80211_hwsim) to generate a dummy field for experimentation.

I'd previously sent an RFC, but I didn't receive that much feedback so I've just tried to be fairly generic here.

johannes

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 9 lines · Simon Barber

I like this proposal. One aspect that is missing is to define the meaning of the timestamp with aggregates. Should this field be present for all subframes, or just the first/last? Should the timestamp refer to the subframes, or the whole A-MPDU? Currently what I see in different generators is the MACTIME field is either the same for all subframes, and always refers to the whole A-MPDU - not individual subframes. For one generator the MACTIME was 0 for subframes after the 1st. Sometimes the signal strength is only present on the last subframe.

Yeah, I had actually noticed this - our device also has the PHY acquisition timestamp of the A-MPDU, in all the frames. We should probably elide it in all but the first, but if we somehow lost the first frame that would be bad. I'm not even sure you can identify that today at all though.

I don't think we can *standardise* the behaviour, but perhaps providing flags for the different behaviours would at least help you identify it?

Any thoughts what flags would be useful?

Quoted 2 lines

Macbooks generate radtiotap files with incorrect rate fields for subframes with CRC errors.

That's a bit odd. Talk to Broadcom? ;-)

Quoted 3 lines

If you look in the wireshark gerrit, you will see I have been porting my timeline viewer code over to the current devel mainline.

Very nice! :)

johannes

A message that is not in the archive (sent off-list or not yet received): 1453362011.13263.13.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org

#8 lore raw

My wireshark timeline code is out for early review.

https://code.wireshark.org/review/#/c/13694

Simon

Sent with AquaMail for Android
http://www.aqua-mail.com

Quoted 34 lines · Johannes Berg
Quoted 9 lines · Simon Barber

I like this proposal. One aspect that is missing is to define the meaning of the timestamp with aggregates. Should this field be present for all subframes, or just the first/last? Should the timestamp refer to the subframes, or the whole A-MPDU? Currently what I see in different generators is the MACTIME field is either the same for all subframes, and always refers to the whole A-MPDU - not individual subframes. For one generator the MACTIME was 0 for subframes after the 1st. Sometimes the signal strength is only present on the last subframe.

Yeah, I had actually noticed this - our device also has the PHY acquisition timestamp of the A-MPDU, in all the frames. We should probably elide it in all but the first, but if we somehow lost the first frame that would be bad. I'm not even sure you can identify that today at all though.

I don't think we can *standardise* the behaviour, but perhaps providing flags for the different behaviours would at least help you identify it?

Any thoughts what flags would be useful?

Quoted 2 lines

Macbooks generate radtiotap files with incorrect rate fields for subframes with CRC errors.

That's a bit odd. Talk to Broadcom? ;-)

Quoted 3 lines

If you look in the wireshark gerrit, you will see I have been porting my timeline viewer code over to the current devel mainline.

Very nice! :)

johannes

#9 lore raw
In reply to a message not in the archive
Quoted 2 lines · Simon Barber

I like this proposal. One aspect that is missing is to define the meaning of the timestamp with aggregates.

Actually, I think the field kinda already covers that.

If you have sampling position 0, then it ought to be of *that* MPDU, so probably not present in any subframes but the first, unless you can sample a different timestamp for each.

If you have sampling position 1 (PLCP start) then obviously that's at the A-MPDU level and it doesn't matter if it's present in all or the first only, in some ways. (Note that we found that Broadcom generates an invalid A-MPDU reference field...)

Sampling position 2 - end of frame - I'll clarify to be "end of PPDU", I think that's what ath* devices create.

johannes