Skip to content

Instantly share code, notes, and snippets.

@pnc pnc/
Last active Oct 12, 2015

What would you like to do?
Randomize link quality

Creating an awful Wi-Fi network

  1. Plug an Ethernet cable into your computer. You'll need this for Internet connectivity while your Wi-Fi card is used to create a network.

  2. Enable Internet Sharing in System Preferences.

  3. Get your phone connected to the network you just created and make sure you can browse the web.

  4. Ensure dummynet'd packets are still routed through the normal rules so masquerading works:

     eleos@Nebula ~$ sudo sysctl -w net.inet.ip.fw.one_pass=0
     net.inet.ip.fw.one_pass: 0 -> 0
  5. Configure the low-quality pipe:

     eleos@Nebula ~$ sudo ipfw pipe 1 config bw 14KB/s
     eleos@Nebula ~$ sudo ipfw pipe 1 config plr 0.01
  6. Route packets into the pipe, but only for traffic over your AirPort interface:

     eleos@Nebula ~$ sudo ipfw add 10 pipe 1 ip from any to any via en1
     00010 pipe 1 ip from any to any via en1
while true do
plr = (rand * 100).round / 100.0
if plr > 0.8
plr = 1.0
bw = rand(20)
plr_command = "sudo ipfw pipe 1 config plr #{plr}"
bw_command = "sudo ipfw pipe 1 config bw #{bw}KB/s"
puts plr_command
puts bw_command
length = rand(45)
puts "sleep #{length}"
sleep length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.