Jump to content

Netcode Is Pretty Hard (Demo Inside)


6 replies to this topic

#1 pesco

    Member

  • PipPipPipPipPipPipPipPip
  • 1,008 posts

Posted 12 December 2012 - 12:06 PM

So the MWO netcode has me as frustrated as many and that led to the question: How does it work!?

I spent a few days thinking about it until I was reasonably confident I had it figured out in principle. I wrote a few posts back then that I'm too lazy to dig up. Anyway, two or three weeks ago I decided to code a simple demo which would show if any of it actually worked.

I've got the first second version done now. There is still stuff to do, but I'd like to share it.

The program simulates a networked environment consisting of one server and two clients. The "game" universe is very simple: it consists of the player (the blue square) and a target (the red circle). The circle can move and the square can fire a projectile. Shown are the view of the player's client and of the server; the target's client runs in the background. There is an actual (very simple) protocol of messages spoken between the clients and the server. Each message is delayed a controllable amount of time, 70ms by default.

Here is the slightly more technical description from the source code:
Spoiler


I'll upload a video later. For now, here's a screenshot.
Spoiler


Update: Video.


You can try the program yourself. Just download and run (no malware, promise ;)).

Download Version 0.2 (2012-12-24)
Download Version 0.1 (2012-12-12)

There are three four settings that affect how the client tries to compensate for lag. I won't go into detail what they do right now, just try them out and take a guess. :)

NB: The target's client likes to get confused because it's stupid and sends the red circle off the screen. Just press "Reset" if that happens. This is more likely the more "jittery" things are.

Update 2012-12-24: Version 0.2 adds client-side interpolation, a more stable movement algo for the target, performance improvements, and some tweaks to better show how shots connect as lag compensation kicks in.


PS: If anyone wants to see the source code, I'll upload it. It's a few hundred lines.
Source Version 0.2
Source Version 0.1
Tclkit 8.5.8 for Windows

Edited by pesco, 23 December 2012 - 05:43 PM.


#2 SteelyDan

    Member

  • PipPipPipPipPipPip
  • Knight Errant
  • 305 posts
  • LocationChicago Ill

Posted 12 December 2012 - 12:25 PM

And in reality... ;)

Posted Image

#3 xenoglyph

    Member

  • PipPipPipPipPipPipPipPip
  • 1,480 posts
  • LocationSan Diego

Posted 12 December 2012 - 03:09 PM

Source plz. Bonus points if it includes a Visual Studio project.

#4 pesco

    Member

  • PipPipPipPipPipPipPipPip
  • 1,008 posts

Posted 12 December 2012 - 03:24 PM

View Postxenoglyph, on 12 December 2012 - 03:09 PM, said:

Source plz. Bonus points if it includes a Visual Studio project.

I fear you might be dissapointed, though possibly not in the way you expect. :}
lagdemo-0.1.tcl

Use this to run it:
Tclkit 8.5.8 for Windows (32bit)

#5 xenoglyph

    Member

  • PipPipPipPipPipPipPipPip
  • 1,480 posts
  • LocationSan Diego

Posted 12 December 2012 - 05:15 PM

Oh wow, Tcl....haven't seen that in ages =)

Edited by xenoglyph, 12 December 2012 - 05:17 PM.


#6 pesco

    Member

  • PipPipPipPipPipPipPipPip
  • 1,008 posts

Posted 12 December 2012 - 05:19 PM

Hey, I'm glad if you can read it. ;) I just learned it and, well, it is as easy as they say to throw something together.

#7 pesco

    Member

  • PipPipPipPipPipPipPipPip
  • 1,008 posts

Posted 23 December 2012 - 05:41 PM

Update 2012-12-24: Version 0.2 adds client-side interpolation, a more stable movement algo for the target, performance improvements, and some tweaks to better show how shots connect as lag compensation kicks in.

See OP for download links.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users