Skip to content. | Skip to navigation

Personal tools


You are here: Home / Wiki / PhantomNet / OEPC-Protected / Dual-SGW Setup in PhantomNet

Dual-SGW Setup in PhantomNet

Use custom config scripts to setup PhantomNet experiments with two SGWs



The default PhantomNet experiment provides a single SGW. However, an experimentor may want to create an experiment with multiple SGWs connected to the eNodeBs to have a more distributed data-plane setup. In this tutorial, we show how the custom OpenEPC configuration features of PhantomNet can be used to create an experiment with multiple (we use two) SGWs.


Step1: Modify the template ns file

We need to modify the default ns file to create an additional node for the extra SGW and also to provide customized configuration options to setup different OpenEPC components properly. You can find an example ns file here. The key additions to the ns files are shown below.

  • Provide locations of custom scripts (customize according to where you store yours):
  •     set MME_PRE_SCRIPT "/proj/PhantomNet/dual_sgw/"
        set SGW2_PRE_SCRIPT "/proj/PhantomNet/dual_sgw/"
        set PGW_PRE_SCRIPT "/proj/PhantomNet/dual_sgw/"
        set SGW2_POST_SCRIPT "/proj/PhantomNet/dual_sgw/"
  • Create the EPC components with custom configurations
  •     # Create the pgw node 
        epcnode pgw "pgw" {} $PGW_PRE_SCRIPT {} 
        # Create the sgw-mme-sgsn node 
        epcnode sgw "sgw-mme-sgsn" {} $MME_PRE_SCRIPT  {}
        # Create the second sgw node 
        epcnode sgw2 "any" {} $SGW2_PRE_SCRIPT $SGW2_POST_SCRIPT

Here the "*_PRE_*" scripts are used to install custom xml node configuartion files for the respective components. Please refer to the documentation for custom OpenEPC configuration for more details. Here is an example of the SGW2_PRE_SCRIPT used in the above example. Note that, for the second SGW node we provide the role "any" which ensures that PhantomNet does not create a specific role for the the node  initially. We use the "*_POST_*" script for the node to startup the SGW service in this node. Here is an example of the SGW2_POST_SCRIPT used in the above example.

  • Manually set the IP addresses for the second SGW node
#set IP for the SGW2 node manually
tb-set-ip-lan $sgw2 ${net-b}
tb-set-ip-lan $sgw2 ${net-d}

This addition is necessary because the custom SGW node is not one of the predefined OpenEPC roles.  Any custom node will similarly need to have its IP addresses manually specified in the appropriate range.  Please see the OpenEPC documentation for more information about the basic network layout.

Step 2: Create custom config files

Before we can execute our ns file, we need to create the custom xml files the EPC components will be using. As mentioned before, the "PRE" scripts are responsible for installation of the custom config files for the respective components. 

  • First, we need to create a configuration file for the second SGW. An example configuration can be found here. It is basically the same as the default sgw.xml file used in the canned version of the PhantomNet experiments with the IP addresses changed to match the second SGW node.
  • Second, now we need to chage the MME configuartion so that it can communicate with the second SGW. The only field we need to update is the "WharfAddressingWRR" to provide the address of the second SGW along with the default SGW as shown below. The MME code utilizes a weighted round-robin algorithm to select a SGW for a UE node during intial attachment procedure. The "WharfAddressingWRR" field is used to provide the list of available SGWs and their corresponding weights. 

                                        <!-- SGW1 -->
                                        <Address ip="" weight="1" />
                                        <!-- SGW2 -->
                                        <Address ip="" weight="1" />


  • Finally, in this example we use custom configuration files for the default SGW and the PGW as well to use IP-v4 addresses for all communications among EPC components. Note that, the canned version of the PhantomNet experiment uses IP-v6 between the SGW and the PGW. 

Step 3: Place the scripts and the configuartion files

The custom configuartion files and the Pre- and Post-hook scripts should be placed in a location such that the PhantomNet client-side start-up tools can access them. The recommended location is somewhere under your project's NFS-shared file space, i.e.: /proj/<your_project>/somedir. The files for this example are located in the /proj/PhantomNet/dual_sgw directory, but your directory path will be different.

Step 4: Execute

Now we are all set to create an experiment with the modified ns file. After the experiment is created, the MME will be connected to two SGWs. Now if we attach (using mm.connect_l3 LTE) the UEs alice and bob to the network, their data plane state will be created in different SGWs. One can ssh into the "sgw2" node and execute /opt/OpenEPC/bin/ to verify that the custom node is indeed executing the SGW process. Similarly, "/opt/OpenEPC/etc/emulab/ sgw" can be used to attach to the screen console of the running instance to monitor the execution steps. All other experimental nodes can be used in the same fashion as in the default PhantomNet experiments.