Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Client-host networking strategy  (Read 2551 times)

0 Members and 1 Guest are viewing this topic.

Mutoh

  • Newbie
  • *
  • Posts: 31
    • View Profile
Client-host networking strategy
« on: March 23, 2015, 05:03:18 pm »
In the process of making a platformer with plans for a local multiplayer I have begun considering giving it an online multiplayer as well. I have done some research on networking an I want some input on my strategy.

Overall idea:
(click to show/hide)

---

Clients would only send input to the host, perhaps with intervals of once every [physics' step duration] seconds, but how the host should organize its received input packets is a more blurry area for me.

Should I use TCP when clients are sending inputs to the host, so that no inputs are received out of order by the host? I plan on having the host not wait for inputs from its clients, and keep gathering the inputs it receives into a queue. The queue would be depleted as it advances its physics' steps. The following pseudo-code should exemplify the procedure:
(click to show/hide)

I am worried about possible too bothersome delays between the clients and response time. After all, it takes on average 100-200ms for a client to receive response from the packet it just sent. I am willing to limit the online gameplay only to LAN connections if the only solutions are complicated predictions - a client-host architecture is still effective against preventing the lockstep asynching problem of peer-to-peer and even allows late-join.

---

I apologize for writing so much, but I want some critiques, suggestions and overall guiding from developers here with more experience with networking in games and SFML, as it hasn't been long since I started studying networks and I have done pretty much no experiments. Developing of the game has only started and this is the best time to decide on such critical points.

Noctiphobia

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Client-host networking strategy
« Reply #1 on: March 26, 2015, 01:39:53 am »

Mutoh

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Client-host networking strategy
« Reply #2 on: March 27, 2015, 03:09:16 pm »
That was an insightful read. I think I should store whole previous sequences of graphical states in a buffer, then. If I'm on sequence 20 and I receive a client packet in which the client acknowledges the sequence 15, I will compare sequence 15 and sequence 20 in my buffer and send the delta to this client.

Of course, the buffer should have a certain limit size, probably determined dynamically. If the client acknowledges a sequence that is no longer in the buffer I can send them the whole current graphical state - instead of sending it whole every X period of time. If the client's acked sequence is, say, 7 sequences behind the latest server sequence and my buffer is storing only the last 5 states, I can probably expand the buffer's limit to 7 for some time.

But I still don't have certainty on how the server would process input. Should I have the client keep sending packets to the server until it receives an ack response from the server? Let's say that, for example, a client whose last acked sequence was 15 will keep sending packets with their current input to the server. The client ends sending three packets before receiving the server's ack, all with different input data. The first input packet to arrive to the server was the second one sent. Upon acknowledge, should the server ignore all further packets it receives from the client that were marked with sequence 15? That is, should it ignore the first and third packets sent by the client while the client waited for a response?

blojayble

  • Newbie
  • *
  • Posts: 19
  • whoa
    • View Profile
Re: Client-host networking strategy
« Reply #3 on: March 27, 2015, 04:05:28 pm »
Are you familiar with this? http://zeromq.org/
It's a very nice library that, I think, will satisfy your needs. It has a very good guidebook, be sure to read it.

@EDIT, I skimmed trough the post too fast first time and got it somewhat wrong. I've been doing something similar before and assumed you are making the same thing. That aside, it still might prove to be useful.

« Last Edit: March 28, 2015, 12:41:45 pm by blojayble »
0 bottles of beer on the wall,
0 bottles of beer!
Take one down, pass it around,
4,294,967,295 bottles of beer on the wall!

Mutoh

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Client-host networking strategy
« Reply #4 on: March 29, 2015, 10:44:21 pm »
Ah, ZeroMQ provides a custom protocol, right? I think I'm fine with what SFML already provides in regards to network, I only need help on how to manage my data. ;)

I noticed that the client packet receiving strategy from my last post wouldn't work with input combinations that required nicely timed combos. I cannot ignore any packets, but I have to ensure that they are processed in the order they were sent. I think for that I will timestamp the packets.

 

anything