Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamps are not accurate if bus is suspended and resumed during the capture #55

Open
desowin opened this issue Jan 5, 2023 · 0 comments

Comments

@desowin
Copy link
Contributor

desowin commented Jan 5, 2023

Packet timestamps are generated based on 24 bit 60 MHz counter value. For example OutputPcap generates nanosecond resolution timestamp based on the counter value:

# Increment timestamp based on the 60 MHz 24-bit counter value.
# Convert remaining clocks to nanoseconds: 1 clk = 1 / 60 MHz = 16.(6) ns
if ts < self.last_ts:
self.ts_offset += (1 << 24)
self.last_ts = ts
clks = self.ts_offset + ts
if clks >= 60e6:
self.utc_ts += 1
self.ts_offset -= 60e6
clks -= 60e6
nanosec = int((clks * 17) - (clks // 3))

The approach of detecting counter overflows by comparing timestamp against previous timestamp works fine when there is actual bus traffic (even when there is no transfer in progress there is a steady number of SOF packets sent on Full- and High- speed links). However, the timestamps become no longer relevant when the bus is suspended and therefore there is no traffic whatsoever on the bus. Host has no way to tell how many overflows there were during the suspend.

A naive solution is to send new magic byte on every counter overflow. Then the host software could use it to keep the timestamp accurate while the bus is suspended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant