Page 1 of 1

Soji's thoughts on Distance Lag.

Posted: Thu Oct 31, 2013 7:43 pm
by Venom
As any aerobatic pilot may know, distance lag has been the enemy of YS Aerobatic Flying since it's existance. If you do not
know what distance lag is, feel free to visit Scarecrow's thread HERE. I recently contacted Mr. Yamakawa on this matter wondering if there were any plans to alter the YSFlight network code to help fix this, here is his response.
Hi Venom,

I wish I could do something. But, nothing can travel faster than the speed of light. The light can go only 7.5 times around the world per second. So, if the server to client distance is at the earth's circumference, you cannot avoid 1/7.5 second lag.

If you are connecting between NY and CA, probably it is 7 times shorter than the earth's circumference. If you have nothing in between your client and the server, the lag will be reduced to 1/52 second. If you are in a bicycle simulator, you are in good shape. This lag will cause only less than 1ft difference. However, if you are flying an airplane flying at Mach 0.8 near sea level, 1/52 second lag will make 17ft difference.

It is the best case that you have nothing in between the client and the server, and connected straight line geodesic distance. In reality, network packets goes through many routers, and they are not located on a straight line. Also, each router takes some time to receive and dispatch a packet. Therefore, chances are, you will get an order of 1/20 second lag even when you are lucky, which will give you 43ft lag.

YSFLIGHT does indeed some interpolation and extrapolation to reduce the lag, but unless some theoretical physicists come up with a new theory that allows data packets travel faster than the speed of sound, it is difficult to reduce the lag further.

Some network games do aggressive path prediction to virtually eliminate the lag, but in those games, instead of the data traveling faster than light, the airplane in the game often travel faster than light, and you may see an airplane suddenly disappear and appear behind you. (That also happens in YSFLIGHT in a slow connection.)

So, it would be the best if you can get together occasionally. Flying a formation with someone connected to the same network hub is much easier than to do the same between Pittsburgh and Japan. (I did a few times and it was fun though.)

Re: Soji's thoughts on Distance Lag.

Posted: Fri Nov 01, 2013 3:43 am
by Scarecrow
Venom,

Thanks for posting Mr. Yamakawa's response! Makes it easier for us to understand.

However, I am a bit "confused" on:
Some network games do aggressive path prediction to virtually eliminate the lag, but in those games, instead of the data traveling faster than light, the airplane in the game often travel faster than light, and you may see an airplane suddenly disappear and appear behind you. (That also happens in YSFLIGHT in a slow connection.)
How does this play out for flight simulators like Lock On, for example? I wonder.

Thanks for sharing.

Re: Soji's thoughts on Distance Lag.

Posted: Fri Nov 01, 2013 12:33 pm
by Vic Viper
I've experienced this is racing games, where the proximity of the cars also causes some issues. I believe Soji is right, those games try their best to predict but often are wrong, cars end up almost in front and behind me simultaneously, especially if the driver is from across the pond.

Re: Soji's thoughts on Distance Lag.

Posted: Fri Nov 01, 2013 7:23 pm
by VNAF ONE
This is super good input and I can understand it!!! Ya I'm no techie but this makes a lot of sense.

My next question though is what would it take for YS to act like other games like LockOn and FSX with formation stuff. I've flown with people from New Zealand and can get very close before I start to even see jumpiness. I know that Flake is working on some sort of similar protocol to reduce distance lag, but would it take a change to YS's configuration in order to make it calculate these "faster than the speed of light" changes?

I hope my words make sense because I might be sounding confusing right now.

Re: Soji's thoughts on Distance Lag.

Posted: Fri Nov 01, 2013 7:55 pm
by Venom
Scarecrow wrote:Venom,

Thanks for posting Mr. Yamakawa's response! Makes it easier for us to understand.

However, I am a bit "confused" on:
Some network games do aggressive path prediction to virtually eliminate the lag, but in those games, instead of the data traveling faster than light, the airplane in the game often travel faster than light, and you may see an airplane suddenly disappear and appear behind you. (That also happens in YSFLIGHT in a slow connection.)
How does this play out for flight simulators like Lock On, for example? I wonder.

Thanks for sharing.

I think he means that automatically, the game predicts the path of the aircraft and simultaneously, the plane appearing on separate clients screen will end up in the predicted spot. And all of this happens faster than the data can travel to the other clients on the server. I am guessing this is what happens when there are "Lag Jumps".


My next question though is what would it take for YS to act like other games like LockOn and FSX with formation stuff. I've flown with people from New Zealand and can get very close before I start to even see jumpiness. I know that Flake is working on some sort of similar protocol to reduce distance lag, but would it take a change to YS's configuration in order to make it calculate these "faster than the speed of light" changes?

I will be sure to ask him this, and get back to you VNAF!

Re: Soji's thoughts on Distance Lag.

Posted: Fri Nov 01, 2013 9:02 pm
by Eric
Interesting stuff. I was able to find a research paper on the subject of reducing latency with special routing algorithms: http://citeseerx.ist.psu.edu/viewdoc/do ... 1&type=pdf
Here's another paper on latency prediction (which is useful to YS because then we can calculate where the plane should appear to other clients): https://homes.cs.washington.edu/~arvind ... ctural.pdf

I'm going to do a bit more research to see if I can find anything on how other online games deal with this.

EDIT: Found a journal article that deals specifically with flight sims: http://pro.sagepub.com/content/55/1/1529.abstract
Unfortunately you have to pay for it.

Re: Soji's thoughts on Distance Lag.

Posted: Fri Jan 24, 2014 4:50 pm
by Venom
Recently I talked with him again and here is what he had to say that other flight simulators are doing.
Sorry for the late reply. That's a very good question. There are many programming tricks that makes you feel like you are not having lags. My guess is other flight simulators are using one (or combination) of these.

For example, some (so-called) flight simulators in 1990s were drawing airplanes much bigger, like 10 times, of the actual size. Or, moving it 10 times slower than the indicated speed. By doing it, apparent distance-error immediately gets 10 times smaller. It was not for solving network-lag problem, but rather to show airplanes bigger on the screen. I played the game called "Strike Commander" so many times, and in that game I could see enemy airplanes very large on the HUD. But, definitely the airplanes were not drawn to the scale.

Another trick is to transmit relative location to the wing leader, rather than the absolute location, across the clients. It is possible if the program can identify the wing leader airplane. The program also needs to identify when other airplanes are leaving/joining the formation since the coordinates of the airplanes not in the formation should still be transmitted in the global coordinate. (I can use the same technique to enable motion of aircraft carrier in the network mode) It is, however, a technologically challenging and I cannot solve quickly.

Of course, better delay-estimation and path prediction can also a solution. The client can ping the server and the server echos back the signal to measure the turn-around time. But, the path-prediction can never be accurate.

The most effective among the above tricks is the scaling. But YSFLIGHT is calculating speed and drawing airplanes in the real scale. So, I wish I had a magical solution to this problem, but quite challenging.

Re: Soji's thoughts on Distance Lag.

Posted: Sat Jan 25, 2014 12:00 am
by Flake
Soji Yamakawa wrote:Another trick is to transmit relative location to the wing leader, rather than the absolute location, across the clients. It is possible if the program can identify the wing leader airplane. The program also needs to identify when other airplanes are leaving/joining the formation since the coordinates of the airplanes not in the formation should still be transmitted in the global coordinate. (I can use the same technique to enable motion of aircraft carrier in the network mode) It is, however, a technologically challenging and I cannot solve quickly.
Glad to see we are thinking the same way.

If Yamakawa-San is reading this, I say please please PLEASE go with this route.

I might even do some mental work to find a solution and post here.

Re: Soji's thoughts on Distance Lag.

Posted: Sat Jan 25, 2014 12:04 am
by Eric
I know it will break all our existing network mods, but can we get YSFlight to switch to UDP instead of TCP? Maybe that would solve some of our issues.

Re: Soji's thoughts on Distance Lag.

Posted: Sat Jan 25, 2014 1:31 am
by Flake
Hows about rather then doing complex calculations, let the pilot choose?

Enter->Set Formation Target->1.2.3.4... (from currently flying pilots)

Grabs the aircraft ID, and then sends relative position packets based on this, whenever the aircraft is within 2* HT Radius as seen on their clients screen?

We could define a Flight Data Packet type 6 for this, and not break anything major.

For example:

a display team spawns for a demo. The wingmen press enter, choose formation target, then choose "[1] OfficerFlake (F-18_HORNET)"

YSF grabs the aircraft ID of that aircraft and sets it as the target.

Now, whenever the aircraft is within double it's ht distance, for example, if it's ht distance is 14m, then 28m, it should send flight data packet type 6, which is pretty much identical to the short data packets, except the position of and angles of the aircraft are relative to the flight lead, ALL as calculated from that own clients perspective.

I think this would be the fastest and easiest fix: pilots can quickly press enter then a button while flying, and prior to a break, could press enter, form, 0 to remove the formation...

If no body has objections to this idea, I will do a write up of my idea and send to Soji?

EDIT: Oh and of course, after defining a target, you could perhaps use autopilot->fly formation?