Omnet - bwHPC Wiki Omnet - bwHPC Wiki

Omnet

From bwHPC Wiki
Jump to: navigation, search
Description Content
module load cae/omnet
Availability bwUniCluster
License OMNeT++ is free only for academic and non-profit use
Citing Credits | Inet-HNRL
Links OMNeT Homepage | Documentation
Graphical Interface Yes
Plugins GraphViz 2.38.0 | Doxygen 1.8.9.1 | Libpcap | INET 2.99.1 and 3.0.0 with Eclipse

1 Description

1.1 OMNet

OMNeT++ - Discrete Event Simulator is an extensible, modular, component-based C++ simulation library and framework, primarily for building network simulators.
"Network" is meant in a broader sense that includes wired and wireless communication networks, on-chip networks, queueing networks, and so on. Domain-specific functionality such as support for sensor networks, wireless ad-hoc networks, Internet protocols, performance modeling, photonic networks, etc., is provided by model frameworks, developed as independent projects. OMNeT++ offers an Eclipse-based IDE, a graphical runtime environment, and a host of other tools. There are extensions for real-time simulation, network emulation, database integration, SystemC integration, and several other functions.
OMNeT++ is an object-oriented modular discrete event network simulation framework. It has a generic architecture, so it can be (and has been) used in various problem domains:

  • modeling of wired and wireless communication networks
  • protocol modeling
  • modeling of queueing networks
  • modeling of multiprocessors and other distributed hardware systems
  • validating of hardware architectures
  • evaluating performance aspects of complex software systems
  • in general, modeling and simulation of any system where the discrete event approach is suitable, and can be conveniently mapped into entities communicating by exchanging messages.

What is OMNeT++?

1.2 Plugins

Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. It has important applications in networking, bioinformatics, software engineering, database and web design, machine learning, and in visual interfaces for other technical domains.

Doxygen is the de facto standard tool for generating documentation from annotated C++ sources, but it also supports other popular programming languages such as C, Objective-C, C#, PHP, Java, Python, IDL (Corba, Microsoft, and UNO/OpenOffice flavors), Fortran, VHDL, Tcl, and to some extent D.

Libpcap provides functions for user-level packet capture, used in low-level network monitoring. This package is known to build and work properly using an LFS-7.8 platform. libpcap provides functions for user-level packet capture, used in low-level network monitoring.

INET Framework is an open-source model library for the OMNeT++ simulation environment. It provides protocols, agents and other models for researchers and students working with communication networks. INET is especially useful when designing and validating new protocols, or exploring new or exotic scenarios.
INET contains models for the Internet stack (TCP, UDP, IPv4, IPv6, OSPF, BGP, etc.), wired and wireless link layer protocols (Ethernet, PPP, IEEE 802.11, etc), support for mobility, MANET protocols, DiffServ, MPLS with LDP and RSVP-TE signalling, several application models, and many other protocols and components.
Several other simulation frameworks take INET as a base, and extend it into specific directions, such as vehicular networks, overlay/peer-to-peer networks, or LTE.

2 Versions and Availability

A list of versions currently available on all bwHPC-C5-Clusters can be obtained from the
Cluster Information System CIS
On the command line interface of a particular bwHPC cluster a list of all available OMNeT versions can be inquired as followed:

$ module avail cae/omnet
------------------------ /opt/bwhpc/common/modulefiles -------------------------
cae/omnet/4.6           cae/omnet/4.6_inet3.0.0


3 Usage

3.1 Loading the Module

3.1.1 Default

You can load the default version of OMNeT with the command:

$ module load cae/omnet

3.1.2 Specific Version

If you wish to load a specific version of OMNeT you can do so by executing e.g.:

$ module load cae/omnet/4.6_inet3.0.0

to load the version 4.6 with the Inet 3.0.0 plugin.

3.2 Start commands

OMNeT doesn't supply a separate 'bin' folder.
All important binaries are located in the $OMNET_HOME directory.

$ ls -F $OMNET_HOME
abspath*       opp_configfilepath*  opp_run*                scavetool*
eventlogtool*  opp_lcg32_seedtool*  opp_runall*             splitvec*
nedtool*       opp_makedep*         opp_run_release*
omnest*        opp_makemake*        opp_shlib_postprocess*
omnetpp*       opp_msgc*            opp_test*

'*' indicates a binary (executable) file.

3.2.1 Command Line Version

If you wish to load a command line version of OMNeT, you can do so using 'module load 'cae/omnet/version' to load the version you desires. The program for the command line version is called 'opp_run'.
See example how to start an OMNeT simulation on bwHPC-Cluster.

3.2.2 GUI Version

After loading the OMNeT module, start the graphical user interface (GUI) with the command 'omnetpp &'.

$ omnetpp &
[1] 45880
$ Starting the OMNeT++ IDE...


Omnet gui.jpg

  • You must have a running X-Window server on your local system (X-forwarding).
  • Start the ssh-session with the option "-X" (ssh -X 'your-id'@bwunicluster.scc.kit.edu).


4 bwHPC Example for Serial Jobs with OMNeT

  • MPI is not implemented in the software OMNeT until now (2015).
  • The bwUniCluster doesn't support array-jobs, so we had to use another way to set up a serial job with OMNeT.

These are examples for the bwUniCluster only.

4.1 Moab Submit Script

This is an adapted version of the bwHPC example Moab submit-script (template).

#!/bin/bash
#MSUB -N mdns_sim_job
#MSUB -j oe
#MSUB -o $(JOBNAME).$(JOBID)
#MSUB -m a
#MSUB -q singlenode
#MSUB -M 'your E-Mail address'
#MSUB -l nodes=1:ppn=8
#MSUB -l mem=4000mb
#MSUB -l walltime=10:00:00
#
# NOTE: Param 1 MUST be Config and 2 must be the lower #RUN and 3 the upper #RUN
#
CONFIG=$1
L=$2
H=$3

start=$(date +%s)

echo " "
echo "### Setting up shell environment ..."
echo " "
if test -e "/etc/profile"; then source "/etc/profile"; fi;
if test -e "$HOME/.bash_profile"; then source "$HOME/.bash_profile"; fi;
unset LANG; export LC_ALL="C"; export MKL_NUM_THREADS=1; export OMP_NUM_THREADS=1
export USER=${USER:=`logname`}
export SLURM_JOB_ID=${SLURM_JOB_ID:=`date +%s`}
export SLURM_SUBMIT_DIR=${SLURM_SUBMIT_DIR:=`pwd`}
export SLURM_JOB_NAME=${SLURM_JOB_NAME:=`basename "$0"`}
export SLURM_JOB_NAME=$(echo "${SLURM_JOB_NAME}" | sed 's/[^a-zA-Z0-9._-]/_/g')

echo " "
echo "### Printing basic job infos to stdout ..."
echo " "
echo "START_TIME           = `date +'%y-%m-%d %H:%M:%S %s'`"
echo "HOSTNAME             = ${HOSTNAME}"
echo "USER                 = ${USER}"
echo "SLURM_JOB_NAME       = ${SLURM_JOB_NAME}"
echo "SLURM_JOB_ID         = ${SLURM_JOB_ID}"
echo "SLURM_SUBMIT_DIR     = ${SLURM_SUBMIT_DIR}"
echo "SLURM_NTASKS         = ${SLURM_NTASKS}"
echo "SLURM_NODELIST       = ${SLURM_NODELIST}"

echo "Working Directory:                    $PWD"
echo "Running on host                       $HOSTNAME"
echo "Job id:                               $MOAB_JOBID"
echo "Job name:                             $MOAB_JOBNAME"
echo "Number of nodes allocated to job:     $MOAB_NODECOUNT"
echo "Number of cores allocated to job:     $MOAB_PROCCOUNT"

# Make sure INET repo is in the Work Directory
if [ ! -d "${SLURM_SUBMIT_DIR}/inet" ]; then
  cp -R $OMNET_BASE_DIR/inet .
fi

INET_DIR="${SLURM_SUBMIT_DIR}/inet"

# Create Work Dir

echo " "
echo "### Creating JOB directory in WORKSPACE"
echo " "
JOB_WORK_DIR=$(ws_find mdns_sim)"/${SLURM_JOB_NAME}.uc1.${SLURM_JOB_ID%%.*}.$(date +%y%m%d_%H%M%S)"

echo "JOB_WORK_DIR = ${JOB_WORK_DIR}"

mkdir -vp "${JOB_WORK_DIR}"
cd "${JOB_WORK_DIR}"

# Load OMNET
module load cae/omnet/4.6_inet3.0.0
if test -z "$OMNET_HOME"; then
 echo "ERROR: Failed to load module 'cae/omnet/4.6_inet3.0.0'."
 exit 101
fi
echo "OMNET_BIN_DIR = $OMNET_HOME"
# Base dir needs to be self defined. Can be done in bash_rc
if test -z "$OMNET_BASE_DIR"; then  echo "ERROR: Omnet Base dir is not defined."
 exit 101
fi

# Load GCC4.9
module load compiler/gnu/4.9

module list

cp -R $HOME/repos/inet-dns-extension/src/networks/dynamic_wireless_mdns_network .
mv dynamic_wireless_mdns_network execution_network
cd execution_network

echo ''
echo "##############################"
echo "# Starting runs ${L} to ${H} #"
echo "##############################"

for K in $(seq ${L} ${H}); do
# Execute opp_run with runnumber $RUN and config $CONFIG
 CMD="opp_run -r ${K} -u Cmdenv -c ${CONFIG} -n ${INET_DIR}/src:${INET_DIR}/examples:${HOME}/repos/inet-dns-extension/src:. -l ${HOME}/repos/inet-dns-extension/src/inet_dns_extension --vector-recording=false --result-dir=\"${JOB_WORK_DIR}/execution_network/results/\" omnetpp.ini > RUN_${K}.txt";
 echo $CMD;
done | parallel --no-notice -j$MOAB_PROCCOUNT

if [ ! -d "results" ]; then
 echo "No resultdir"
fi

let RUNS=$H-$L+1
RES_FILE_COUNT=$(ls results/ | grep .sca | wc -l)
if [ $RES_FILE_COUNT -lt $RUNS ]; then
 echo "Not all runs ran through"
fi

echo " "
echo "### Compressing results and copying back result archive ..."
echo " "

mkdir -vp "${SLURM_SUBMIT_DIR}" # if user has deleted or moved the submit dir
echo "Creating result tgz-file '${JOB_WORK_DIR}.tgz' ..."
tar -zcvf "${JOB_WORK_DIR}.tgz" "${JOB_WORK_DIR}" \
  || { echo "ERROR: Failed to create tgz-file. Please cleanup TMP_WORK_DIR '$TMP_WORK_DIR' on host '$HOSTNAME' manually (if not done automatically by queueing system)."; exit 102; }

echo " "
echo "### Final cleanup: Remove TMP_WORK_DIR ..."
echo " "
rm -rvf "${JOB_WORK_DIR}"
echo "END_TIME             = `date +'%y-%m-%d %H:%M:%S %s'`"

end=$(date +%s)
echo " "
echo "### Calculate duration ..."
echo " "
diff=$[end-start]
if [ $diff -lt 60 ]; then
   echo "Runtime (approx.): '$diff' secs"
elif [ $diff -ge 60 ]; then
   echo 'Runtime (approx.): '$[$diff / 60] 'min(s) '$[$diff % 60] 'secs'
fi
  • parallel: build and execute shell command lines from standard input in parallel. See parallel manpage for more information ($ man parallel).
  • #MSUB -l nodes=1:ppn=8 is required. Only one node supported.
  • 'your-id' is your current user-id on the cluster. e.g.: kn_pop123456.

4.2 Job Script

  • This script runs a full configuration.
  • It determines the runs using opp_run -x $Config.
  • It submits the mdns_sim.moab job, which includes 16 runs to fully utilize a node which has 16 cores.
  • Every job is run independently and parallel.
  • An internal queue makes sure not to use too many resources (upper limit).

Usage: mdns_sim_control.sh <Network> <Config>

!/bin/bash
NETWORK=$1
CONFIG=$2
declare -i CURR_CONFIG
CURR_CONFIG=0
if [ "${#}" == "3" ]; then
 CURR_CONFIG=$3
fi 

# Queue variable. Currently no jobs are in the queue.
declare -i QUEUE
QUEUE=$(showq | grep "Total jobs" | sed -r "s/Total jobs:[ ]*([0-9]*)/\1/g")
UPPER_LIMIT_DAY=50 # Use up to 800 Cores on days
UPPER_LIMIT_NIGHT=50 # Use up to 1600 Cores on nights

# Job submission script
JOB_SUBMISSION_SCRIPT=$HOME/repos/inet-dns-extension/mdns_sim.moab
# Determine network dir
NETWORK_DIR=$HOME/repos/inet-dns-extension/src/networks/$NETWORK
echo "Using NETWORK_DIR ${NETWORK_DIR}"

cd $NETWORK_DIR
# load omnet, so we can run opp_run
module load cae/omnet/4.6_inet3.0.0
if test -z "$OMNET_HOME"; then
 echo "ERROR: Failed to load module 'cae/omnet/4.6_inet3.0.0'."
 exit 101
fi
echo "OMNET_BIN_DIR = $OMNET_HOME"
if test -z "$OMNET_BASE_DIR"; then # Base dir needs to be self defined. Can be done in bash_rc
 echo "ERROR: Omnet Base dir is not defined."
 exit 101
fi

# Use SED to get the amount of configs.
CONFIG_NUMBER=$(opp_run -x $CONFIG | sed -r -n 's/Number of runs: ([0-9]*)/\1/p')

echo "Number of Configs: ${CONFIG_NUMBER}"

# cd into workspace
WS_DIR="/work/workspace/scratch/'your-id'-mdns_sim-0"
cd $WS_DIR

echo "Switched to ${WS_DIR}"

# Outer control loop
let "SLEEP_TIME=60*15"
while true 
do
 declare -i UPPER_LIMIT
 h=$(date +%H)
 if [ $h -lt 8 -o $h -gt 20 ]; then
  UPPER_LIMIT=$UPPER_LIMIT_NIGHT
 else
  UPPER_LIMIT=$UPPER_LIMIT_DAY
 fi

 # Determine how many jobs are in the queue at the moment
 QUEUE=$(showq -v | grep 'your-id' | wc -l) 

 # First check if there are jobs done. 
 #for j in ${!JOB_IDS[@]}; do
 # # STATE="State: Completed "
 # STATE=$(checkjob ${JOB_IDS[$j]} | grep "^State:")
 # if [ "${STATE}" == "State: Completed " ]; then
 #  # this job is finished, remove from list
 #  echo "Job ${j} completed, removing from MAP."
 #  unset JOB_IDS[$j]
 #  let "QUEUE--" # Decrement the Queue
 # fi
 #done

 while [ $QUEUE -lt $UPPER_LIMIT ]
 do
  # Add jobs until we reach the upper limit.
  L=$CURR_CONFIG
  let H=$CURR_CONFIG+7
  if [ $H -gt $CONFIG_NUMBER ]; then
   H=$CONFIG_NUMBER
  fi

  let "QUEUE++"
  let "CURR_CONFIG+=8"
  #JOBID=$RANDOM
  JOBID=$(msub $JOB_SUBMISSION_SCRIPT $CONFIG $L $H)
  #JOB_IDS[$JOBID]=true # set some value, we actually just need the keys.
  echo "Added JOB: ${JOBID} for RUN ${L} to ${H}"
  sleep 10
 done
 
 if [ $CONFIG_NUMBER -lt $CURR_CONFIG ]; then
  # We are finished, jump out of the loop.
  echo "Finished running all jobs."
  break;
 fi 
 
 sleep $SLEEP_TIME; # Only check every 15 minutes if there is capacity available
done


5 OMNeT-Specific Environments

To see a list of all OMNeT environments set by the 'module load'-command use 'env | egrep -E *NET'. Or use the command 'module display cae/omnet'.

$ : Example Omnet and plugin Inet 3.0.0
$ module list
Currently Loaded Modulefiles:
  1) compiler/gnu/4.9            3) devel/python/3.4.1
  2) mpi/openmpi/1.6.5-gnu-4.9   4) cae/omnet/4.6_inet3.0.0
$ env | egrep -E *NET
OMNET_HOME=/opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/bin
OMNET_VERSION=4.6_inet3.0.0
OMNET_DOC_DIR=/opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/bin
INET_DOC_DIR=/opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/inet/doc
OMNET_EXA_DIR=/opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/samples
INET_EXA_DIR=/opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/inet/exampl


6 Version-Specific Information

For a more detailed information specific to a specific OMNeT version, see the information available via the module system with the command 'module help cae/omnet/version'.
For a small abstract what OMNeT is about use the command 'module whatis cae/omnet

$ module whatis cae/omnet
cae/omnet            : OMNeT++ is an extensible, modular, component-based
   C++ simulation library and framework, primarily for building network
   simulators. GUI-command 'omnetpp
$
$ module help cae/omnet
----------- Module Specific Help for 'cae/omnet/4.6_inet3.0.0' ---------------------------
  OMNeT++ is an extensible, modular, component-based C++ simulation library 
  and framework, primarily for building network simulators. 
  'Network' is meant in a broader sense that includes wired and wireless 
  communication networks, on-chip networks, queueing networks, and so on. 
  Domain-specific functionality such as support for sensor networks, 
[...]
  DOCUMENTATIONS 
  * OMNET 
     https://omnetpp.org/documentation (online)
     /opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/bin
  * GRAPHVIZ
     http://www.graphviz.org/Documentation.php (online)
  * PCAP/LIBPCAP
     http://eecs.wsu.edu/~sshaikot/docs/lbpcap/libpcap-tutorial.pdf (online)
  * INET FRAMEWORK
     https://inet.omnetpp.org/Introduction.html (online)
     /opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/inet/doc
    INET 3.0.0 release notes
     /opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/inet/WHATSNEW
	
  EXAMPLES
  * OMNET
     /opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/samples      
  * INET
     /opt/bwhpc/common/cae/omnet/4.6_inet3.0.0/inet/examples      
[...]