Download Dummynet Ubuntu

Posted on -
Download Dummynet Ubuntu Rating: 4,0/5 4404 reviews

Aug 25, 2017. This article will show how to install, set up, and use Dummynet to introduce latency into a network. On the system during the testing was the vCenter Service Appliance, a Windows Server 2012 (64-bit) machine running Active Directory services and two Ubuntu VMs that will be used to test Dummynet. It ran on a laptop, located in Champaign, IL, connected to DSL line with 3Mbps download and 512Kbps upload speeds. On the laptop, we used a. On this machine, we ran several VMware guest operating systems: a Ubuntu VM Client, a virtual router and a host implementing a transparent Dummynet link. The Ubuntu VM.

As part of one of my classes about 'how to be a grad student', we are required to work on 'miniprojects' with faculty outside of our own advisors. For mine, I decided to work with Patrick Traynor and two of his students, Brad Reeves and Michael Good.

For a project that they are working on they need a network simulator to simulate a long distance link, without going over a long distance. Since I have a network background, I am a good person to take this segment on. This involves simulating latency, loss rates, and jitter of the network link.

The Overall goals of this project are:

  • Create a pair of Virtual Machines to act as PBXes
  • Install Asterisk on both VMs to perform the PBX work.
  • Install Dummynet on both VMs to simulate the network latency.
  • Playback and record audio streams across the simulated link.

As described above, there are many goals, most of which are setup related. Much of what I did builds off of others' work, so there will be copious crediting of sources. Consider this section a compendium of links to those sources, along with notes about the modifications of their methods.

Setting up Virtual Machine

I used Virtual Box to host the two Virtual machines that were needed. I installed Ubuntu 12.04 64-bit as the host operating system.

At this point, I only created one Virtual Machine. This allowed me to install all of the software on a single VM, then clone that near-complete VM, without wasting time installing the same packages twice. Much of the software was installed manually, that is, not using apt, so this was a particular time saver.

The set up was very the basic setup that Virtual Box suggested, save a couple of details. When using the wizard to configure hardware, I set the memory size to be 1GB. Secondly, I created a second Network Interface. This can by done by clicking 'Settings', then selecting the 'Network' screen, then selecting the 'Adapter 2' tab. Click 'Enable Network Adapter'. In the 'Attached to:' dropdown, select 'Internal Network'. This creates an internal network - it is not seen outside of the hypervisor - that can be used to connect to the peer PBX.

Once Ubuntu was installed, the second network adaper needs an IP assigned. This can be configured any number of ways; use your favorite.

Installing Asterisk

Once the OS was installed, the difficult parts followed.

Asterisk is incredibly configurable, and seems to be the de-facto standard PBX software. Unfortunatley, it can be painful to configure. I'll get back to that in a bit, as we're concerned with installation of Asterisk at the moment.

I followed the guide from Digium written by Billy Chia to install the latest version of Asterisk (11.6.0) onto my Ubuntu VM. His guide is very detailed, and provides step by step installation instructions. This worked perfectly for me, so I can recommend it.

The same thing could be achieved by installing via apt. Less fun, but less involved. Much less involved. In retrospect, I would suggest installing the packages via apt. The biggest difference is that the package that Ubuntu 12.04 had was the Long Term Support (LTS) version of Asterisk, something in the 1.8 series. This will work just fine for what was done. It will also prevent any prerequisites from being missed, which can easily happen.

Installing Twinkle

Twinkle is a simple softphone that runs in Linux. It does what I needed it to do, which is make phone calls.

I installed this via apt:sudo apt-get install twinkle

Configuration of Twinkle will be covered below.

Installing Dummynet

Dummynet is a network emulation tool that's rather handy for simulating delays on the network, among other things. It's rather handy, and I was very impressed by how simple it is to use. Its installation, on the other hand, I was less impressed by. It was originally written for FreeBSD, but has been ported for Linux and Windows, and is part of FreeBSD and OSX by default (which is handy, as I could test it out on my Mac).

I had issues with installation, as I was trying to use the soruce code that worked with 2.6 and earlier kernels. Ubuntu 12.04 is running a 3.8 kernel, as of right now, so this involved finding the correct package of the Dummynet site. The package that I used is here, which is updated for kernels up to 3.8.

For installation, I used the instructions from the second post in the thread. These instructions, when you have the right source code, work perfectly. The biggest caveats that I can suggest involve being sure you have all the prerequisite headers, otherwise the compile of dummynet fails spactacularly.

Delay/jitter Script

This turned out to be reasonably straightforward, thanks to Andrew Dolce of Gradient Studios. He ran into a similar question when it came to testing video games, and simulating delay and jitter across a network. His blog post explained how he solved it, and includes a script that handles much of what I was looking to do. I modified it to also add dropping of data, and the final script can be found here.

Different parts of the script will be discussed in more detail below.

Cloning VM

At this point, much of what is identical is done, and the VM can be cloned. If you want to run the updates that Ubuntu has been nagging you to do, now is the best time, so that you don't have to run them twice.

Download

To do this, I shut down the one virtual machine that I was working on that I called PBX-A. I selected the 'Snapshots' screen for PBX-A, and took a snapshot pre-cloning. This is paranoia on my part, but it has come in handy as I did mess up a few times, and reverting to the snapshot was very helpful.

Now, cloning also happens on the 'Snapshots' screen. Right click on the snapshot that was just created or 'Current State', and click 'Clone'. I named my clone quite creatively as 'PBX-B'. The important part is to tick the box that says 'Reinitialize the MAC address of all network cards'. This prevents an ARP nightmare by having duplicate MAC address on the network. When you click 'Next', you have the option of Full or Linked clones. I chose Full, as I have gobs of hard disk space, so it wasn't an issue. I'm not sure if Linked clones are harder to export, so I'll defer to you on how to handle that. Similarly, it's up to you on the final screen, whether you want to include all snapshots or just the selected state.

Asterisk Configuration Files

This is where I spent much of my time. Getting initial configuration working wasn't difficult. I followed a couple of tutorials (1,2,3), that were very helpful at initial setup.

The configuration above is helpful for understanding the Asterisk configuration files. Each PBX VM has two network connections. One goes to the NAT device so that they have internet access, while the other goes to the peer PBX - this is the Internal Network Connection. The IP address listed in the VMs is the address off the Internal Network card. All telephony traffic goes over the Internal Network connection.

PBX-A Configuration Files:* asterisk.conf* extensions.conf* modules.conf* sip.conf

Download Dummynet Ubuntu Pc

PBX-B Configuration Files:* asterisk.conf* extensions.conf* modules.conf* sip.conf

The previous files are the interesting ones.

The asterisk.conf file isn't that interesting, but I've included it for completness. The most important part is the location of the 'astspooldir', which is /var/spool/asterisk. This is the location where the recordings go, and will be referenced later.

The extensions.conf file is the most important file, and will be discussed later.

The modules.conf file is important in that it enables all the modules that we need in order to run the system. The PBX-A configuration file is a more general file that includes most everything and it auto-loads whatever modules are needed. The PBX-B file is a manually written configuration file that includes only what is necessary. Both work, it's unimportant which one is used. They are both useful as examples.

The sip.conf file configures two important piece. It defines the link between the two PBXes, as well as two handsets on each PBX.

From PBX-A's sip.conf file:

register => pbxa:welcome@192.168.1.200/pbxb

This tells the PBX to register a connection with PBX-B at 192.168.1.200. PBX-A's username on PBX-B is 'pbxa' and uses a password of 'welcome'. There is the equivalen on PBX-B. There are three 'friend' entries. The first is for 'pbxb', while the other two are for two softphones that can connect to it. In each of them, there's a 'context' line. This is used in the extensions.conf file to tell the PBX how to handle any calls from each source.

In the extensions.conf file for both PBX-A and PBX-B, there is a lot going on. I'm going to explain the important pieces now, and gloss over the majority of what is in the file. As noted in the goals up above, we need to playback a sound file, and record it on the far side.

From PBX-A's extensions.conf file, the following extension starts recording locally using the MixMonitor command, answers the call, then plays a sound file, and finally hangs up the call.

From PBX-B's extensions.conf file, the following handles any call going to a four digit extension that begins with '4', then records what is happening, then dials the correct extension, and waits for the hang-up signal to occur.

These recordings are then stored in the /var/spool/asterisk/monitor folder.

Setup Twinkle

Twinkle's setup is reasonably straightforward - enter in the usernames and passwords that were defined in the sip.conf file, along with the appropriate IP address, and it should be nearly ready to connect. In my set up, the SIP port needs to be changed from the standard 5060 to 5070. This occurs in the 'System Settings' screen under the 'Network' tab.

Calls between the four softphone extensions that are defined in the sip.conf files is simple, but the important parts are related to the special 4000 extenion on PBX-A.

Softphone

The user would go to PBX-B and dial 4000 on the softphone. Since there is no microphone on the VM, nothing will be transmitted. PBX-A will answer and play whatever sound file is specified. It will then hangup. Both PBX-A and PBX-B will have sound files generated that can be used for analysis.

I would recommend copying and pasting the the 4000 extension and modifying it for a series of extensions (4001, 4002, etc), each with a different sound file. This would significantely simplify testing, in that a series of phone calls could be made easily.

Delay/jitter Script

The jitter script is very easy to use. It needs to be run by root (sudo works just fine). At the moment, it runs and changes the network latency very 1/10 of a second for 10 minutes based on a few configured parameters at the beginning of the script. It should be on both PBXes, such that per-link latency can be modified.

The following shows some of the configuration parameters within the script.

The jitter is centered around the midpoint of MIN_LAG and MAX_LAG.

References

Active5 years, 7 months ago

I'm trying to use Dummynet to test the behaviour of my network application in various network conditions. The emulator was compiled and installed on an Ubuntu 12.04 box. I'm experiencing a strange behaviour when I reduce the bandwidth of the link/path.

For some reason, instead of having a slow download speed. It seems as if the download is happening in bursts! A portion of the data is downloaded at a high speed, then the data transfer stops for a period of time and then resumes again (and so on). Does anyone have an idea what could be the cause? Or is this even expected?

informer2000informer2000

1 Answer

I guess you already do that, but for ensure you must to do the follow:

Compile a new kernel with support for IPFW and Dummynet, putting this lines on your kernel config file:

After that compile and install your new kernel. To do that follow the steps on Building and Installing a Custom Kernel

Doing that, configure the rc.conf file with this lines:

If you are not using the default firewall conf file /etc/rc.firewall then put your config file like this, instead 'OPEN':

for testing purposes you can write yours rules directly on console an see what happens, and after write this on your config file to preserve the rules.

for a basic bandwith limit this rules must be enough:

Now you have two pipes with 1Mbit of bandwidth each, lets put the traffic on this pipes.

Doing this your is limiting your self to pipes previously created.

This is basic for Dummynet bandwidth control.

Márcio EliasMárcio Elias
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged linuxnetworkingnetwork-programmingfreebsd or ask your own question.