Provide correct timestamps to ngtcp2

This commit is contained in:
Mark Spanbroek 2020-11-09 17:14:26 +01:00 committed by markspanbroek
parent d17f733059
commit 613fd8318e
5 changed files with 14 additions and 6 deletions

View File

@ -12,6 +12,7 @@ import crypto
import connection
import path
import streams
import timestamp
var zeroKey = dummyKey()
@ -45,7 +46,8 @@ proc newClientConnection*(local, remote: TransportAddress): Connection =
callbacks.stream_open = streamOpen
callbacks.recv_stream_data = receiveStreamData
let settings = defaultSettings()
var settings = defaultSettings()
settings.initial_ts = now()
let source = randomConnectionId().toCid
let destination = randomConnectionId().toCid
let path = newPath(local, remote)

View File

@ -13,6 +13,7 @@ import connection
import path
import errors
import streams
import timestamp
let zeroKey = dummyKey()
@ -47,6 +48,7 @@ proc newServerConnection(local, remote: TransportAddress, source, destination: n
var settings = defaultSettings()
settings.transport_params.original_dcid = destination
settings.initial_ts = now()
let id = randomConnectionId().toCid
let path = newPath(local, remote)

View File

@ -1,4 +1,3 @@
import std/monotimes
import chronos
import ngtcp2
import ../openarray
@ -8,6 +7,7 @@ import connection
import errors
import path
import pointers
import timestamp
proc openStream*(connection: Connection): Stream =
var id: int64
@ -31,7 +31,7 @@ proc trySend(stream: Stream, messagePtr: ptr byte, messageLen: uint, written: va
stream.id,
messagePtr,
messageLen,
getMonoTime().ticks.uint
now()
)
checkResult length.cint
let data = stream.connection.buffer[0..<length]

View File

@ -0,0 +1,4 @@
import std/monotimes
proc now*: uint64 =
getMonoTime().ticks.uint64

View File

@ -1,4 +1,3 @@
import std/monotimes
import chronos
import ngtcp2
import ../openarray
@ -7,6 +6,7 @@ import ../congestion
import connection
import path
import errors
import timestamp
proc trySend(connection: Connection): Datagram =
var packetInfo: ngtcp2_pkt_info
@ -21,7 +21,7 @@ proc trySend(connection: Connection): Datagram =
-1,
nil,
0,
getMonoTime().ticks.uint
now()
)
checkResult length.cint
let data = connection.buffer[0..<length]
@ -46,7 +46,7 @@ proc receive*(connection: Connection, datagram: DatagramBuffer, ecn = ecnNonCapa
unsafeAddr packetInfo,
datagram.toUnsafePtr,
datagram.len.uint,
getMonoTime().ticks.uint
now()
)
connection.send()
connection.flowing.fire()