Howto:Record, analyze and replay multiplayer flights with network tools: Difference between revisions

Jump to navigation Jump to search
m
Minor cleanup
(→‎Wiki articles: + Instant Replay)
m (Minor cleanup)
 
Line 1: Line 1:
{{Note|As of 2020-August, Flightgear next has built-in support for recording/replaying multiplayer aircraft.}}
{{Note|As of August 2020, FlightGear next has built-in support for recording/replaying multiplayer aircraft.}}


You can '''record, analyze and replay flights with network tools''' by recording and working on UDP packets sent through the [[multiplayer protocol]] between your computer and a [[Howto:Multiplayer|multiplayer]] server.
You can '''record, analyze and replay flights with network tools''' by recording and working on UDP packets sent through the [[multiplayer protocol]] between your computer and a [[Howto:Multiplayer|multiplayer]] server.
Line 32: Line 32:
What do we have now? We have the flight recorded at the network level!
What do we have now? We have the flight recorded at the network level!


With wireshark we can now extract some pilot(s), use a certain time interval of traffic, or see certain traffic properties.
With Wireshark we can now extract some pilot(s), use a certain time interval of traffic, or see certain traffic properties.


With the help of tcpreplay/tcprewrite, we can send the multiplayer traffic back to a running FlightGear session.
With the help of tcpreplay/tcprewrite, we can send the multiplayer traffic back to a running FlightGear session.
Line 53: Line 53:
== Analyzing UDP packets loss/jitter ==
== Analyzing UDP packets loss/jitter ==
[[File:Wireshark mp rate analyse.png|600px|thumb|Received Multiplayer packet rate]]
[[File:Wireshark mp rate analyse.png|600px|thumb|Received Multiplayer packet rate]]
Here is a wireshark analysis showing the multiplayer packet rate for different multiplayer pilots from a recorded multiplayer session.
Here is a Wireshark analysis showing the multiplayer packet rate for different multiplayer pilots from a recorded multiplayer session.
* The black curve got a nice 10 packets/s, our internet link was good and is maybe connected to the same multiplayer server.
* The black curve got a nice 10 packets/s, our internet link was good and is maybe connected to the same multiplayer server.
* The red and pink were pretty chaotic. Their packets are often lost and I guess they are jittery in FlightGear. They were probably connected to an other multiplayer server.
* The red and pink were pretty chaotic. Their packets are often lost and I guess they are jittery in FlightGear. They were probably connected to an other multiplayer server.
Line 64: Line 64:
To make things short, tcpreplay can not send directly to FlightGear if we are on the same computer.
To make things short, tcpreplay can not send directly to FlightGear if we are on the same computer.


Until now I either use an other PC to send traffic back to my FlightGear PC, or i send to the internet box's external IP  address, with a redirection to my pc for the port used in its firewall.
Until now I either use an other PC to send traffic back to my FlightGear PC, or i send to the internet box's external IP  address, with a redirection to my PC for the port used in its firewall.


According to the tcpreplay FAQ, it could work if tcpreplay runs in a virtualized machine, but I did not give it a go.
According to the tcpreplay FAQ, it could work if tcpreplay runs in a virtualized machine, but I did not give it a go.
Line 78: Line 78:
* The computer we will use to send the recorded packets: MAC address 99:88:77:66:55:44, IP address 192.168.1.17
* The computer we will use to send the recorded packets: MAC address 99:88:77:66:55:44, IP address 192.168.1.17


It is up to you to find your MAC and IP address. You can use wireshark on some network traffic between the two, or ifconfig on Linux etc. Here is the "magic" line,
It is up to you to find your MAC and IP address. You can use Wireshark on some network traffic between the two, or ifconfig on Linux etc. Here is the "magic" line,
  tcprewrite -C --enet-smac=99:88:77:66:55:44 --enet-dmac=00:11:22:33:44:55  
  tcprewrite -C --enet-smac=99:88:77:66:55:44 --enet-dmac=00:11:22:33:44:55  
  -S 0.0.0.0/0:192.168.1.17 -D 0.0.0.0/0:192.168.1.12 -i recorded.cap -o readytosend.cap
  -S 0.0.0.0/0:192.168.1.17 -D 0.0.0.0/0:192.168.1.12 -i recorded.cap -o readytosend.cap


where:
where:
* -C force a checksum recalculation. If not the packets are not valid and are not sent.
* <code>-C</code> force a checksum recalculation. If not the packets are not valid and are not sent.
* --enet-smac gives the mac address of the sender
* <code>--enet-smac</code> gives the mac address of the sender
* --enet-dmac same with the receiver
* <code>--enet-dmac</code> same with the receiver
* -S changes source IP address
* <code>-S</code> changes source IP address
* -D does the same for destination
* <code>-D</code> does the same for destination
* -i input file (the previously recorded flight)
* <code>-i</code> input file (the previously recorded flight)
* -o output file
* <code>-o</code> output file


tcprewrite do not need to be root to be used, but using tcpreplay to see the recorded traffic again need root access to use the network interface.
tcprewrite do not need to be root to be used, but using tcpreplay to see the recorded traffic again need root access to use the network interface.


Now we start FlightGear with Multiplayer enabled by sending to a server (it can be a MPserver or the address of a valid local host on your network, for example 192.168.0.17).
Now we start FlightGear with multiplayer enabled by sending to a server (it can be a MPserver or the address of a valid local host on your network, for example 192.168.0.17).


Finally we start replaying the flight, on the dedicaced PC:
Finally we start replaying the flight, on the dedicaced PC:
Line 100: Line 100:
Be sure to use the correct name for the network interface. ifconfig/ipconfig is your friend here!
Be sure to use the correct name for the network interface. ifconfig/ipconfig is your friend here!


Tcpreplay works fine this way if we don't need a very good time flow sync, as it end being late, dépending on the cpu usage mostly. I didn't notice this issue at first, but this became evident using lag statistics available recently in next, so to keep a good sync between tcpreplay and flightgear, using a core affinity, setting a priority higher and preferably on a not overloaded PC/CPU core makes things better, so we got something like that on linux:
tcpreplay works fine this way if we don't need a very good time flow sync, as it end being late, depending on the CPU usage mostly. I didn't notice this issue at first, but this became evident using lag statistics available recently in next, so to keep a good sync between tcpreplay and FlightGear, using a core affinity, setting a priority higher and preferably on a not overloaded PC/CPU core makes things better, so we got something like that on Linux:


  taskset 02 nice -n -15 tcpreplay -x 1.000065  -K -i enp0s10  /rab/refuel/test.pcapng
  taskset 02 nice -n -15 tcpreplay -x 1.000065  -K -i enp0s10  /rab/refuel/test.pcapng


The "-x" option (time acceleration) ensure a good time sync over the replay (find yourself the best value for your config :) ), i just need to adjust the time offset for the mp clock, to have replayed planes in sync with my session, considered as "real time" buddys.
The <code>-x</code> option (time acceleration) ensure a good time sync over the replay (find yourself the best value for your config :) ), i just need to adjust the time offset for the mp clock, to have replayed planes in sync with my session, considered as "real time" buddies.


=== Give it a try ===
=== Give it a try ===
[[File:Fighters mont aiguille.jpg|thumb|The "mont aiguille", in the French Vercors Massif.]]
[[File:Fighters mont aiguille.jpg|thumb|The "Mont Aiguille", in the French Vercors Massif.]]
if you don't have time to make a record yourself, you can use this [http://janodesbois.free.fr/flightgear/cap_files/vercors_test.cap.bz2 flight in the French Vercors Massif] (3.4M). Start at LFLU, runway 01 with the [[UFO]] or in a plane capable of more than 400 kts, and follow the leading [[McDonnell F-4 Phantom II|F-4N]] in a Vercors Massif trip, followed by a [[English Electric Lightning|Lightning]], a [[General Dynamics F-16 Fighting Falcon|F-16]] and a [[Grumman F-14 Tomcat|F-14B]]. It is better with a detailed scenery like "La France d'el maxo".
If you do not have time to make a record yourself, you can use this [http://janodesbois.free.fr/flightgear/cap_files/vercors_test.cap.bz2 flight in the French Vercors Massif] (3.4 MB). Start at LFLU, runway 01 with the [[UFO]] or in a plane capable of more than 400 kt, and follow the leading [[McDonnell F-4 Phantom II|F-4N]] in a Vercors Massif trip, followed by a [[English Electric Lightning|Lightning]], a [[General Dynamics F-16 Fighting Falcon|F-16]] and a [[Grumman F-14 Tomcat|F-14B]]. It is better with a detailed scenery like "La France d'el maxo".


Just decompress it, and use tcprewrite to match your config.{{-}}
Just decompress it, and use tcprewrite to match your config.{{-}}

Navigation menu