Commit cb401e5b authored by Binh Nguyen's avatar Binh Nguyen

Add ns file

parent 9c5df868
#
# NS file for instantiating an OpenEPC setup.
#
# Look for the variable definitions near the top to adjust the composition
# of the resultant OpenEPC system.
#
source tb_compat.tcl
set ns [new Simulator]
##############################################################################
#
# Variables you can tweak w/o necessarily understanding this NS file.
#
# OS to use on the nodes. This image must be one that has been prepared
# the way OpenEPC expects!
set OEPC_OS "UBUNTU12-64-OEPCR5"
# Were to log the output of the startup command on each node
set OEPC_LOGFILE "/var/tmp/openepc_start.log"
# Location of OpenEPC-in-Emulab startup script
set OEPC_SCRIPT "/usr/bin/sudo /opt/OpenEPC/bin/start_epc.sh"
# Set the type of node hardware to use. "pc" is a generic, real PC.
set OEPC_HWTYPE "d710"
# Set the link bandwidth. Note that "*" (meaning, use the fastest available
# native link speed) is incompatible with link encapsulation. Since link
# encapsulation is required for virtual nodes, this value has to be changed
# to something specific (e.g., 10Mb) if HWTYPE is set to "pcvm".
set OEPC_LINKBW "*"
# Allocate the enodeb node (and an_lte network)?
# If we allocate, then currently the number can be from 1 to 3.
set alloc_enodeb 1
set num_enodeb 1
# Allocate the epdg node (and an_wifi network)?
set alloc_epdg 0
# Allocate the angw node (and an_wimax network)?
set alloc_angw 0
# Allocate the nodeb node (and an_umts network)?
set alloc_nodeb 0
##############################################################################
#
# Code to generate OpenEPC topology and set it up follows.
#
# Various node lists (referenced by, or filled in by code below)
set nodelist ""
set enblist "enb1 enb2 enb3"
# List of lans that nodes may be added to below.
set lanlist "mgmt net_a net_b net_d an_lte an_umts an_wimax an_wifi"
# Initialize lan membership lists
array set lans {}
array set lanconf {}
foreach lan $lanlist {
set lans($lan) ""
set lanconf($lan) ""
}
proc addtolan {lan node {bw ""} {delay ""}} {
global lans
global lanconf
lappend lans($lan) $node
if {$bw != {} || $delay != {}} {
lappend lanconf($lan) [list $node $bw $delay]
}
}
proc epcnode {node {role ""} {hname ""} {prescr ""} {postscr ""}} {
global nodelist
global OEPC_OS OEPC_LOGFILE OEPC_SCRIPT OEPC_HWTYPE
uplevel "set $node \[\$ns node]"
lappend nodelist $node
tb-set-hardware $node $OEPC_HWTYPE
tb-set-node-os $node $OEPC_OS
tb-set-node-failure-action $node "nonfatal"
addtolan mgmt $node
if {$role != {}} {
set startcmd "$OEPC_SCRIPT -r $role"
if {$hname != {}} {
append startcmd " -h $hname"
}
if {$prescr != {}} {
append startcmd " -P $prescr"
}
if {$postscr != {}} {
append startcmd " -T $postscr"
}
append startcmd " >& $OEPC_LOGFILE"
tb-set-node-startcmd $node $startcmd
}
}
# Create the epc-enablers node (Mandatory)
epcnode epc "epc-enablers"
addtolan net_a $epc
# Create the pgw node (Mandatory)
epcnode pgw "pgw"
addtolan net_a $pgw
addtolan net_b $pgw
# Create the sgw-mme-sgsn node (Mandatory)
epcnode sgw "sgw-mme-sgsn"
addtolan net_b $sgw
addtolan net_d $sgw
# Add ip.access enodeb node #1
set penb1 [$ns node]
tb-fix-node $penb1 enodeb01
addtolan net_d $penb1
# Create the enodeb RAN node(s) (Optional)
if {$alloc_enodeb} {
# Check that num_enodeb isn't out of bounds.
if {$num_enodeb < 1 || $num_enodeb > [llength $enblist]} {
perror "num_enodeb must be between 1 and [llength $enblist] (inclusive)!"
exit 1
}
# Create the number of enodeb nodes requested.
for {set i 0} {$i < $num_enodeb} {incr i} {
set enbnode [lindex $enblist $i]
epcnode $enbnode "enodeb" $enbnode
addtolan an_lte $enbnode
addtolan net_d $enbnode
}
}
# Create the epdg RAN node (Optional)
if {$alloc_epdg} {
epcnode epdg "epdg"
addtolan an_wifi $epdg
addtolan net_b $epdg
}
# Create the angw RAN node (Optional)
if {$alloc_angw} {
epcnode angw "angw"
addtolan an_wimax $angw
addtolan net_b $angw
}
# Create the nodeb RAN node (Optional)
if {$alloc_nodeb} {
epcnode nodeb "nodeb"
addtolan an_umts $nodeb
addtolan net_d $nodeb
}
# Create all lans that have at least two members
foreach lan $lanlist {
# Since DNS doesn't officially allow underscores, we have to convert
# them to dashes in the names of the lans before instantiation.
set nslan [regsub -all -- "_" $lan "-"]
if {[llength $lans($lan)] > 1} {
set $nslan [ns make-lan $lans($lan) $OEPC_LINKBW 0ms]
# The default type of link encapsulation for virtual nodes
# (veth-ne) is antiquated and incompatible with modern XEN.
if {[string match -nocase "*vm*" $OEPC_HWTYPE]} {
tb-set-link-encap $nslan "vlan"
}
foreach nent $lanconf($lan) {
set node [lindex $nent 0]
set bw [lindex $nent 1]
set delay [lindex $nent 2]
if {$bw != {}} {
tb-set-node-lan-bandwidth $node $nslan $bw
}
if {$delay != {}} {
tb-set-node-lan-delay $node $nslan $delay
}
}
}
}
# Cut down on the number of nodes required in the topology by using
# end-node traffic shaping.
tb-use-endnodeshaping 1
# Go!
$ns run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment