Network Link Conditioner using a Network Extension

Currently, I've been able to completely block requests using a Content Filter Network extension.

Right now, I'm looking to build a Network Link Conditioner that applies to an individual app only.

The Network Link Conditioner allows selecting profiles with specific settings:

Downlink

  • Packages Dropped
  • Bandwidth
  • Delay

Uplink

  • Bandwidth
  • Packets dropped
  • Delay

My question Is it possible to reproduce this behavior using a Network Extension and if so, which type of network extension should I use?

Answered by Systems Engineer in 790401022

Is it possible to reproduce this behavior using a Network Extension and if so, which type of network extension should I use?

NETransparentProxyProvider is probably your best bet here. The reason why I say that is because you are in charge of copying the flows on both sides of the connection and so you could develop an algorithm where small amounts of delay or data is dropped during the flow copying process without platform disruption.

Delay could be introduced as well with NEFilterDataProvider but that would back up the flow provider queue and could ultimately lead to issues if too much delay is introduced in the case (There can be a lot of traffic in this context!). NEFilterDataProvider does not offer a clear way to discard data / packets from a connection either, only to make a filtering decision.

One thing I will caution against is consuming too much memory in your process while delaying / causing packet loss. This could lead to your process getting terminated due to memory constraints or memory being reaped, especially on iOS.

Matt Eaton - Networking

Accepted Answer

Is it possible to reproduce this behavior using a Network Extension and if so, which type of network extension should I use?

NETransparentProxyProvider is probably your best bet here. The reason why I say that is because you are in charge of copying the flows on both sides of the connection and so you could develop an algorithm where small amounts of delay or data is dropped during the flow copying process without platform disruption.

Delay could be introduced as well with NEFilterDataProvider but that would back up the flow provider queue and could ultimately lead to issues if too much delay is introduced in the case (There can be a lot of traffic in this context!). NEFilterDataProvider does not offer a clear way to discard data / packets from a connection either, only to make a filtering decision.

One thing I will caution against is consuming too much memory in your process while delaying / causing packet loss. This could lead to your process getting terminated due to memory constraints or memory being reaped, especially on iOS.

Matt Eaton - Networking

Thanks a lot, this helps a ton! I'll check out the NETransparentProxyProvider and loop back in case it doesn't work out.

Network Link Conditioner using a Network Extension
 
 
Q