Tuesday 10 March 2009

Using Dummynet to simulate WAN links (2/2)


Thought it might be a good idea to split these sections as you only install once (Sounds like a bad Bond movie) So this part I'll deal with the operation of Dummynet:

Dummynet is contolled by the IPFW command but first we have to configure both Ethernet interfaces and set them up for bridging.

Configure both interfaces with an IP address within the same subnet (Any will do) as below:

# Ifconfig dc0 inet 192.168.0.253 netmask 255.255.255.0

# Ifconfig rl0 inet 192.168.0.252 netmask 255.255.255.0

Note: These IP address aren't actually visible to external devices, so they don't have to conform to the exiting subnet surrounding your server (It just appears as a L2 device, which the following command enables)

Then link both interfaces together so they will bridge packets rather than route them:

# sysctl –w net.link.ether.bridge.enable=1

# sysctl –w net.link.ether.bridge.config=dc0,rl0

Now we can define a firewall pipe where we can control the bandwidth and delay

# ipfw add pipe 1 ip from any to any

# ipfw pipe 1 config bw 3200Kbit/s queue 10 delay 150ms

Now check the firewall rulesets and delete any lines which have a lower value than the rules you just entered.

# ipfw show

# ipfw delete

Dummynet is now up and configured. You should be able to change bandwidth as per the ipfw pipe command shown above.

Surprisingly it's quite accurate, you can verify this yourself (always good practice) with some other tools (Future blog me thinks) and maybe an FTP server.

No comments:

Post a Comment