oepc-basic-ns
Basic OpenEPC setup NS file.
# Basic OpenEPC NS specification file. source tb_compat.tcl set ns [new Simulator] # OS to use on the nodes. This image must be one that has been prepared the way OpenEPC expects! set OEPC_OS "PhantomNet/UBUNTU12-64-BINOEPC" # What type of hardware to use for the nodes? "pc" means a generic x86-class machine. set OEPC_HWTYPE "pc" # 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" # Number of clients to allocate (currently, value can be 1 or 2) set num_clients 1 ############################################## # # Code to generate OpenEPC topology and set it up follows. # # Some top-level lists - don't change these directly unless you know what you are doing. set nodelist "" set clientlist "alice bob" # List of lans that nodes may be added to below. set lanlist "mgmt net_a net_b net_d an_lte" # Initialize lan membership lists array set lans {} foreach lan $lanlist { set lans($lan) "" } proc addtolan {lan node} { global lans lappend lans($lan) $node } 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 } } # Quick sanity check. if {$num_clients < 1 || $num_clients > [llength $clientlist]} { perror "num_clients must be between 1 and [llength $clientlist] (inclusive)!" exit 1 } # Create $num_clients client nodes for {set i 0} {$i < $num_clients} {incr i} { set clnode [lindex $clientlist $i] epcnode $clnode "epc-client" $clnode addtolan an_lte $clnode } # 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 # Create eNodeB (Mandatory) epcnode enb "enodeb" addtolan an_lte $enb addtolan net_d $enb # 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) * 0ms] } } # Go! $ns run