DotNetMud: Client Server Poll Loops

The original muds didn’t need this because telnet, but with the spaceship game in mind, I need some way to sync game-data back and forth between server and client.

Without any hard work, the poll looks like this:

  • C:  “Server, hit me.  I got you some inputs: I1”
  • S: “Hit!  H1”
  • C: “Server, hit me, inputs I2”
  • S: “Hit!  H2”

So if you have a 200msec lag time, you get a hit every 400msec.  That’s assuming upload and download lag are similar.

If you go a little crazier you can work with intermediate frames

  • Setup: Real Time clock R = 0, corresponds to CT=1000 and ST=2000.   Neither server nor client can know R.   Upload lag 200ms, download lag 50ms
  • R=0, Client sends “hit me, CT=1000”
  • R=200, Server receives hit request at ST=2200.   maybe it takes 15 msec to put together the response. 
  • R=215, server sends H1 CT1=1000 ST1=2200 ST2=2215
  • R=265, client receivesH1 CT1=1000 ST1=2200 ST2=2215 at CT2=1265
  • Client now knows that round trip time is about 265 msec.   Maybe it takes 20msec to put everything where it goes
  • R=285, client sends “hit me H2 CT=1285  Intermediate frame: 133ms”
  • R=485, server receives the above request.
  • R=500, server sends H2
  • R=550, client receives H2
  • R=633, server sends H2.1 as requested
  • R=683, client receives H2.1

I haven’t coded it yet, but the client is in charge of throttling, and there’s going to be some interesting “what did I try before” “what shall I try now” logic. 

There’s also a limit.   If the client requested too many intermediate frames, the actual network transport might start bundling the frames together and/or delivering them out of order.     

Note that upload and download lag are different – so it might be completely plausible to have 2 or 3 intermediate frames before the client can actually send back its next update.

A more advanced algorithm would have the server asking the client for intermediate frames, but I don’t live in a reality where that needs to be solved.

There’s also some work in the above protocol to figure out server to client time offset.  Its not an easy question to handle.  And there are also drifting lag speeds – as I write this attached to a 3G Karma Go device.  which keeps going from 2 to 3 circles and back.

Dialing it back

I don’t need to solve it all now.  For starters – all I need is a simple loop.  When I get to space ships floating around and changing direction based on user input, then I’ll need the intermediate frame update stuff.     Just need to know it is solvable.

 

 

Tagged with:
Posted in Code, Games

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories
Tags
.net 3d 3d-printing 4k abc15 algorithms ames android anonymous types asp.net audio editing aws backup basecamp beatunes biorhythm bittorrent blender blog boston marathon bpm c# caffeine campfire candycrush car carmax charity chiropractor cities-skylines clog clone codelouisville codepalousa coding coffee collaboration color run ComputerElbow ComputerVision configuration consulting cooking crash course crashplan crestwood cycling dabda dan dapper DataSet ddl diabetes dictation dotnetcore dotnetmud downtown e-cycling elite excel exercise expiration facebook feature-branching firefall flipflops Flow FL Studio focus food forecastle fortresscraft franklinplanner gadgets game-design games git github google docs google maps gopro gps grandpa greenshot hack half marathon headless health heart rate hiren ignew integration testing interop inventory ios ipad itunes javascript jobs karma kdf keyboards keys kittens lamont laptop lavalamp lego life lifehack linq linqtotwitter linux los angeles louisville mandelbulber massage therapy mastery-teaching maths merge metformin Minecraft miniature modeling monitor mud muhammad ali institute music mvc mycartracks netfabb nexus10 node nostalgia nutrition nwipe oldham county grand slam opal openjscad openscad owin pacedj paper mockup pepakura performance photoscan politics pomodoro postgresql powershell premiere prius process product-management project-management qa resharper review rmi roman road 5k RSI rubiks running samsung 700t sandals schedule scooter scribblelive selenium service shapeways sleep slic3r sneakersync snot software software-engineering solidoodle soylent spacegame speaking sql sqlite SSDT SSIS standing state-machine stayfocusd stonehearth sunset tablet teaching team teamcity teamtreehouse terraform testing tfs time timelapse torque touch tracks trs80 Tuple tutor twitter ubuntu unit testing utilities video video editing visual studio vscode vsvim warp stabilizer windows 8 windows home server wordpress wpf xml
Archives
%d bloggers like this: