Skip to content

Instantly share code, notes, and snippets.

@blocktrron
Created September 6, 2024 10:27
Show Gist options
  • Select an option

  • Save blocktrron/26408c9f8707e5c2e4049302866be01e to your computer and use it in GitHub Desktop.

Select an option

Save blocktrron/26408c9f8707e5c2e4049302866be01e to your computer and use it in GitHub Desktop.
#!/bin/sh
# Install kmod-netem
# opkg update && opkg install kmod-netem
INTERFACE="$1"
IFB_INTERFACE="$INTERFACE-ifb"
ip link add "$IFB_INTERFACE" type ifb
ip link set "$IFB_INTERFACE" up
# Redirect traffic to IFB
tc qdisc add dev "$INTERFACE" clsact
tc filter add dev "$INTERFACE" ingress protocol all prio "512" matchall action mirred egress redirect dev "$IFB_INTERFACE"
tc qdisc add dev "$INTERFACE" root netem
tc qdisc add dev "$IFB_INTERFACE" root netem
tc qdisc change dev "$INTERFACE" root netem delay 100ms 10ms 25% duplicate 4% reorder 8% rate 5100000 loss random 15%
tc qdisc change dev "$IFB_INTERFACE" root netem delay 100ms 10ms 25% duplicate 4% reorder 8% rate 5100000 loss random 15%
tc qdisc change dev "$INTERFACE" root netem delay 100ms 10ms 25% duplicate 4% reorder 5% rate 5M loss random 8%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment