We're using SFS2X as the network solution for one of our projects and I find a strange problem. I'll try to explain as simply and as detailed as possible.
Consider state the set of user variables describing the game state (it contains a packet number to help packet identification) and packet a TCP packet.
I'm using the following configuration to reproduce the problem:
Server (s)- local machine
client 1(c1) - client on Unity editor
client 2(c2) - client on iOS device
Sometimes, not always, when c2 performs an action (like jumping) the state describing the position received at c1 are duplicate or somewhat invalid.
This is a Unity trace that shows in which frame a certain numbered state is received:
We can see from this trace that state 71 is dropped and 72 is received twice at the frame 4560.
To evaluate at which communication layer the problem was occurring I toke a trace from the packets exchanged between c1,c2 and s (packets are ordered by oldest to newest):
Packet number
contains both states 71 and 72 as you can see from the packet data:1825
Code: Select all
0000 6c 96 cf df 8c 15 d0 c5 f3 55 30 4c 08 00 45 00 l.Ïß..ÐÅóU0L..E.
0010 02 58 00 00 40 00 40 06 05 49 c0 a8 d8 d1 c0 a8 .X..@.@..IÀ¨ØÑÀ¨
0020 d9 34 d1 7c 26 cd ad 16 cf 28 ed 7c 86 ce 80 18 Ù4Ñ|&Í..Ï(í|.Î..
0030 08 00 06 21 00 00 01 01 08 0a 2b 30 ec 18 52 90 ...!......+0ì.R.
0040 10 d2 80 01 0f 12 00 03 00 01 63 02 00 00 01 61 .Ò........c....a
0050 03 00 0c 00 01 70 12 00 01 00 02 76 6c 11 00 0d .....p.....vl...
0060 11 00 04 08 00 01 78 02 03 07 3f fb 3e 06 60 00 ......x...?û>.`.
0070 00 00 01 00 11 00 04 08 00 01 79 02 03 07 3f f6 ..........y...?ö
0080 78 60 a0 00 00 00 01 00 11 00 04 08 00 01 7a 02 x` ...........z.
0090 03 07 40 31 89 c5 00 00 00 00 01 00 11 00 04 08 ..@1.Å..........
00a0 00 03 72 6f 74 02 03 07 40 50 09 ef a0 00 00 00 ..rot...@P.ï ...
00b0 01 00 11 00 04 08 00 02 61 73 02 02 04 7c 16 1a ........as...|..
00c0 2b 01 00 11 00 04 08 00 02 61 70 02 03 07 40 33 +........ap...@3
00d0 52 b3 c0 00 00 00 01 00 11 00 04 08 00 02 72 65 R³À...........re
00e0 02 02 04 00 00 00 00 01 00 11 00 04 08 00 01 74 ...............t
00f0 02 01 01 00 01 00 11 00 04 08 00 02 78 73 02 03 ............xs..
0100 07 00 00 00 00 00 00 00 00 01 00 11 00 04 08 00 ................
0110 02 79 73 02 03 07 40 16 c7 2e 80 00 00 00 01 00 .ys...@.Ç.......
0120 11 00 04 08 00 02 7a 73 02 03 07 00 00 00 00 00 ......zs........
0130 00 00 00 01 00 11 00 04 08 00 02 74 73 02 02 04 ...........ts...
0140 00 00 00 [b]47[/b] 01 00 11 00 04 08 00 02 71 61 02 01 ...G........qa..
0150 01 00 01 00 80 01 0f 12 00 03 00 01 63 02 00 00 ............c...
0160 01 61 03 00 0c 00 01 70 12 00 01 00 02 76 6c 11 .a.....p.....vl.
0170 00 0d 11 00 04 08 00 01 78 02 03 07 3f fb 3e 06 ........x...?û>.
0180 60 00 00 00 01 00 11 00 04 08 00 01 79 02 03 07 `...........y...
0190 3f fb cf 80 a0 00 00 00 01 00 11 00 04 08 00 01 ?ûÏ. ...........
01a0 7a 02 03 07 40 31 89 c5 00 00 00 00 01 00 11 00 z...@1.Å........
01b0 04 08 00 03 72 6f 74 02 03 07 40 50 09 ef a0 00 ....rot...@P.ï .
01c0 00 00 01 00 11 00 04 08 00 02 61 73 02 02 04 7c ..........as...|
01d0 16 1a 2b 01 00 11 00 04 08 00 02 61 70 02 03 07 ..+........ap...
01e0 40 33 54 c1 40 00 00 00 01 00 11 00 04 08 00 02 @3TÁ@...........
01f0 72 65 02 02 04 00 00 00 00 01 00 11 00 04 08 00 re..............
0200 01 74 02 01 01 00 01 00 11 00 04 08 00 02 78 73 .t............xs
0210 02 03 07 00 00 00 00 00 00 00 00 01 00 11 00 04 ................
0220 08 00 02 79 73 02 03 07 40 0a 16 cf 00 00 00 00 ...ys...@..Ï....
0230 01 00 11 00 04 08 00 02 7a 73 02 03 07 00 00 00 ........zs......
0240 00 00 00 00 00 01 00 11 00 04 08 00 02 74 73 02 .............ts.
0250 02 04 00 00 00 [b]48[/b] 01 00 11 00 04 08 00 02 71 61 .....H........qa
0260 02 01 01 00 01 00
This packet was sent from c2->s. Next, we can see that SFS2X server immediately sent two packets to c1 (
and1759
), containing states 71 and 72:1761
1759
Code: Select all
0000 02 00 00 00 45 00 01 4e 00 00 40 00 40 06 00 00 ....E..N..@.@...
0010 7f 00 00 01 7f 00 00 01 26 cd e9 1b f3 a3 46 16 ........&Íé.ó£F.
0020 ad fd 5d 08 80 18 31 2d ff 42 00 00 01 01 08 0a .ý]...1-ÿB......
0030 52 90 11 3c 52 90 10 d3 80 01 17 12 00 03 00 01 R..<R..Ó........
0040 70 12 00 02 00 01 75 04 00 00 00 63 00 02 76 6c p.....u....c..vl
0050 11 00 0d 11 00 04 08 00 01 78 02 03 07 3f fb 3e .........x...?û>
0060 06 60 00 00 00 01 00 11 00 04 08 00 01 79 02 03 .`...........y..
0070 07 3f f6 78 60 a0 00 00 00 01 00 11 00 04 08 00 .?öx` ..........
0080 01 7a 02 03 07 40 31 89 c5 00 00 00 00 01 00 11 .z...@1.Å.......
0090 00 04 08 00 03 72 6f 74 02 03 07 40 50 09 ef a0 .....rot...@P.ï
00a0 00 00 00 01 00 11 00 04 08 00 02 61 73 02 02 04 ...........as...
00b0 7c 16 1a 2b 01 00 11 00 04 08 00 02 61 70 02 03 |..+........ap..
00c0 07 40 33 52 b3 c0 00 00 00 01 00 11 00 04 08 00 .@3R³À..........
00d0 02 72 65 02 02 04 00 00 00 00 01 00 11 00 04 08 .re.............
00e0 00 01 74 02 01 01 00 01 00 11 00 04 08 00 02 78 ..t............x
00f0 73 02 03 07 00 00 00 00 00 00 00 00 01 00 11 00 s...............
0100 04 08 00 02 79 73 02 03 07 40 16 c7 2e 80 00 00 ....ys...@.Ç....
0110 00 01 00 11 00 04 08 00 02 7a 73 02 03 07 00 00 .........zs.....
0120 00 00 00 00 00 00 01 00 11 00 04 08 00 02 74 73 ..............ts
0130 02 02 04 00 00 00 [b]47[/b] 01 00 11 00 04 08 00 02 71 ......G........q
0140 61 02 01 01 00 01 00 00 01 61 03 00 0c 00 01 63 a........a.....c
0150 02 00 ..
1761
Code: Select all
0000 02 00 00 00 45 00 01 4e 00 00 40 00 40 06 00 00 ....E..N..@.@...
0010 7f 00 00 01 7f 00 00 01 26 cd e9 1b f3 a3 47 30 ........&Íé.ó£G0
0020 ad fd 5d 08 80 18 31 2d ff 42 00 00 01 01 08 0a .ý]...1-ÿB......
0030 52 90 11 3f 52 90 11 3c 80 01 17 12 00 03 00 01 R..?R..<........
0040 70 12 00 02 00 01 75 04 00 00 00 63 00 02 76 6c p.....u....c..vl
0050 11 00 0d 11 00 04 08 00 01 78 02 03 07 3f fb 3e .........x...?û>
0060 06 60 00 00 00 01 00 11 00 04 08 00 01 79 02 03 .`...........y..
0070 07 3f fb cf 80 a0 00 00 00 01 00 11 00 04 08 00 .?ûÏ. ..........
0080 01 7a 02 03 07 40 31 89 c5 00 00 00 00 01 00 11 .z...@1.Å.......
0090 00 04 08 00 03 72 6f 74 02 03 07 40 50 09 ef a0 .....rot...@P.ï
00a0 00 00 00 01 00 11 00 04 08 00 02 61 73 02 02 04 ...........as...
00b0 7c 16 1a 2b 01 00 11 00 04 08 00 02 61 70 02 03 |..+........ap..
00c0 07 40 33 54 c1 40 00 00 00 01 00 11 00 04 08 00 .@3TÁ@..........
00d0 02 72 65 02 02 04 00 00 00 00 01 00 11 00 04 08 .re.............
00e0 00 01 74 02 01 01 00 01 00 11 00 04 08 00 02 78 ..t............x
00f0 73 02 03 07 00 00 00 00 00 00 00 00 01 00 11 00 s...............
0100 04 08 00 02 79 73 02 03 07 40 0a 16 cf 00 00 00 ....ys...@..Ï...
0110 00 01 00 11 00 04 08 00 02 7a 73 02 03 07 00 00 .........zs.....
0120 00 00 00 00 00 00 01 00 11 00 04 08 00 02 74 73 ..............ts
0130 02 02 04 00 00 00 [b]48[/b] 01 00 11 00 04 08 00 02 71 ......H........q
0140 61 02 01 01 00 01 00 00 01 61 03 00 0c 00 01 63 a........a.....c
0150 02 00 ..
So, the server sent the packets right to the client, but as shown on the image above c1 dropped state 71 and duplicated state 72. It appears that both packets were received before the next update and 72 overwrote the last state.
I've explained this case since it was simpler, but we found even cases were 3 packets were intertwined, resulting in even more duplicated packets. All tests were conducted using a LAN.
Our game is a real-time third person and this client behavior is confusing our interpolation/dead reckoning, and also showing some ghosting.
Can someone please help me with this issue?
Best regards,