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

Lots of changes on common protocols #12

Merged
merged 9 commits into from
Jun 17, 2023

Conversation

DaniElectra
Copy link
Member

@DaniElectra DaniElectra commented Jun 5, 2023

  • Since we now store the client station URLs on nex.Client, there's no
    need for external handlers to do so, so remove them. Also, the handlers
    were deprecated as they didn't do anything anyway.
  • Use common struct on NAT traversal and remove external handlers,
    as we now store the client station URLs on nex.Client. And implement
    ReportNATTraversalResult.
  • Various changes to Matchmaking:
    • Use structure.Copy() and structure.Equal() now that they are
      implemented.
    • Add notification types that weren't used before.
    • Remove handlers for MatchMaking(-Ext) and use global sessions for
      handling rooms.
    • And possibly more

Depends on PretendoNetwork/nex-protocols-go#24

Since we now store the client station URLs on nex.Client, there's no
need for external handlers to do so, so remove them. Also, the handlers
were deprecated as they didn't do anything anyway.
Also remove external handlers, as we now store the client station URLs
on nex.Client. And implement ReportNATTraversalResult.
- Use structure.Copy() and structure.Equal() now that they are
  implemented.
- Add notification types that weren't used before.
- Remove handlers for MatchMaking(-Ext) and use global sessions for
  handling rooms.
- And possibly more
matchmake-extension/auto_matchmake_postpone.go Outdated Show resolved Hide resolved
matchmaking-ext/end_participation.go Outdated Show resolved Hide resolved
nat-traversal/report_nat_traversal_result.go Outdated Show resolved Hide resolved
globals/matchmaking_globals.go Outdated Show resolved Hide resolved
@DaniElectra
Copy link
Member Author

DaniElectra commented Jun 6, 2023

While I was testing this on MK7, everything seemed to work fine, except that one of the clients would randomly disconnect in-game from the session (also causing the other client to leave) and from NEX for seemingly no reason (there aren't any requests sent to NEX before this happening, just the Leaving message).

Luckily, the NEX matchmaking sessions themselves seem to work fine. I can't test nat traversal however, since both machines are connected to the same network

@DaniElectra DaniElectra marked this pull request as ready for review June 6, 2023 20:37
@jonbarrow
Copy link
Member

(there aren't any requests sent to NEX before this happening, just the Leaving message).

About how long does this take to happen? It sounds like a ping timeout issue

@DaniElectra
Copy link
Member Author

(there aren't any requests sent to NEX before this happening, just the Leaving message).

About how long does this take to happen? It sounds like a ping timeout issue

It would happen some seconds after the game had started (the time varied on each test).
Actually, that may be it, since the server is set with ping after 999 seconds and I hadn't changed that parameter

I will try again tomorrow

@DaniElectra
Copy link
Member Author

DaniElectra commented Jun 8, 2023

Interestingly, the issue above appears on Race mode, but on Battle mode almost everything works just fine, and I can play as many rounds as I want. However, when one of the participants leaves, the EndParticipation isn't sent for some reason (but the client doesn't disconnect from the server), and the other player will show a connection error.

I wonder if this is a me issue, because of having the server and consoles on the same network? idk

@jonbarrow
Copy link
Member

It's possible that's causing issues, yeah. I've had a few issues when hosting the servers on the same network as the clients in the past. That is weird though

@jonbarrow
Copy link
Member

jonbarrow commented Jun 10, 2023

I see this was marked as open, no longer a draft. Are we still waiting for more changes or is this ready for review now?

@DaniElectra
Copy link
Member Author

Yes, it's ready for review

Copy link
Member

@jonbarrow jonbarrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things addressed here are not actually changes you made, but they are around the code you are working on and this PR seems to be broadly covering a refactor of the common protocols, so I figured they fit

Also full transparency, since I am personally not very familiar with the matchmaking system specifically, my review is strictly on code quality and performance. I have not exactly reviewed the logic behind the matchmaking itself, and I would prefer if I could get another set of eyes on that. I have already assigned @shutterbug2000 for this task as well, but will likely also call upon Rambo since he's done great work on MK8

You will also need to update the go modules, as I have pushed updates to them and made some breaking changes to some protocols

globals/matchmaking_globals.go Outdated Show resolved Hide resolved
globals/matchmaking_globals.go Outdated Show resolved Hide resolved
globals/matchmaking_globals.go Show resolved Hide resolved
globals/matchmaking_globals.go Outdated Show resolved Hide resolved
globals/matchmaking_globals.go Outdated Show resolved Hide resolved
matchmake-extension/auto_matchmake_postpone.go Outdated Show resolved Hide resolved

currentTime := nex.NewDateTime(0)
common_globals.Sessions[sessionIndex].GameMatchmakeSession.StartedTime = nex.NewDateTime(currentTime.UTC())

common_globals.CurrentGatheringID++
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value doesn't appear to be checked anywhere. Though very unlikely, if a server runs for long enough and people keep creating sessions then this will reach the max uint32. Reaching this value may create unexpected side effects (such as the above check thinking no session was found, which I addressed in an earlier comment as well). This should be bounds checked

matchmaking-ext/end_participation.go Outdated Show resolved Hide resolved
matchmaking-ext/end_participation.go Outdated Show resolved Hide resolved
matchmaking/update_session_host.go Outdated Show resolved Hide resolved
@shutterbug2000
Copy link
Collaborator

Looks good to me

@jonbarrow
Copy link
Member

Relating to a comment we talked about the other day, nex-protocols-go version 1.0.30 now has a GatheringFlags structure in the match making protocol to hold all the possible flags a gathering can have. I added 0x20 and 0x200 as well despite them being labeled as "unknown"

@jonbarrow
Copy link
Member

Carrying over from Discord, @shutterbug2000 has confirmed that the matchmaking changes here work fine in MK7 during his testing. So this PR should be good to merge once the Go modules are updated (I merged your other PR PretendoNetwork/nex-protocols-go#25 and made a new release) and once the other issues are looked at

Also implement Kerberos ticket time check.
@DaniElectra
Copy link
Member Author

DaniElectra commented Jun 15, 2023

I changed invalid values to be zero, as it can't be a valid gathering ID nor a valid connection ID. To get a gathering ID, I changed the counter to the function GetSessionIndex(), which will check for empty sessions starting from ID 1. I tested this implementation in isolation (with maps with a million values) with minimal performance impact. Considering a PID can only create one session, it's impossible that we reach the max uint32 limit, so if we get an error, it should be an issue of not erasing empty sessions.

I also implemented time validation on Kerberos tickets. If the ticket is expired, we kick the client for timeout, as on Mario Kart 7 the client was still sending data packets when using a graceful kick (using graceful kicks aren't really an issue though, as we delete the client and the server can't decrypt those data packets anymore [PRUDPv0] Error decoding packet data: [PRUDPv0] Error parsing RMC request: RMC Request size does not match length of buffer, but the client would get spammy with those packets).

We have to increase the ticket time and compare to the server time.
Whoops.
@jonbarrow jonbarrow merged commit 0342dc2 into PretendoNetwork:main Jun 17, 2023
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

Successfully merging this pull request may close these issues.

3 participants