Using simulated packet loss with reliable pipeline

NetworkStreamReceiveSystem.cs has this code where it sets up the pipelines with simulated delay and packet loss:

if (simulatorParams.PacketDelayMs > 0 || simulatorParams.PacketDropInterval > 0)
{
    unreliablePipeline = driver.CreatePipeline(
        typeof(SimulatorPipelineStage),
        typeof(SimulatorPipelineStageInSend));
    reliablePipeline = driver.CreatePipeline(
        typeof(SimulatorPipelineStage),
        typeof(ReliableSequencedPipelineStage),
        typeof(SimulatorPipelineStageInSend));
    unreliableFragmentedPipeline = driver.CreatePipeline(
        typeof(SimulatorPipelineStage),
        typeof(FragmentationPipelineStage),
        typeof(SimulatorPipelineStageInSend));
}

It looks to me like the SimulatorPipelineStage drops received packets after the ReliableSequencedPipelineStage in the reliable pipeline making this test a bit misleading. I’m thinking the reliable stage should be first? Or am I misunderstanding how the pipeline works?

And am I correct in just assuming stuff sent is the reliable pipeline is always eventually received as long as the connection doesn’t go and die?

The order of those is incorrect and it has been fixed on the 0.50 branch. The reliable stage should be first, as should the fragmentation stage in unrealiableFragmentedPipeline.

The reliable pipeline will always deliver the packets as long as begin / end send returns true. If sending returns false that means the send window is full and the delivery is not guaranteed. In netcode for entities we have a separate queue for RPCs where we keep them until they are accepted by the reliable pipeline (send succeeds) in order to guarantee delivery.

2 Likes