About the timestamp accuracy in wifi packet acceptance
About the timestamp accuracy in wifi packet acceptance
I call the function esp_cpu_get_cycle_count() in the wifi sniffer's interrupt function wifi_sniffer_packet_handler() and record the current CPU cycle count. Can I assume that this CPU cycle count corresponds to the local timestamp when a wifi packet arrives at the receiving end, and that the precision of this timestamp is the same as the CPU clock precision?
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: About the timestamp accuracy in wifi packet acceptance
No, you cannot assume that as there may be an undeterminable amount of latency between the packet coming in and the handler being triggered.salieri wrote: ↑Sun Aug 27, 2023 6:32 amI call the function esp_cpu_get_cycle_count() in the wifi sniffer's interrupt function wifi_sniffer_packet_handler() and record the current CPU cycle count. Can I assume that this CPU cycle count corresponds to the local timestamp when a wifi packet arrives at the receiving end, and that the precision of this timestamp is the same as the CPU clock precision?
Re: About the timestamp accuracy in wifi packet acceptance
But the process of receiving the two wifi packets is the same. I can assume that the cpu count difference between the two wifi packets is correct, right?
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: About the timestamp accuracy in wifi packet acceptance
No. As Sprite said, there are several effects which can cause varying latencies (jitter) between the time a hardware event happens and the time your code gets to handle it, e.g. critical sections (also inside FreeRTOS itself) or higher-priority interrupts.
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: About the timestamp accuracy in wifi packet acceptance
Aside from software things, you can also have hardware things like cache misses or pipeline stalls because something is talking to a slow peripheral (e.g. slow rtc memory)
Re: About the timestamp accuracy in wifi packet acceptance
Thanks for the answers, I probably understand what you guys are saying. I learned from a paper that you can use cpu cycle to record wifi packet arrival times as shown in the figure. Is there any way I can record the cpu cycle of wifi packet arrival?
- Attachments
-
- Excerpts from the paper
- 1.png (450.82 KiB) Viewed 1069 times
-
- Posts: 9730
- Joined: Thu Nov 26, 2015 4:08 am
Re: About the timestamp accuracy in wifi packet acceptance
It's not possible to do this on production firmware, in a way that will not have jitter, period. Perhaps the people making the paper were OK with jitter because they had a point to prove ('this is theoretically possible' vs 'this can be implemented in a practical sense'). You can try this if you want, but we as Espressif do not guarantee this will work, or that the timings won't change with a software or hardware change.
Who is online
Users browsing this forum: Baidu [Spider] and 80 guests