Skip to contentSkip to conversation

why does skb->tstamp use getnstimeofday?

DISCUSSION Anatoly Sivov 3 participants 7 messages Jan 15, 2012 – Jan 16, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello everyone.

struct sk_buff has a field tstamp, which is used for high resolution rtt calculation. All operations with this field are done directly or indirectly via ktime_* interface, which uses getnstimeofday function.
My question is why does skb->tstamp use getnstimeofday?
Isn't it better to use getrawmonotonic, where we are not inetrfered with ntp, for rtt calculation?

Thank you.

#1 lore raw
Quoted 11 lines · Anatoly Sivov

Hello everyone.

struct sk_buff has a field tstamp, which is used for high resolution rtt calculation.
All operations with this field are done directly or indirectly via ktime_* interface,
which uses getnstimeofday function.
My question is why does skb->tstamp use getnstimeofday?
Isn't it better to use getrawmonotonic, where we are not inetrfered with ntp, for rtt calculation?

It's using this since day 0, so cannot be changed or break applications, which expect timeofday, not monotonic.

monotonic time services were added later.

#2 lore raw

Hello Eric,

thanks for your answer.

Quoted 1 line

monotonic time services were added later.

Yep, I understand.

Quoted 2 lines

It's using this since day 0, so cannot be changed or break applications, which expect timeofday, not monotonic.

I missed that field tstamp is used for things other than RTT and can be even user-spaced with SO_TIMESTAMP. However, timekeeper speed up/slow down (due to ntp) can seriously affect some congestion avoidance algorithm quality, I guess. Am I wrong?

#3 lore raw
Quoted 2 lines

some congestion avoidance algorithm quality, I guess.

I mean efficiency, not quality.

#4 lore raw
In reply to Anatoly Sivov
Quoted 5 lines · Anatoly Sivov

I missed that field tstamp is used for things other than RTT and can be even user-spaced with SO_TIMESTAMP.
However, timekeeper speed up/slow down (due to ntp) can seriously affect some congestion avoidance algorithm quality, I guess.
Am I wrong?

For what kind of application or protocol do you feel there could be a problem ?

TCP stack doesnt use skb->tstamp/jtime_t, for example, but jiffies.

ntp adjustements are normally very small and nobody notice.

#5 lore raw
Quoted 1 line

TCP stack doesnt use skb->tstamp/jtime_t, for example, but jiffies.

Some CA engines asks for RTT calculation with skb->tstamp.
They state about it by setting TCP_CONG_RTT_STAMP flag in their struct tcp_congestion_ops instances.

Quoted 2 lines

For what kind of application or protocol do you feel there could be a problem ?

I don't insist on problems are here, just want to mark that there could be a problem with these CA engines in the case of "big ntp adjustment".

#6 lore raw
In reply to Anatoly Sivov
Quoted 5 lines · Anatoly Sivov

I missed that field tstamp is used for things other than RTT and can be even user-spaced with SO_TIMESTAMP.
However, timekeeper speed up/slow down (due to ntp) can seriously affect some congestion avoidance algorithm quality, I guess.
Am I wrong?

Good question - not sure if we will see anything, but the upcoming leap-second might be interesting to watch - though I think contemporary NTP addresses that by a big slew rather than a step adjust. Of course it can step-adjust the time on the system, but 99 times out of 10 (*) that will be just at system start-up, when there probably will not be all that many congestion controlled connections active. Of course, who knows what that 100th out of 10 times will do.

rick jones
* 99 times out of 10 is an expression which if I recall correctly was coined or at least repeated by a high-school sports coach to mean "virtually all of the time"