Table Of Contents
Table Of Contents

Using Real Applications in a Simulated Network

Goals

In this showcase, we’ll use real applications which communicate over a simulated network. This feature is useful for testing how applications work over the network, without having to set up a physical network. The simulated network can be easily configured for various topologies and behaviors to test a variety of cases.

We’ll use INET’s emulation feature to interface the real world (the host OS environment) with the simulation. INET has various modules which facilitate this interfacing, you can read about them in the Emulation section of the showcases page. In this scenario, we’ll use a real video application to stream a video file to another real video application.

Note that this showcase requires the Emulation feature of the INET Framework to be turned on (it’s off by default), and it only runs on Linux.

INET version: 4.2

The Model

The simulation scenario is illustrated with the following diagram:

../../../../_images/setup.png

In this scenario, a VLC instance in a sender host streams a video file to another VLC instance in a receiver host over the network. The hosts from the link-layer up are real; parts of the link-layer, as well as the physical layer and the network are simulated.

We’ll use the ExtUpperEthernet interface to connect the real and simulated parts of the scenario. The lower part of this interface is present in the simulation, and uses TAP interfaces in the host OS to send and receive packets to and from the upper layers of the host OS.

Note that the real and simulated parts can be separated at other levels of the protocol stack, using other, suitable EXT interface modules, such as at the transport layer (ExtLowerUdp), and the network layer (ExtUpperIpv4, ExtLowerIpv4).

In fact, the real parts of the sender and receiver hosts are running on the same machine, as both use the protocol stack of the host OS (even though in this scenario logically they are different hosts):

../../../../_images/actualsetup.png

We’ll use a VLC instance in the sender host to stream a video file. The packets created by VLC go down the host OS protocol stack and enter the simulation at the Ethernet interface. Then they traverse the simulated network, enter the receiver host’s Ethernet interface, and are injected into the host OS protocol stack, and go up to another VLC instance which plays the video.

The network for the simulation is the following:

../../../../_images/Network2.png

It contains two StandardHost’s. Each host is connected by an EtherSwitch to a Router.

The sender VLC application will stream the video to the address of the router’s eth0 in the simulation. The router will perform network address translation to rewrite the destination address to the address of the receiver host’s EXT/TAP interface.

This is required so that the video packets actually enter the simulated network; if they were sent to the receiver host’s EXT/TAP interface, they would go through the loopback interface because the host OS optimizes traffic.

Three shell scripts in the showcase’s directory can be used to control the emulation scenario. The setup.sh script creates the TAP interfaces, assigns IP addresses to them, and brings them up:

# create TAP interfaces
sudo ip tuntap add mode tap dev tapa
sudo ip tuntap add mode tap dev tapb

# assign IP addresses to interfaces
sudo ip addr add 192.168.2.20/24 dev tapa
sudo ip addr add 192.168.3.20/24 dev tapb

# bring up all interfaces
sudo ip link set dev tapa up
sudo ip link set dev tapb up

The teardown.sh script does the opposite; it destroys the TAP interfaces when they’re no longer needed.

# destroy TAP interfaces
sudo ip tuntap del mode tap dev tapa
sudo ip tuntap del mode tap dev tapb

The run.sh script starts the simulation, and both video applications:

# start streaming server
cvlc RickAstley.mkv --sout '#transcode{vcodec=h264,acodec=mpga,vb=125k,ab=64k,deinterlace,scale=0.25,threads=2}:rtp{mux=ts,dst=192.168.2.99,port=4004}' &

# start streaming client
vlc rtp://192.168.3.20:4004 &

# start simulation
inet -u Cmdenv -f omnetpp.ini

# kill child processes
trap 'kill $(jobs -pr)' SIGINT SIGTERM EXIT

In the configuration in omnetpp.ini, the scheduler class is set to RealTimeScheduler so that the simulation can run in the real time of the host OS:

[General]
network = VideoStreamingShowcase
scheduler-class = "inet::RealTimeScheduler"
sim-time-limit = 225s

The hosts are configured to have an ExtUpperEthernetInterface, and to use the TAP devices which were created by the setup script. The setup script assigned IP addresses to the TAP interfaces; the EXT interfaces are configured to copy the addresses from the TAP interfaces:

*.host1.eth[0].typename = "ExtUpperEthernetInterface"
*.host1.eth[0].device = "tapa"
*.host1.eth[0].copyConfiguration = "copyFromExt"

*.host2.eth[0].typename = "ExtUpperEthernetInterface"
*.host2.eth[0].device = "tapb"
*.host2.eth[0].copyConfiguration = "copyFromExt"

The addresses in the network are important; the configurator is set to assign the correct addresses so the simulation and the script can work together (the VLC sends the video packets to the router, so its address needs to match as the destination address in the script):

*.configurator.config = xml("<config> \
                                <interface hosts='router' names='eth0' address='192.168.2.99' netmask='255.255.255.0'/> \
                                <interface hosts='router' names='eth1' address='192.168.3.99' netmask='255.255.255.0'/> \
                             </config>")

Also, the CRC and FCS need to be set to computed to be able to properly serialize/deserialize packets.

**.crcMode = "computed"
**.fcsMode = "computed"

Running/Results

Before running the emulation scenario, run setenv in the omnetpp and inet directories, and run the setup.sh script in the showcase’s folder:

$ cd ~/workspace/omnetpp
$ . setenv
$ cd ~/workspace/inet
$ . setenv
$ cd showcases/emulation/videostreaming
$ ./setup.sh

To start the simulation and the VLC instances, run the run.sh script:

$ ./run.sh

The script starts the simulation in Cmdenv; the streaming VLC client is also started in command line mode. The received video stream is played by the other VLC instance. The received video is lower quality than the original video file, because it’s downscaled, and the bitrate is reduced, so that the playback is smooth.

Note

Emulating the network is CPU-intensive. The downscaling and bitrate settings were chosen to lead to smooth playback on the PC we tested the showcase on. However, it might be able to work in higher quality on a faster machine; the user can experiment with different encoding settings for the VLC streaming instance by editing them in the run script.

Here are some of the packets captured in Wireshark:

../../../../_images/wireshark.png

Note that there are packets sent from the tapa (192.168.2.20) interface to the router’s eth0 (192.168.2.99) interface, and also packets sent from the router’s eth1 (192.168.3.99) interface to tapb (192.168.3.20).

Sources: omnetpp.ini, VideostreamingShowcaseNetwork.ned, run.sh, setup.sh, teardown.sh

Discussion

Use this page in the GitHub issue tracker for commenting on this showcase.