Increase packet size of utp over discv5 (#1042)

* Increase packet size of utp over discv5
This commit is contained in:
KonradStaniec 2022-04-07 13:54:49 +02:00 committed by GitHub
parent 8af5c33ef9
commit 0365d030fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -111,8 +111,9 @@ proc run(config: PortalConf) {.raises: [CatchableError, Defect].} =
# One instance of UtpDiscv5Protocol is shared over all the PortalStreams.
let
maxPayloadSize = uint32(discv5MaxSize - talkReqOverhead - utpHeaderOverhead)
socketConfig = SocketConfig.init(
incomingSocketReceiveTimeout = none(Duration))
incomingSocketReceiveTimeout = none(Duration), payloadSize = maxPayloadSize)
streamTransport = UtpDiscv5Protocol.new(
d,
utpProtocolId,
@ -123,7 +124,6 @@ proc run(config: PortalConf) {.raises: [CatchableError, Defect].} =
stateNetwork.portalProtocol.stream,
historyNetwork.portalProtocol.stream]),
socketConfig)
stateNetwork.setStreamTransport(streamTransport)
historyNetwork.setStreamTransport(streamTransport)

View File

@ -22,6 +22,18 @@ const
utpProtocolId* = "utp".toBytes()
defaultConnectionTimeout = 5.seconds
defaultReadTimeout = 2.seconds
# TalkReq message is used as transport message
talkReqOverhead* =
16 + # IV size
55 + # header size
1 + # talkReq msg id
3 + # rlp encoding outer list, max length will be encoded in 2 bytes
9 + # request id (max = 8) + 1 byte from rlp encoding byte string
3 + # rlp encoding response byte string, max length in 2 bytes
16 + # HMAC
len(utpProtocolId) + 1 # + 1 is necessary due to rlp encoding of those bytes
utpHeaderOverhead* = 20
discv5MaxSize* = 1280
type
ContentRequest = object