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

Rendezvous Connection: Wrong Initial Sequence Initialization of the Receiver #2773

Closed
maxsharabayko opened this issue Aug 4, 2023 · 1 comment · Fixed by #2772
Closed
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@maxsharabayko
Copy link
Collaborator

The RCV buffer is initialized with the host's Initial Sequence Number value. If the host is the receiver, the ISN of the sender peer has to be used.
The issue results in the "SEQUENCE DISCREPANCY. BREAKING CONNECTION" error report upon the first data packet received.

Before PR #2711 the correct value was set after the RCV buffer had been initialized via CUDT::applyResponseSettings(..).
After the PR the RCV buffer may not yet be created when CUDT::applyResponseSettings(..) is called for the first time.

If it happens to be called once more or if the distance between the host's ISN and peer's ISN is not that big, the sending would work.

SRT versions with the bug: v1.5.2, v1.5.2.rc.2.

@maxsharabayko maxsharabayko added Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core labels Aug 4, 2023
@maxsharabayko maxsharabayko added this to the v1.6.0 milestone Aug 4, 2023
@maxsharabayko maxsharabayko modified the milestones: v1.6.0, v1.5.3 Aug 8, 2023
@maxsharabayko
Copy link
Collaborator Author

The condition is for the receiving side to lose the initial WAVEHAND handshake. Then it gets the CONCLUSION request and initializes the buffer with the wrong ISN.
Reproduced locally with v1.5.2 applying 10% packet drop and 10% packet reordering.

Receiver side

srt-xtransmit  receive "srt://127.0.0.1:4200?mode=rendezvous&bind=:5200" --enable-metrics -v
11:29:21.219814 [I] SOCKET::SRT srt://127.0.0.1:4200: bound to ':5200'.
11:29:21.221048 [D] SOCKET::SRT 0x2A7A9938 ASYNC Connecting to srt://127.0.0.1:4200
11:29:21.223000/T45736!W:SRT.cn: @712677688: COOKIE CONTEST RESOLVED: RESPONDER
11:29:21.223000/T45736!W:SRT.cn: @712677688: rendezvousSwitchState: HS: version=5 type=0x1 ISN=667419692 MSS=1500 FLW=8192 reqtype=conclusion srcID=621674819 cookie=cd2dba8 srcIP=127.0.0.1.0.0.0.0.0.0.0.0.0.0.0.0.FLAGS:  hsx no-pbklen
11:29:21.223000/T45736!W:SRT.cn: @712677688: applyResponseSettings: HANSHAKE CONCLUDED. SETTING: payload-size=1456 mss=1500 flw=8192 isn=667419692 peerID=621674819 sourceIP=unknown:0
11:29:21.223000/T45736!W:SRT.rs: @712677688: prepareBuffers: ISN 444132657
11:29:21.252539 11:29:21.252000/T45736*E:SRT.qr: @712677688: SEQUENCE DISCREPANCY. BREAKING CONNECTION. %667419692 buffer=(%444132657:%667419691+%444140847), 18446744073486272773 past max. Reception no longer possible. REQUESTING TO CLOSE.
[I] SOCKET::SRT 0x2A7A9938 ASYNC Connected to srt://127.0.0.1:4200. KM state UNSECURED (RCV UNSECURED, SND UNSECURED). PB key length : 0.
11:29:21.253319 [D] SOCKET::SRT 0x2A7A9938 read::recv ERROR 2001 Connection was broken
11:29:21.253389 [I] RECEIVE Latency, us: avg n/a, min n/a, max n/a. Jitter: 0us. Delay Factor: 1us. Pkts: rcvd 0, reordered 0 (dist 0), lost 0, MD5 err 0, bad len 0.
11:29:21.253895 [W] RECEIVE read::recv: Connection was broken
11:29:22.264036 [D] SOCKET::SRT 0x2A7A9938 Releasing epolls before closing
11:29:22.264587 [D] SOCKET::SRT 0x2A7A9938 Closing

Sender side

srt-xtransmit generate --sendrate 1Mbps "srt://127.0.0.1:5200?mode=rendezvous&bind=:4200" --enable-metrics --duration 2s -v
11:29:20.580368 [I] SOCKET::SRT srt://127.0.0.1:5200: bound to ':4200'.
11:29:20.581642 [D] SOCKET::SRT 0x250E0143 ASYNC Connecting to srt://127.0.0.1:5200
11:29:21.221000/T33128!W:SRT.cn: @621674819: COOKIE CONTEST RESOLVED: INITIATOR
11:29:21.222000/T33128!W:SRT.cn: @621674819: rendezvousSwitchState: HS: version=5 type=0x0 ISN=444132657 MSS=1500 FLW=8192 reqtype=waveahand srcID=712677688 cookie=a7c02d48 srcIP=127.0.0.1.0.0.0.0.0.0.0.0.0.0.0.0.FLAGS: NONE
11:29:21.222000/T33128!W:SRT.cn: @621674819: applyResponseSettings: HANSHAKE CONCLUDED. SETTING: payload-size=1456 mss=1500 flw=8192 isn=444132657 peerID=712677688 sourceIP=unknown:0
11:29:21.222000/T33128!W:SRT.rs: @621674819: prepareBuffers: ISN 667419692
11:29:21.224000/T33128!W:SRT.cn: @621674819: COOKIE CONTEST RESOLVED: INITIATOR
11:29:21.224000/T33128!W:SRT.cn: @621674819: rendezvousSwitchState: HS: version=5 type=0x1 ISN=444132657 MSS=1500 FLW=8192 reqtype=conclusion srcID=712677688 cookie=a7c02d48 srcIP=127.0.0.1.0.0.0.0.0.0.0.0.0.0.0.0.FLAGS:  hsx no-pbklen
11:29:21.224000/T33128!W:SRT.cn: @621674819: applyResponseSettings: HANSHAKE CONCLUDED. SETTING: payload-size=1456 mss=1500 flw=8192 isn=444132657 peerID=712677688 sourceIP=unknown:0
11:29:21.225148 [I] SOCKET::SRT 0x250E0143 ASYNC Connected to srt://127.0.0.1:5200. KM state UNSECURED (RCV UNSECURED, SND UNSECURED). PB key length : 0.
11:29:21.225589 [I] PACER sendrate 1000000 bps (inter send interval 10537 us)
11:29:21.284893 [D] SOCKET::SRT 0x250E0143 write::send. ERROR: Connection was broken.
11:29:21.286827 [W] GENERATE write::send: Connection was broken
11:29:21.288552 [D] SOCKET::SRT 0x250E0143 Releasing epolls before closing
11:29:21.290214 [D] SOCKET::SRT 0x250E0143 Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant