Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Wiki / PhantomNet / OEPC-Protected / sample-ns / smore-ns

smore-ns

SMORE topology NS file (from SMORE tutorial).
# NS file for instantiating an SMORE prototype setup.
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"

# Were to log the output of the startup command on each node
set OEPC_LOGFILE "/var/tmp/openepc_start.log"

# Set the type of hardware to use. "pc" is a generic x86-compatible machine.
set OEPC_HWTYPE "pc"

# 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.
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 net_d_mme an_lte offload"

# 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
    }
}

if {$num_clients < 1 || $num_clients > 2} {
    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_mme $sgw

# Create OVS node to interpose on net_d between enodeb nodes and the mme/sgw
set smore [$ns node]
tb-set-node-os $smore "PhantomNet/SMORE-SDN"
addtolan net_d $smore
addtolan net_d_mme $smore
addtolan offload $smore

# Offload server
set cloud [$ns node]
tb-set-node-os $cloud "UBUNTU12-64-STD"
addtolan offload $cloud

# Create the enodeb RAN node (Optional)
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]
    }
}

tb-set-ip-lan $smore $offload 192.168.10.10
tb-set-ip-lan $cloud $offload 192.168.10.11

# Go!
$ns run