Policy-controlled Video Streaming (pcvs) with APEX¶
Introduction¶
This module contains several demos for Policy-controlled Video Streaming (PCVS). Each demo defines a policy using AVRO and Javascript (or other scripting languages for the policy logic). To run the demo, a vanilla Ubuntu server with some extra software packages is required:
Mininet as network simulator
Floodlight as SDN controller
Kafka as messaging system
Zookeeper for Kafka configuration
APEX for policy control
Install Ubuntu Server and SW¶
Install Demo
Requirements:
Ubuntu server: 1.4 GB
Ubuntu with Xubuntu Desktop, git, Firefox: 2.3 GB
Ubuntu with all, system updated: 3 GB
With ZK, Kafka, VLC, Mininet, Floodlight, Python: 4.4 GB
APEX Build (M2 and built): M2 ~ 2 GB, APEX ~3.5 GB
APEX install (not build locally): ~ 300 MB
On a Ubuntu OS (install a stable or LTS server first)
# pre for Ubuntu, tools and X sudo apt-get -y install --no-install-recommends software-properties-common sudo apt-get -y install --no-install-recommends build-essential sudo apt-get -y install --no-install-recommends git sudo aptitude -y install --no-install-recommends xubuntu-desktop sudo apt-get -y install --no-install-recommends firefox # install Java sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get -y install --no-install-recommends oracle-java8-installer java -version # reboot system, run system update, then continue # if VBox additions are needed, install and reboot sudo (cd /usr/local/share; wget https://www.virtualbox.org/download/testcase/VBoxGuestAdditions_5.2.7-120528.iso) sudo mount /usr/local/share/VBoxGuestAdditions_5.2.7-120528.iso /media/cdrom sudo (cd /media/cdrom;VBoxLinuxAdditions.run) # update apt-get DB sudo apt-get update # if APEX is build from source, install maven and rpm sudo apt-get install maven rpm # install ZooKeeper sudo apt-get install zookeeperd # install Kafka (cd /tmp;wget http://ftp.heanet.ie/mirrors/www.apache.org/dist/kafka/1.0.0/kafka_2.12-1.0.0.tgz --show-progress) sudo mkdir /opt/Kafka sudo tar -xvf /tmp/kafka_2.12-1.0.0.tgz -C /opt/Kafka/ # install mininet cd /usr/local/src sudo git clone https://github.com/mininet/mininet.git (cd mininet;util/install.sh -a) # install floodlight, requires ant sudo apt-get install ant cd /usr/local/src sudo wget --no-check-certificate https://github.com/floodlight/floodlight/archive/master.zip sudo unzip master.zip cd floodlight-master sudo ant sudo mkdir /var/lib/floodlight sudo chmod 777 /var/lib/floodlight # install python pip sudo apt-get install python-pip # install kafka-python (need newer version from github) cd /usr/local/src sudo git clone https://github.com/dpkp/kafka-python sudo pip install ./kafka-python # install vlc sudo apt-get install vlcInstall APEX either from source or from a distribution package. See the APEX documentation for details. We assume that APEX is installed in
/opt/ericsson/apex/apex
Copy the LinkMonitor file to Kafka-Python
sudo cp /opt/ericsson/apex/apex/examples/scripts/pcvs/vpnsla/LinkMonitor.py /usr/local/src/kafka-pythonChange the Logback configuration in APEX to logic logging
(cd /opt/ericsson/apex/apex/etc; sudo cp logback-logic.xml logback.xml)Get the Demo Video
For all download options of the movie please visit http://bbb3d.renderfarming.net/download.html
For lower-res downloads and mirrors see https://peach.blender.org/download
sudo mkdir /usr/local/src/videosStandard 720p (recommended)
(cd /usr/local/src/videos; sudo curl -o big_buck_bunny_480p_surround.avi http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi)Full HD video
(cd videos; sudo curl -o bbb_sunflower_1080p_60fps_normal.mp4 http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4)
VPN SLA Demo¶
This demo uses a network with several central office and core switches, over which two VPNs are run. A customer
A
has two locationA1
andA2
and a VPN between them. A customerB
has two locationB1
andB2
and a VPN between them.The architecture above shows the scenario. The components are realized in this demo as follows:
CEP / Analytics - a simple Python script taking events from Kafka and sending them to APEX
APEX / Policy - the APEX engine running the VPA SLA policy
Controller - A vanilla Floodlight controller taking events from the Link Monitor and configuring Mininet
Network - A network created using Mininet
The demo requires to start some software (detailed below). To show actual video streams, we use
VLC
. If you do not want to show video streams, but only the policy, skip theVLC
section.All shown scripts are available in a full APEX installation in
$APEX_HOME/examples/scripts/pcvs/vpnsla
.Start all Software
Create environment variables in a file, say
env.sh
. In each new Xterm
Source these environment settings, e.g.
. ./env.sh
Run the commands below as root (
sudo
per command orsudo -i
for interactive mode as shown below)#!/usr/bin/env bash export src_dir=/usr/local/src export APEX_HOME=/opt/ericsson/apex/apex export APEX_USER=apexuserIn a new Xterm, start Floodlight
sudo -i . ./env.sh cd $src_dir/floodlight-master && java -jar target/floodlight.jarIn a new Xterm start Mininet
sudo -i . ./env.sh mn -c && python $APEX_HOME/examples/scripts/pcvs/vpnsla/MininetTopology.pyIn a new Xterm, start Kafka
sudo -i . ./env.sh /opt/Kafka/kafka_2.12-1.0.0/bin/kafka-server-start.sh /opt/Kafka/kafka_2.12-1.0.0/config/server.propertiesIn a new Xerm start APEX with the Kafka configuration for this demo
cd $APEX_HOME ./bin/apexApps.sh engine -c examples/config/pcvs/vpnsla/kafka2kafka.jsonIn a new Xterm start the Link Monitor. The Link Monitor has a 30 second sleep to slow down the demonstration. So the first action of it comes 30 seconds after start. Every new action in 30 second intervals.
sudo -i . ./env.sh cd $src_dir xterm -hold -e 'python3 $src_dir/kafka-python/LinkMonitor.py' &Now all software should be started and the demo is running. The Link Monitor will send link up events, picked up by APEX which triggers the policy. Since there is no problem, the policy will do nothing.
Create 2 Video Streams with VLC
In the Mininet console, type
xterm A1 A2
andxterm B1 B2
to open terminals on these nodes.
A2
andB2
are the receiving nodes. In these terminals, runvlc-wrapper
. In each opened VLC window do
Click Media → Open Network Stream
Give the URL as
rtp://@:5004
A1
andB1
are the sending nodes (sending the video stream) In these terminals, runvlc-wrapper
. In each opened VLC window do
Click Media → Stream
Add the video (from
/usr/local/src/videos
)Click
Stream
Click
Next
Change the destination
RTP / MPEG Transport Stream
and clickAdd
Change the address and type to
10.0.0.2
inA1
and to10.0.0.4
inB1
Turn off
Active Transcoding
(this is important to minimize CPU load)Click
Next
Click
Stream
The video should be streaming across the network from
A1
toA2
and fromB1
toB2
. If the video streams a slow or interrupted the CPU load is too high. In these cases either try a better machine or use a different (lower quality) video stream.Take out L09 and let the Policy do it’s Magic
Now it is time to take out the link
L09
. This will be picked up by the Link Monitor, which sends a new event (L09 DOWN) to the policy. The policy then will calculate which customer should be impeded (throttled). This will continue, until SLAs are violated, then a priority calculation will kick in (CustomerA
is prioritized in the setup).To initiate this, simply type
link s5 s6 down
in the Mininet console followed byexit
.If you have the video streams running, you will see one or the other struggeling, depending on the policy decision.
Reset the Demo
If you want to reset the demo, simple stop (in this order) the following process
Link Monitor
APEX
Mininet
Floodlight
Then restart them in this order
Floodlight
Mininet
APEX
Link Monitor
Monitor the Demo
Floodlight and APEX provide REST interfaces for monitoring.
Floodlight: see Floodlight Docs for details on how to access the monitoring. In a standard installation as we use here, pointing browser to the URL
http://localhost:8080/ui/pages/index.html
should work on the same hostAPEX please see the APEX documentation for Monitoring Client or Full Client for details on how to monitor APEX.
VPN SLA Policy¶
The VPN SLA policy is designed as a MEDA policy. The first state (M = Match) takes the trigger event (a link up or down) and checks if this is a change to the known topology. The second state (E = Establish) takes all available information (trigger event, local context) and defines what situation we have. The third state (D = Decide) takes the situation and selects which algorithm is best to process it. This state can select between
none
(nothing to do),solved
(a problem is solved now),sla
(compare the current customer SLA situation and select one to impede), andpriority
(impede non-priority customers). The fourth and final state (A = Act) selects the right action for the taken decision and creates the response event sent to the orchestrator.We have added three more policies to set the local context: one for adding nodes, one for adding edges (links), and one for adding customers. These policies do not realize any action, they are only here for updating the local context. This mechanism is the fasted way to update local context, and it is independent of any context plugin.
The policy uses data defined in Avro, so we have a number of Avro schema definitions.
Context Schemas¶
The context schemas are for the local context. We model edges and nodes for the topology, customers, and problems with all information on detected problems.
Trigger Schemas¶
The trigger event provides a status as
UP
orDOWN
. To avoid tests for these strings in the logic, we defined an Avro schema for an enumeration (AVRO Schema Link Status). This does not impact the trigger system (it can still send the strings), but makes the task logic simpler.
Context Logic Nodes¶
The node context logic simply takes the trigger event (for context) and creates a new node in the local context topology (Logic Node Context).
Context Logic Edges¶
The edge context logic simply takes the trigger event (for context) and creates a new edge in the local context topology (Logic Edge Context).
Context Logic Customer¶
The customer context logic simply takes the trigger event (for context) and creates a new customer in the local context topology (Logic Customer Context).
Logic: Match¶
This is the logic for the match state. It is kept very simple. Beside taking the trigger event, it also creates a timestamp. This timestamp is later used for SLA and downtime calculations as well as for some performance information of the policy . Sample Logic Policy Match State
Logic: Policy Establish State¶
This is the logic for the establish state. It is the most complicated logic, since establishing a situation for a decision is the most important part of any policy. First, the policy describes what we find (the switch block), in terms of 8 normal situations and 1 extreme error case.
If required, it creates local context information for the problem (if it is new) or updates it (if the problem still exists). It also calculates customer SLA downtime and checks for any SLA violations. Finally, it creates a situation object. Sample Logic Policy Establish State
Logic: Policy Decide State¶
The decide state can select between different algorithms depending on the situation. So it needs a Task Selection Logic (TSL). This TSL select a task in the current policy execution (i.e. potentially a different one per execution). Sample JS Logic Policy Decide State - TSL
The actual task logic are then
none
,solved
,sla
, andpriority
. Sample task logic are as given below :
Logic: Policy Act State¶
This is the logic for the act state. It is simply selecting an action, and creating the repsonse event for the orchestrator (the output of the policy). Sample Logic Policy Act State
CLI Spec¶
Complete Policy Definition
The complete policy definition is realized using the APEX CLI Editor. The script below shows the actual policy specification. All logic and schemas are included (as macro file). Sample APEX VPN SLA Policy Specification
Context Events Nodes¶
The following events create all nodes of the topology.
Context Events Edges¶
The following events create all edges of the topology.
Context Events Customers¶
The following events create all customers of the topology.
Trigger Examples¶
The following events are examples for trigger events
Link Monitor¶
The Link Monitor is a Python script. At startup, it sends the context events to APEX to initialize the topology and the customers. Then it takes events from Kafka and sends them to APEX. Sample Link Monitor
Mininet Topology¶
The topology is realized using Mininet. This script is used to establish the topology and to realize network configurations. Sample Mininet Topology