Commits

Anonymous committed a24d58a

Successfully add support of Csma Network. still three small bugs:
For ManualTopoNetExperiment --> topology net is no longer needed. clean it
Nix Vector Still has bug, this is the problem of NS3.14, may be change to NS3.15 can fix it
When running the algorithm for ddos_ping_flooding problem, may be problem of server address

  • Participants
  • Parent commits 09f321c

Comments (0)

Files changed (22)

File core/configure/API.py

 from Network import Network
-from Anomaly import AtypicalUserAnomaly, Anomaly, TargetOneServer
+from Anomaly import AtypicalUserAnomaly, Anomaly, TargetOneServer, AddModulatorAnomaly
 from MarkovAnomaly import MarkovAnomaly
 from MVAnomaly import MVAnomaly
 ##################################
 ano_map = {
         # 'ATYPICAL_USER':AtypicalUser,
         'atypical_user':AtypicalUserAnomaly,
+        'add_mod':AddModulatorAnomaly,
         'anomaly':Anomaly,
         'flow_arrival_rate':Anomaly,
         'flow_size_mean':Anomaly,

File core/configure/Anomaly.py

     nt = copy.deepcopy(t)
     new_num = list(copy.deepcopy(num))
     i = get_pos(t, b)
-    if i == -1 or i == len(t) - 1:
+
+    if i is None:
+        raise Exception('[insert_break_pt], maybe you have insert an anomaly in an unsuitable time? ')
+    elif i == -1 or i == len(t) - 1:
         return dur, num, i+1;
     else:
         nt.insert(i+1, b)
 
 
 import copy
-class Anomaly:
-    '''basis class for anomaly. Its subclass will provide run() method'''
+class Anomaly(object):
+    """basis class for anomaly. Its subclass will provide run() method
+    ano_desc:
+        **T**: start, end time for the anomaly
+        **change**: a dictionary specify how the attributes of the existing modules are
+            changed. the value is a string, if the first char is '=', it means change the attribute
+            to the value behind '='. If the first char is '+', it means add the attribute by
+            the value behind '+'. Likewise if the first char is 'x', it means multiply the attribute by
+            the value behind 'x'.
+            for example:
+                change = {'flow_size_mean':'x2', 'flow_arrival_rate':'=6', 'flow_size_var=+3'},
+            means: change the flow_size_mean to two times of the orginal value, change flow_arrival_rate
+            to be 6 and add the flow_size_var by 3.
+    """
     def __init__(self, ano_desc):
         self.ano_desc = ano_desc
         self.ano_node = None
         normal_profile_2 = ( tuple(d[i2:]), tuple(n[i2:]) )
         return normal_profile_1, abnormal_profile, normal_profile_2
 
-    def cut_profile(profile, status):
-        """cut into three pieces"""
+    # def cut_profile(profile, status):
+        # """cut into three pieces"""
 
     def _infect_modulator(self, ano_t, m_id, mod):
         ano_node = self.ano_node
                 profile=ap,
                 generator = [ self.new_generator ])
 
+        # export para to help to export ano flo
+        self._export_ano_flow_para(self.new_generator)
+
         # st = mod_start + float(np.sum(np1[0])) + float(np.sum(ap[0]))
         st = mod_start + float(sum(np1[0])) + float(sum(ap[0]))
         assert(st == end)
         del ano_node.modulator[m_id]
         del ano_node.generator[s_id]
 
-    def _export_ano_flow_para(self):
+    def _export_ano_flow_para(self, new_generator):
         """export para to help to export ano flows"""
-        ano_flow_para = copy.deepcopy(self.new_generator.para)
+        ano_flow_para = copy.deepcopy(new_generator.para)
         ano_flow_para['ano_type'] = self.ano_desc['anoType']
         pickle.dump(ano_flow_para, open(settings.EXPORT_ABNORMAL_FLOW_PARA_FILE, 'w')) # For export abnormal flows
 
         ano_t = self.ano_desc['T']
 
         m_back = copy.deepcopy(self.ano_node.modulator)
-        for m_id, mod in m_back.iteritems(): # For each modulator
+
+        for m_id, mod in m_back.iteritems(): # infect each modulator, change attribute by ratio
             self._infect_modulator(ano_t, m_id, mod)
 
-        self._export_ano_flow_para()
+class AddModulatorAnomaly(Anomaly):
+    """instead of changing parameters of existing modulators, simply add new modulators
+    ano_desc:
+        - **dst_nodes**: the destination node of the modulators, will add one modulator
+            for each dst_nodes
+        - **gen_desc**: the descriptor for the generator of the modulator
+        - **T**: a two element list or tuple, the start, end time for the anomaly.
+    """
+    def run(self, net):
+        self.ano_node = net.node_list[self.ano_desc['ano_node_seq']]
+        self.net = net
+        self._config_traffic()
+
+    def _config_traffic(self):
+        """add modulator to each srv"""
+        nn = len(self.net.node_list)
+        srv_node_list = [self.net.node_list[i] for i in xrange(nn) if i in self.ano_desc['dst_nodes'] ]
+        start, end = self.ano_desc['T']
+        for srv_node in srv_node_list:
+            gen_desc = Load(self.ano_desc['gen_desc'])
+            gen_desc['ipsrc'] = choose_ip_addr(self.ano_node.ipdests).rsplit('/')[0]
+            gen_desc['ipdst'] = choose_ip_addr(srv_node.ipdests).rsplit('/')[0]
+            self.ano_node.add_modulator(start=str(start),
+                    profile='((%d,),(1,))' %(end-start),
+                    generator=[get_generator(gen_desc)] )
 
 
 from Edge import NEdge
         start, end = self.ano_desc['T']
         for srv_node in srv_node_list:
             gen_desc = Load(self.ano_desc['gen_desc'])
-            gen_desc['ipsrc'] = choose_ip_addr(self.ano_node.ipdests)
-            gen_desc['ipdst'] = choose_ip_addr(srv_node.ipdests)
+            gen_desc['ipsrc'] = choose_ip_addr(self.ano_node.ipdests).rsplit('/')[0]
+            gen_desc['ipdst'] = choose_ip_addr(srv_node.ipdests).rsplit('/')[0]
             self.ano_node.add_modulator(start=str(start),
                     profile='((%d,),(1,))' %(end-start),
                     generator=get_generator(gen_desc) )

File core/configure/Generator.py

 
     def get_new_gen(self, change_para=None):
         new = copy.deepcopy(self)
-        if change_para:
-            for attr, ratio in change_para.iteritems():
+        if change_para is None:
+            return new
+
+        # change the parameters
+        for attr, ratio in change_para.iteritems():
+            if isinstance(ratio, str):
+                if change_para[0] is '=':
+                    new.para[attr.lower()] = ratio
+                elif change_para[0] is '+':
+                    new.para[attr.lower()] += ratio
+                elif change_para[0] is 'x':
+                    new.para[attr.lower()] *= ratio
+                else:
+                    raise Exception('unknown change parameter')
+            # for backward compatibility
+            elif isinstance(ratio, float) or isinstance(ratio, int):
                 new.para[attr.lower()] *= ratio
-            new.sync()
+        new.sync()
         return new
 
 class MVGenerator(HarpoonG):

File core/configure/Network.py

 from mod_util import GetIPAdress, FixQuoteBug
 
 from Address import Ipv4AddressHelper
+from util import get_net_addr, CIDR_to_subnet_mask
 
 node_map = {
         'NNode':NNode,
         self.mv = None
         # self.Node = node_init_handle
 
-        network = '10.0.7.0'
-        mask = '255.255.255.0'
-        base = '0.0.0.4'
+        # network = '10.0.7.0'
+        # mask = '255.255.255.0'
+        # base = '0.0.0.4'
+        # self.addr_helper = Ipv4AddressHelper(network, mask, base)
+
+    def _init_addr_helper(self):
+        """initialize the address helper"""
+        ipv4_net_addr_base = self.net_desc.get('ipv4_net_addr_base', '10.0.7.4/24')
+        addr, network, mask = CIDR_to_subnet_mask(ipv4_net_addr_base)
+        base = get_net_addr(addr, mask)
         self.addr_helper = Ipv4AddressHelper(network, mask, base)
 
     def init(self, net_desc, norm_desc):
         self.net_desc = net_desc
+        self._init_addr_helper()
         self.Node = node_map[self.net_desc['node_type']]
         self.norm_desc = norm_desc
         self._topo(self.net_desc['topo'])
         self._config_traffic()
 
+
+    # def _config_traffic(self):
+    #     """config the traffic of network"""
+    #     nn = len(self.node_list)
+    #     srv_node_list = [self.node_list[i] for i in xrange(nn) if i in self.net_desc['srv_list'] ]
+    #     for i in xrange(nn):
+    #         if i in self.net_desc['srv_list']:
+    #             continue
+    #         self.node_list[i].init_traffic(self.norm_desc, srv_node_list)
+
     def _config_traffic(self):
-        """config the traffic of network"""
-        nn = len(self.node_list)
-        srv_node_list = [self.node_list[i] for i in xrange(nn) if i in self.net_desc['srv_list'] ]
-        for i in xrange(nn):
-            if i in self.net_desc['srv_list']:
-                continue
-            self.node_list[i].init_traffic(self.norm_desc, srv_node_list)
+        """config the traffic of network, there will be
+        traffic for any combination of self.norm_desc['src_nodes']
+        and self.norm_desc['dst_Nodes']
+        """
+        dst_node_list = [self.node_list[i] for i in self.norm_desc['dst_nodes']]
+        for i in self.norm_desc['src_nodes']:
+            self.node_list[i].init_traffic(self.norm_desc, dst_node_list)
 
     def _topo(self, topo):
         """initialize the topology of the network"""
             self.add_node(node)
             # if self.mv: mv.MHarpoon(node)
 
+        def link_attr_list_to_map(l):
+            if isinstance(l, dict): # dirty code for backword compatibility
+                return l
+            attr_name = ['delay', 'capacity']
+            # han specify the format of the attribute
+            han = { 'delay':float,
+                    'capacity':int
+                    }
+            check_table = {
+                    'ms':1e-3,
+                    'kbps':1e3,
+                    'mbps':1e6,
+                    }
+            def convert_unit(val):
+                """convert unit of delay and capacity to second and bps, respectively
+                """
+                val = val.lower()
+                for k,v in check_table.iteritems():
+                    if k in val:
+                        return float(val.rsplit(k)[0]) * v
+
+            nl = [str(han[n](convert_unit(v))) for n, v in zip(attr_name, l)]
+            m = dict(zip(attr_name, nl))
+            m['weight'] = '10'
+            return m
+
         for i in xrange(n):
             for j in xrange(n):
-                # if topo[i, j]:
                 if topo[i][j]:
-                    edge = NEdge(self.node_list[i], self.node_list[j], self.net_desc['link_attr'])
+                    la_dft = self.net_desc['link_attr_default']
+                    link_attr_list = self.net_desc.get('link_attr', {}).get((i,j), la_dft)
+                    edge = NEdge(self.node_list[i],
+                            self.node_list[j],
+                            link_attr_list_to_map(link_attr_list))
                     self.assign_link_interface_ip(i, j)
                     self.add_edge(edge)
 
     def assign_link_interface_ip(self, i, j):
+        # if link_to_ip_map is defined and (i,j) is inside
+        print '(i, j), ', (i, j)
+        if_addr = self.net_desc.get('link_to_ip_map', {}).get((i,j), None)
+        if if_addr is not None:
+            if if_addr[0] is not '':
+                self.node_list[i].add_interface_addr(if_addr[0])
+            if if_addr[1] is not '':
+                self.node_list[j].add_interface_addr(if_addr[1])
+            return
         node_container = [self.node_list[i], self.node_list[j]]
         self.addr_helper.Assign(node_container)
         self.addr_helper.NewNetwork()
         for node in self.node_list:
             node.sync()
         Dot.write(self, fName)
-        FixQuoteBug(fName, float(self.net_desc['link_attr']['delay']))
+        # FixQuoteBug(fName, float(self.net_desc['link_attr']['delay']))
+        FixQuoteBug(fName)
 
     def InjectAnomaly(self, A):
         '''Inject Anomaly into the network. A is the one type Anomaly'''

File core/configure/Node.py

         res = []
         for state in para_list:
             s = Load(state)
-            s['ipsrc'] = choose_ip_addr(self.ipdests)
-            s['ipdst'] = choose_ip_addr(dst_node.ipdests)
+            s['ipsrc'] = choose_ip_addr(self.ipdests).rsplit('/')[0]
+            s['ipdst'] = choose_ip_addr(dst_node.ipdests).rsplit('/')[0]
             gen = get_generator(s)
             res.append(gen)
         return res
 
     def _gen_generator(self, ipdst):
         self.gen_desc = copy.deepcopy( self.states[self.cs] )
-        self.gen_desc['ipsrc'] = choose_ip_addr(self.ipdests)
-        self.gen_desc['ipdst'] = self.ipdst
+        self.gen_desc['ipsrc'] = choose_ip_addr(self.ipdests).rsplit('/')[0]
+        self.gen_desc['ipdst'] = self.ipdst.rsplit('/')[0]
         return get_generator(self.gen_desc)
 
     @property

File core/configure/__init__.py

-"""
-This module configures the normal traffic.
-"""
 from API import gen_anomaly_dot

File core/configure/mod_util.py

 
 
 
-import re
-def FixQuoteBug(fileName, delay=0.001):
-    """ There is a bug in pydot. when link attribute is < 1, pydot will automatically add quote to value
-    which is not desirable. This function try to fix that problem """
+# import re
+def FixQuoteBug(fileName):
+    """ There is a bug in pydot. when link attribute is < 1, pydot will automatically add quote
+    to value which is not desirable. This function try to fix that problem. delete
+    all the quotes in the link attribute"""
+    # fid = open(fileName, 'r')
+    # content = fid.read()
+    # content = re.sub('delay="[\d.]*"', 'delay='+str(delay), content)
+    # fid.close()
+    # fid = open(fileName, 'w')
+    # fid.write(content)
+    # fid.close()
     fid = open(fileName, 'r')
-    content = fid.read()
-    content = re.sub('delay="[\d.]*"', 'delay='+str(delay), content)
+    lines = fid.readlines()
     fid.close()
+    for i in xrange(len(lines)):
+        line = lines[i]
+        if '--' in line: # if it is link attribute line
+            newline = ''.join([c for c in line if c is not '"'])
+            lines[i] = newline
     fid = open(fileName, 'w')
-    fid.write(content)
+    fid.write(''.join(lines))
     fid.close()
 
 
+
+
 def ParseArg(string):
     # print '---before--'
     # print string

File core/ns3/DotConfig.py

     server_id_set = [  ]
     server_addr = [ ]
 
-    def __init__(self, f_name, trace_config):
+    def __init__(self, f_name):
         self._loadconfig(f_name)
-        self.__dict__.update(trace_config)
+        # self.__dict__.update(trace_config)
 
     def _loadconfig(self, config):
         self.graph = networkx.nx_pydot.read_dot(config)
             return [ip.strip('"') for ip in ipstr.rsplit(' ')]
 
         def find_addr_in_same_net(a, b):
+            """find the two addresses in the same network from the address list a and b
+            """
             # routing_prefix_len = lambda a: int(a.rsplit('/')[1]) if '/' in a else self.DEFAULT_ROUTING_PREFIX
             aug_routing_prefix_len = lambda a: a if '/' in a else (a + '/' + str(self.DEFAULT_ROUTING_PREFIX))
 
             def same_net(au, bu):
+                """return True if au and bu are in the same network"""
                 a_addr, a_net, a_mask = CIDR_to_subnet_mask(au)
                 b_addr, b_net, b_mask = CIDR_to_subnet_mask(bu)
+                # print 'a_net, ', a_net
+                # print 'b_net, ', b_net
                 return get_net(a_net, a_mask) == get_net(b_net, b_mask)
 
             for addr1, addr2 in itertools.product(a, b):
         for (src_nid, dst_nid), attr in self.link_attr.iteritems():
             src_ips = get_ips(src_nid)
             dst_ips = get_ips(dst_nid)
+            # print 'src_ips, ', src_ips
+            # print 'dst_ips, ', dst_ips
+            # import pdb;pdb.set_trace()
             res = find_addr_in_same_net(src_ips, dst_ips)
+            print 'res, ', res
             if not res:
-                raise Exception('there is no address for nodes in the same net')
+                raise Exception("The two nodes don't have two address in the same net, \
+                        maybe you specify the wrong ip address?")
             self.link_to_ip_map[(src_nid, dst_nid)] = res
 
         fid = open(fname, 'w')
 
         fid.write('link_attr = ' + pprint.pformat(self.link_attr, indent=4)+'\n')
         fid.write('link_to_ip_map = ' + pprint.pformat(self.link_to_ip_map, indent=4)+'\n')
-        fid.write("""
-pcap_nodes = %s
-pcap_links = %s
-botmaster_id_set = %s
-client_id_set = %s
-server_id_set = %s
-server_addr = %s"""%(self.pcap_nodes, self.pcap_links,
-        self.botmaster_id_set,
-        self.client_id_set,
-        self.server_id_set,
-        self.server_addr))
-        fid.close()
+#         fid.write("""
+# pcap_nodes = %s
+# pcap_links = %s
+# botmaster_id_set = %s
+# client_id_set = %s
+# server_id_set = %s
+# server_addr = %s"""%(self.pcap_nodes, self.pcap_links,
+#         self.botmaster_id_set,
+#         self.client_id_set,
+#         self.server_id_set,
+#         self.server_addr))
+#         fid.close()
         return self.link_attr, self.link_to_ip_map
 
     def export_inet(self, fname):

File core/ns3/NS3Config.py

 import settings
 from Node import ImalseNetnsSimNode
 from Topology import ManualTopologyNet
+from Topology import ComplexNet
 from DotConfig import DotConfig
 from util import Namespace
 import ns3
 
 from RandomVarLib import *
 
-class NS3Config(object):
+class BackgroundTrafficConfig(object):
     """config NS3 according to fs dot file"""
     TOPOLOGY_FILE = settings.ROOT + '/share/bg_topology.inet'
     TOPOLOGY_TYPE = 'Inet'
     NET_SETTINGS_FILE = settings.ROOT + '/share/bg_net_settings_tmp.py'
-    def __init__(self, dot_file, trace_config):
+    def __init__(self, dot_file, net):
         self.dot_file = dot_file
-        self.dot_config = DotConfig(self.dot_file, trace_config)
+        self.dot_config = DotConfig(self.dot_file)
         self.dot_config.export_inet(self.TOPOLOGY_FILE)
         self.dot_config.export_net_settings(self.NET_SETTINGS_FILE)
-
-    def load_net_settings(self):
-        s = {}
-        execfile(self.NET_SETTINGS_FILE, s)
-        return Namespace(s)
-
-    @staticmethod
-    def NodeCreator():
-        return ImalseNetnsSimNode()
-
-    def setup(self):
-        """set up the network"""
-        net_settings = self.load_net_settings()
-        self.net = ManualTopologyNet(
-                self.TOPOLOGY_FILE,
-                self.TOPOLOGY_TYPE,
-                self.NodeCreator,
-                net_settings,
-                routing_helper_list = self.routing_helper_list,
-                )
-        self.net.set_trace()
+        self.net = net
 
     def add_onoff_app(self, start_time, end_time, local, remote, on_time, off_time, data_rate, sport, dport):
         """add one ns3 onoff application to the network
         helper.SetAttribute("OnTime", ns3.RandomVariableValue(on_time.to_ns3()))
         helper.SetAttribute("OffTime", ns3.RandomVariableValue(off_time.to_ns3()))
 
+        print('local, ', local)
         local_node = self.net.search_node(local)
         helper.Install(local_node)
 
         helper.SetAttribute("StartTime", ns3.TimeValue(ns3.Time(str(start_time)+'s')))
         helper.SetAttribute("StopTime", ns3.TimeValue(ns3.Time(str(end_time)+'s')))
         remote_node = self.net.search_node(remote)
+        print('remote, ', remote)
         sinkHelper.Install (remote_node);
 
         print("""add an onoff application with

File core/ns3/NS3Config.py_back

+#!/usr/bin/env python
+""" Load the flowmax dot syntax flow description file.
+use on-off application to simulate the flows. All packets
+from one node during one segment of on-time are considered
+to belongs to the same flow.
+    **OnTime** is calcualted by *flow size / data rate*
+    **OffTime** is calculated by *1 / flow arrival rate*
+        (approximation, assume OnTime is small)
+"""
+from __future__ import division, print_function
+
+import settings
+from Node import ImalseNetnsSimNode
+from Topology import ManualTopologyNet
+from Topology import ComplexNet
+from DotConfig import DotConfig
+from util import Namespace
+import ns3
+from random import randint
+from RandomVariable import RV
+
+#####################################
+####              API            ####
+#####################################
+def TopologyNetBT(dot_file, trace_config, **kwargs):
+    """return a TopologyNet with Background traffic already configured
+        - **dotfile** is the path of dot configuration file relative to ROOT directory
+        - **trace_config** is a dictionary contains the trace and bot server client information
+    """
+    ns3_config = NS3Config(dot_file, trace_config)
+    # set other parameters
+    for k, v in kwargs.iteritems():
+        ns3_config.__dict__[k] = v
+
+    ns3_config.setup()
+    ns3_config.config_onoff_app()
+    return ns3_config.net
+
+def run_ns3(dot_file, trace_config, sim_time, visual):
+    """run ns3 simulation based on configuration in **dot_file** and **trace_flag**"""
+    if visual:
+        ns3.GlobalValue.Bind("SimulatorImplementationType",
+                ns3.StringValue("ns3::VisualSimulatorImpl"))
+
+    ns3.LogComponentEnable("OnOffApplication", ns3.LOG_LEVEL_INFO)
+    ns3.LogComponentEnable("OnOffApplication", ns3.LOG_LEVEL_INFO)
+
+    ns3_config = NS3Config(settings.ROOT + '/' + dot_file, trace_config)
+    ns3_config.setup()
+    ns3_config.config_onoff_app()
+    ns3.Simulator.Stop(ns3.Seconds(sim_time))
+    ns3.Simulator.Run()
+    ns3.Simulator.Destroy()
+
+##################################################################
+####    Not recommend to call functions in this part directly ####
+##################################################################
+def short_num_to_standard(s):
+    """change short text notation to standard numerica value"""
+    replace_map = {
+            'kbps':'1000',
+                }
+    for k, v in replace_map.iteritems():
+        s = s.replace(k, v)
+    return s
+
+from RandomVarLib import *
+
+class NS3Config(object):
+    """config NS3 according to fs dot file"""
+    TOPOLOGY_FILE = settings.ROOT + '/share/bg_topology.inet'
+    TOPOLOGY_TYPE = 'Inet'
+    NET_SETTINGS_FILE = settings.ROOT + '/share/bg_net_settings_tmp.py'
+    def __init__(self, dot_file, trace_config):
+        self.dot_file = dot_file
+        self.dot_config = DotConfig(self.dot_file, trace_config)
+        self.dot_config.export_inet(self.TOPOLOGY_FILE)
+        self.dot_config.export_net_settings(self.NET_SETTINGS_FILE)
+
+    def load_net_settings(self):
+        s = {}
+        execfile(self.NET_SETTINGS_FILE, s)
+        # return Namespace(s)
+        return s
+
+    @staticmethod
+    def NodeCreator():
+        return ImalseNetnsSimNode()
+
+    def setup(self):
+        """set up the network"""
+        net_settings = self.load_net_settings()
+        # self.net = ManualTopologyNet(
+        self.net = ComplexNet(
+                self.TOPOLOGY_FILE,
+                self.TOPOLOGY_TYPE,
+                self.NodeCreator,
+                net_settings,
+                routing_helper_list = self.routing_helper_list,
+                )
+        self.net.set_trace()
+
+    def add_onoff_app(self, start_time, end_time, local, remote, on_time, off_time, data_rate, sport, dport):
+        """add one ns3 onoff application to the network
+        """
+        # ignore the network prefix length if there is
+        if '/' in remote: remote = remote.rsplit('/')[0]
+        if '/' in local: local = local.rsplit('/')[0]
+
+        ### Install OnOff Application ###
+        socketType = "ns3::UdpSocketFactory"
+        # socketType = "ns3::TcpSocketFactory"
+        helper = ns3.OnOffHelper(socketType,
+                ns3.InetSocketAddress(remote, dport))
+
+        helper.SetAttribute("StartTime", ns3.TimeValue(ns3.Time(str(start_time)+'s')))
+        helper.SetAttribute("StopTime", ns3.TimeValue(ns3.Time(str(end_time)+'s')))
+
+        # helper.SetAttribute("Remote", ns3.AddressValue(ns3.Ipv4Address(remote)))
+        local_inet = ns3.InetSocketAddress(local, sport)
+        helper.SetAttribute("Local", ns3.AddressValue(local_inet))
+
+        helper.SetAttribute("DataRate", ns3.StringValue(str(data_rate) + 'b/s'))
+        helper.SetAttribute("OnTime", ns3.RandomVariableValue(on_time.to_ns3()))
+        helper.SetAttribute("OffTime", ns3.RandomVariableValue(off_time.to_ns3()))
+
+        local_node = self.net.search_node(local)
+        helper.Install(local_node)
+
+        ### Install Sink Application ####
+        sinkLocalAddress = ns3.Address(ns3.InetSocketAddress (ns3.Ipv4Address.GetAny (), dport))
+        sinkHelper = ns3.PacketSinkHelper(socketType, sinkLocalAddress)
+        helper.SetAttribute("StartTime", ns3.TimeValue(ns3.Time(str(start_time)+'s')))
+        helper.SetAttribute("StopTime", ns3.TimeValue(ns3.Time(str(end_time)+'s')))
+        remote_node = self.net.search_node(remote)
+        sinkHelper.Install (remote_node);
+
+        print("""add an onoff application with
+                start_time: %f
+                end_time: %f
+                local: %s,
+                remote: %s,
+                on_time: %s,
+                off_time: %s"""%(start_time, end_time, local, remote, on_time, off_time))
+
+    @staticmethod
+    def transform_para(flowsize, flowstart, ipsrc, ipdst, sport, dport, **argv):
+        """transform the parameter for generator desription to the NS3 onoff application parameters"""
+        # data_rate = StringValue('1kbps') # constant data rate
+        data_rate = 1000
+        on_time = RV(flowsize) / data_rate
+        off_time = RV(flowstart)
+        return ipsrc, ipdst, on_time, off_time, data_rate, eval(sport).next(), eval(dport).next()
+
+    def config_onoff_app(self):
+        """ config on off application according to the modulator profile"""
+        mod_prof = self.dot_config.load_mod_prof()
+        for node, mod_profs in mod_prof.iteritems(): # for each node
+            for start_time, end_time, num, generator in mod_profs: # for each modulator
+                gen = self.dot_config.get_gen(node, generator)
+                for i in xrange(num):
+                    self.add_onoff_app(start_time, end_time, *self.transform_para(**gen))
+
+if __name__ == "__main__":
+    run_ns3('res.dot', [], 3000, False)

File core/ns3/Topology.py

     """Load Topology File and Contruct the Network Accordingly"""
     routing_helper_list = {
             'static':0,
-            'nix':5,
-            # 'olsr':10,
+            # 'nix':5,
+            'olsr':10,
             }
     def __init__(self, _input, _format, NodeCreator, *args, **kwargs):
         self._input = _input
         return self.net_settings.link_attr.get(self.get_link_name(i), default)
 
     def set_trace(self):
-        for n in self.net_settings.pcap_nodes:
+        # for n in self.net_settings.pcap_nodes:
+        for n in self.net_settings['pcap_nodes']:
             self.p2p.EnablePcap(settings.ROOT + "/res/trace-node", ns3.NodeContainer(self.nodes.Get(n)), 0)
 
-        for l in self.net_settings.pcap_links:
+        # for l in self.net_settings.pcap_links:
+        for l in self.net_settings['pcap_links']:
             self.p2p.EnablePcap(settings.ROOT + "/res/trace-link", self.get_link_ndc(l))
 
     def get_link_ndc(self, i):
 
 
     def init_net_device(self, net_settings, *args, **kwargs):
-        """Initial the ip address and network devices"""
+        """Initial the ip address and network devices
+        """
         self.net_settings = net_settings
         totlinks = self.inFile.LinksSize()
         p2p = ns3.PointToPointHelper()
         ipic = [] #ip interface container
         for i in xrange(totlinks):
             ips = self.net_settings.link_to_ip_map.get(self.get_link_name(i), None)
+
+            # Use the default base when the ip address is not explictly specified,
+            # create new network for each p2p link
             if not ips:
                 # ipic.append( defaultAddressHelper.Assign(ndc[i]) )
                 ipic.append( defaultAddressHelper.Assign(self.get_link_ndc(i)) )
                 addressHelper.NewNetwork()
                 continue
 
+            # Assign ip address for node 1
             addr, netBase, mask = CIDR_to_subnet_mask(ips[0])
             net_addr = get_net_addr(addr, mask)
             addressHelper.SetBase(
                     )
             # ip1 = addressHelper.Assign(ns3.NetDeviceContainer(ndc[i].Get(0)))
             ip1 = addressHelper.Assign(ns3.NetDeviceContainer(self.get_link_ndc(i).Get(0)))
+            # self.get_link_ndc(i).Get(0).SetAddress(ns3.Ip)
 
+            # Assign ip address for node 2
             addr, netBase, mask = CIDR_to_subnet_mask(ips[1])
             net_addr = get_net_addr(addr, mask)
             addressHelper.SetBase(
             ipic.append((ip1, ip2))
 
         self.p2p = p2p
+        self.ipic = ipic
 
         # from ns.core import ofstream
         # _ascii = ofstream("wifi-ap.tr")
         # p2p.EnableAsciiAll("test")
 
-        self.ipic = ipic
+        return ipic
 
-        return ipic
+
+class ComplexNet(ManualTopologyNet):
+    """ Complex Network contains different types of Subnets.
+
+    For example, some parts is Csma Network, which some other parts is
+    PointToPoint Network.
+    """
+    def _modify_address_helper(self, addressHelper, cidr_addr):
+        """ modify the netbase, mask and and base of the address helper
+        """
+        addr, netBase, mask = CIDR_to_subnet_mask(cidr_addr)
+        netAddr = get_net_addr(addr, mask)
+        addressHelper.SetBase(
+                network=ns3.Ipv4Address(netBase),
+                mask = ns3.Ipv4Mask(mask),
+                base = ns3.Ipv4Address(netAddr),
+                )
+        return addressHelper
+
+    def init_link(self):
+        pass
+
+    def _initSubnet(self, type_, desc):
+        """ Initialize subnet in the complex network.
+
+        - **type_**: can be ['PointToPoint', 'Csma']
+        - **desc**: parameters for ['']
+        """
+        # defaultAddressHelper = self._get_address_helper(desc[''])
+        helperMap = {
+                'PointToPoint': ns3.PointToPointHelper,
+                'Csma': ns3.CsmaHelper,
+                }
+        helper = helperMap[type_]()
+        for nodes, ips in desc['IpMap'].iteritems():
+
+            # set channel attribute
+            channelAttribute = desc.get('ChannelAttribute', {}).get(nodes, desc.get('ChannelAttributeDefault', {}))
+            for attr, val in channelAttribute.iteritems():
+                helper.SetChannelAttribute(attr, ns.core.StringValue(val))
+
+            # set device attribute
+            deviceAttribute = desc.get('DeviceAttribute', {}).get(nodes, desc.get('DeviceAttributeDefault', {}))
+            for attr, val in deviceAttribute.iteritems():
+                helper.SetDeviceAttribute(attr, ns.core.StringValue(val))
+
+            # create node container with all nodes in the channel
+            channelContainer = ns3.NodeContainer()
+            for n in nodes:
+                # print('n : %i'%(n))
+                # print('nN : %i'%(self.nodes.GetN()))
+                channelContainer.Add(self.nodes.Get(n))
+
+            # create channel and correspondings NetDevices
+            self.netDevices[nodes] = helper.Install( channelContainer )
+
+            # assign Ip address for each net devices
+            addressHelper = ns3.Ipv4AddressHelper()
+            i = -1
+            for n, ip in zip(nodes, ips):
+                i += 1
+                addressHelper = self._modify_address_helper(addressHelper, ip)
+                print('address for node ', n, ' has bee assigned, ip, ', ip)
+                ip = addressHelper.Assign(ns3.NetDeviceContainer(self.netDevices[nodes].Get(i)))
+
+
+    def init_net_device(self, net_settings, *args, **kwargs):
+        self.net_settings = net_settings
+        self.netDevices = {}
+        for type_, desc in net_settings['nets'].iteritems():
+            self._initSubnet(type_, desc)
 
 
 def main():

File experiments/ManualTopoBTExperiment.py

 """
 from __future__ import print_function
 import settings
-from core.ns3.NS3Config import TopologyNetBT
+# from core.ns3.NS3Config import TopologyNetBT
+from core.ns3.NS3Config import BackgroundTrafficConfig
+from core.ns3.Topology import ComplexNet
 from experiments import experiment_factory
 from core.configure import gen_anomaly_dot
 import ns3
 
 zeros = lambda s:[[0 for i in xrange(s[1])] for j in xrange(s[0])]
 def get_inet_adj_mat(fname):
+    """ get the adjacent matrix from the topology.inet file.
+    """
     fid = open(fname, 'r')
     i = -1
     while True:
 
     return adj_mat
 
+import pprint
+import os
+def fix_fs_addr_prefix_bug(f_name):
+    """A fs node can either represent a real node or a network. If the addr in
+    node's ipdests is add prefix, then fs will automatically consider it as network.
+    However, the net_settings generated by Imalse GUI topology also use CIDR format.
+    To reduce ambiguity, delete all network length information in **link_to_ip_map**
+    """
+    s = {}
+    execfile(f_name, s)
+    new_link_to_ip_map = {}
+    for k, v in s.get('link_to_ip_map', {}).iteritems():
+        new_link_to_ip_map[k] = [val.rsplit('/')[0] for val in v]
+    s['link_to_ip_map'] = new_link_to_ip_map
+    new_f_name = os.path.dirname(f_name) + '/new_' + os.path.basename(f_name)
+    fid = open(new_f_name, 'w')
+    fid.close()
+    fid = open(new_f_name, 'a')
+    for k, v in s.iteritems():
+        if k.startswith('__'):
+            continue
+        fid.write('%s = '%(k))
+        pprint.pprint(v, stream=fid)
+    fid.close()
+    return new_f_name
+
 class ManualTopoBTExperiment(ManualTopoExperiment):
     """This is a extension of manual topology experiment which add background traffic
     to the network. """
-    DOT_FILE = settings.ROOT + '/net_config/ManualTopoBTTopology.dot'
-
     # routing protocol list, 'type':priority
     routing_helper_list = {
             'static':0,
         parser.add_option('--back_traf', dest="back_traf",
                 help='confgiuration files for back ground traffic',
                 )
+        parser.add_option('--dot_file', default='net_config/ManualTopoBTConf.dot',
+                help='the configured dot file')
 
-    def load_back_traf(self, **kwargs):
-        """load parameters for generating the background traffic. **kwargs** contains some
-        additional parameters"""
+
+
+    def load_para(self, f_name, encap=None, **kwargs):
+        """load parameters.
+
+        - **kwargs** contains some additional parameters
+        - **encap** is the additional operation done to the data, for example,
+            the default value encap=Namespace is to change parameters from dict
+            to Namespace class.
+        """
         s = kwargs
-        execfile(settings.ROOT + '/' + self.options.back_traf, s)
-        return Namespace(s)
+        execfile(f_name, s)
+        return s if encap is None else encap(s)
+
+    def get_config_net_desc(self):
+        """ get the network description parameters
+
+        It will load the network_settings file and
+
+        - the new format of net_settings for Imalse and fs configure module
+          are quite different. need to transform the net settigns parameters
+
+        # transform the net settings format file to fs configure format
+        # since the function of the generated dot file is just to provide behaviour
+        # of models.
+        # we don't need topology in the dot file to be exactly the same.
+        # we just need the ip address for each interface.
+
+        """
+        # topo = get_inet_adj_mat(settings.ROOT + '/' + self.options.topology_file)
+        # new_net_settings_file = fix_fs_addr_prefix_bug(settings.ROOT + '/' + self.options.net_settings)
+        new_net_settings_file = settings.ROOT + '/' + self.options.net_settings
+        net_desc= self.load_para(f_name=new_net_settings_file, encap=None)
+        net_desc['node_type'] = 'NNode'
+        net_desc['node_para'] = {}
+
+        net_desc['link_to_ip_map'] = {}
+        for type_, desc in net_desc['nets'].iteritems():
+            if type_ == 'PointToPoint':
+                net_desc['link_to_ip_map'].update(desc['IpMap'])
+            elif type_ == "Csma":
+                for nodes, ips in desc['IpMap'].iteritems():
+                    for i in xrange(len(nodes) - 1):
+                        net_desc['link_to_ip_map'].update({ (nodes[i], nodes[i+1]):(ips[i], ips[i+1]) })
+
+        pairs = net_desc['link_to_ip_map'].keys()
+        g_size = max(max(pairs)) + 1
+        topo = zeros((g_size, g_size))
+        for x, y in pairs:
+            topo[x][y] = 1
+        net_desc['topo'] = topo
+
+        return net_desc
 
     def load_exper_settings(self, ns):
         from util import CIDR_to_subnet_mask
         # botnet related configuration
-        self.server_id_set = ns.server_id_set
-        self.botmaster_id_set = ns.botmaster_id_set
-        self.client_id_set = ns.client_id_set
+        self.server_id_set = ns['server_id_set']
+        self.botmaster_id_set = ns['botmaster_id_set']
+        self.client_id_set = ns['client_id_set']
         # print('ns.server_addr', ns.server_addr)
 
         # parse the server address
-        if len(ns.server_addr) == 0:
+        if len(ns['server_addr']) == 0:
             self.SERVER_ADDR = ''
             self.NETWORK_BASE = ''
             self.IP_MASK = ''
         else:
-            self.SERVER_ADDR, self.NETWORK_BASE, self.IP_MASK = CIDR_to_subnet_mask(ns.server_addr[0]);
+            self.SERVER_ADDR, self.NETWORK_BASE, self.IP_MASK = CIDR_to_subnet_mask(ns['server_addr'][0]);
+
+
+    @staticmethod
+    def get_trace_config(net_settings):
+        """transform net_setting to trace config
+        """
+        # TODO generate netDesc, normalDesc
+        keys = ['pcap_links', 'pcap_nodes',
+                'server_id_set', 'botmaster_id_set', 'client_id_set',
+                'server_addr']
+        ns = dict.copy(net_settings)
+        return dict(elem for elem in ns.items() if elem[0] in keys)
 
     # @staticmethod
     def gen_back_traf_dot(self, net_settings):
         """generate background traffic dot file
         """
-        # TODO generate netDesc, normalDesc
-        def get_trace_config(net_settings):
-            """transform net_setting to trace config"""
-            keys = ['pcap_links', 'pcap_nodes',
-                    'server_id_set', 'botmaster_id_set', 'client_id_set',
-                    'server_addr']
-            ns = dict.copy(net_settings)
-            return dict(elem for elem in ns.items() if elem[0] in keys)
 
         # get back_traf parameter
-        topo = get_inet_adj_mat(settings.ROOT + '/' + self.options.topology_file)
-        back_traf = self.load_back_traf(
-                topo = topo,
-                srv_node_list = net_settings.server_id_set,
+        back_traf = self.load_para(
+                f_name = settings.ROOT + '/' + self.options.back_traf,
                 sim_t = self.options.simtime,
                 )
 
         # call the SADIT/Configure module to generate the dot file specifying the background
         # traffic pattern.
-        gen_anomaly_dot(back_traf.ANO_LIST, back_traf.NET_DESC, back_traf.NORM_DESC, self.DOT_FILE)
-        return self.DOT_FILE, get_trace_config(net_settings)
+        dot_file = settings.ROOT + '/' + self.options.dot_file
+        gen_anomaly_dot(
+                back_traf['ANO_LIST'],
+                self.get_config_net_desc(),
+                back_traf['NORM_DESC'],
+                # self.options.dot_file
+                dot_file
+                )
+        # return self.options.dot_file, self.get_trace_config(net_settings)
+        return dot_file, self.get_trace_config(net_settings)
 
     def setup(self):
         BaseClass.setup(self)
-        net_settings = self.load_net_settings()
+        # net_settings = self.load_net_settings()
+        net_settings = self.load_para(
+                f_name = settings.ROOT + '/' + self.options.net_settings,
+                )
         self.load_exper_settings(net_settings)
 
         # Generate dot file that describe the background traffic.
         dot_file, trace_config = self.gen_back_traf_dot(net_settings)
 
         ns3.LogComponentEnable("OnOffApplication", ns3.LOG_LEVEL_INFO)
-        self.net = TopologyNetBT(dot_file, trace_config,
-                routing_helper_list = self.routing_helper_list)
+        # self.net = TopologyNetBT(dot_file, trace_config,
+                # routing_helper_list = self.routing_helper_list)
+        self.net = ComplexNet(
+                # os.path.abspath(self.options.topology_file),
+                settings.ROOT + '/' + self.options.topology_file,
+                self.options.topology_type,
+                self.NodeCreator,
+                net_settings,
+                )
+
+        bg_cofig = BackgroundTrafficConfig(dot_file, self.net)
+        bg_cofig.config_onoff_app()
 
         self.net.set_trace()
         self._install_cmds(srv_addr = self.SERVER_ADDR)

File gui/imalse_config/net_settings.py

 ipv4_net_addr_base = '10.7.0.1/24'
 link_attr_default = ['2ms','5Mbps']
 link_to_ip_map = {
-	(0, 2):['', '10.20.30.1/24'],
+	(0, 2):['10.1.1.5/24', '10.20.30.1/24'],
 	(0, 3):['', '10.20.30.2/24'],
 	(0, 4):['', '10.20.30.3/24'],
 	(0, 5):['', '10.20.30.4/24'],
-	(1, 0):['10.200.1.1', ''],
+	(1, 0):['10.200.1.1/24', '10.200.1.3/24'],
 	(6, 0):['10.1.1.1/24', '10.20.30.9/24'],
-	(7, 6):['1.1.1.1/24', '60.70.80.1/24'],
-	(8, 6):['2.3.5.6/24', '10.0.0.1/24'],
-	(6, 9):['10.0.1.1/24', '5.6.8.9/24'],
+	(7, 6):['1.1.1.1/24', '2.3.5.10/24'],
+	(8, 6):['2.3.5.6/24', '1.1.1.10/24'],
+	(6, 9):['5.6.8.10/24', '5.6.8.9/24'],
 	(12, 0):['10.20.30.8/24', ''],
 	(11, 0):['10.20.30.7/24', ''],
 	(10, 0):['10.20.30.6/24', ''],

File gui/imalse_config/topology.inet

 14 1
-0	526.0	349.0
+0	529.0	380.0
 2	330.0	538.0
 3	545.0	545.0
 4	724.0	537.0

File net_config/aro_demo/net_settings.py

 ipv4_net_addr_base = '10.7.0.1/24'
 link_attr_default = ['2ms','5Mbps']
 link_to_ip_map = {
-	(0, 2):['', '10.20.30.1/24'],
+	(0, 2):['10.1.1.5/24', '10.20.30.1/24'],
 	(0, 3):['', '10.20.30.2/24'],
 	(0, 4):['', '10.20.30.3/24'],
 	(0, 5):['', '10.20.30.4/24'],
-	(1, 0):['10.200.1.1', ''],
+	(1, 0):['10.200.1.1/24', '10.200.1.3/24'],
 	(6, 0):['10.1.1.1/24', '10.20.30.9/24'],
-	(7, 6):['1.1.1.1/24', '60.70.80.1/24'],
-	(8, 6):['2.3.5.6/24', '10.0.0.1/24'],
-	(6, 9):['10.0.1.1/24', '5.6.8.9/24'],
+	(7, 6):['1.1.1.1/24', '2.3.5.10/24'],
+	(8, 6):['2.3.5.6/24', '1.1.1.10/24'],
+	(6, 9):['5.6.8.10/24', '5.6.8.9/24'],
 	(12, 0):['10.20.30.8/24', ''],
 	(11, 0):['10.20.30.7/24', ''],
 	(10, 0):['10.20.30.6/24', ''],

File net_config/aro_demo/new_net_settings.py

+server_id_set = []
+ipv4_net_addr_base = '10.7.0.1/24'
+client_id_set = []
+link_to_ip_map = {(0, 2): ['', '10.20.30.1'],
+ (0, 3): ['', '10.20.30.2'],
+ (0, 4): ['', '10.20.30.3'],
+ (0, 5): ['', '10.20.30.4'],
+ (1, 0): ['10.200.1.1', ''],
+ (6, 0): ['10.1.1.1', '10.20.30.9'],
+ (6, 9): ['10.0.1.1', '5.6.8.9'],
+ (7, 6): ['1.1.1.1', '60.70.80.1'],
+ (8, 6): ['2.3.5.6', '10.0.0.1'],
+ (10, 0): ['10.20.30.6', ''],
+ (11, 0): ['10.20.30.7', ''],
+ (12, 0): ['10.20.30.8', ''],
+ (13, 0): ['10.20.30.5', '']}
+pcap_links = []
+pcap_nodes = []
+server_addr = []
+link_attr = {}
+link_attr_default = ['2ms', '5Mbps']
+botmaster_id_set = []

File net_config/aro_demo/nf_net_settings.py

+Ipv4NetAddressBase = '10.7.0.1/24'
+link_attr_default = ['2ms','5Mbps']
+nets = {
+        'PointToPoint': {
+            'ChannelAttributeDefault':{'Delay':'2ms'},
+            'DeviceAttributeDefault':{'DataRate':'5Mbps'},
+            'IpMap': {
+                    (1, 0):['10.200.1.1/24', '10.200.1.3/24'],
+                    (6, 0):['10.1.1.1/24', '10.1.1.5/24'],
+                    (7, 6):['1.1.1.1/24', '2.3.5.10/24'],
+                    (8, 6):['2.3.5.6/24', '1.1.1.10/24'],
+                    (6, 9):['5.6.8.10/24', '5.6.8.9/24'],
+                },
+            'ChannelAttribute':{},
+            'DeviceAttribute':{},
+            },
+        'Csma': {
+            'ChannelAttributeDefault':{'Delay':'2ms', 'DataRate':'5Mbps'},
+            'IpMap': {
+                (0, 2, 3, 4, 5, 10, 11, 12, 13): [
+                    '10.20.30.9/24',
+                    '10.20.30.1/24',
+                    '10.20.30.2/24',
+                    '10.20.30.3/24',
+                    '10.20.30.4/24',
+                    '10.20.30.6/24',
+                    '10.20.30.7/24',
+                    '10.20.30.8/24',
+                    '10.20.30.5/24',
+                ]
+                },
+            'ChannelAttribute':{},
+            'DeviceAttribute':{},
+            },
+        }
+
+pcap_nodes = [  ]
+pcap_links = [  ]
+botmaster_id_set = [  ]
+client_id_set = [  ]
+server_id_set = [  ]
+server_addr = [  ]

File net_config/aro_demo/topology.inet

 14 1
-0	526.0	349.0
+0	529.0	380.0
 2	330.0	538.0
 3	545.0	545.0
 4	724.0	537.0

File net_config/back_traf.py

-""" This file will accept
-    **topo** and **srv_node_list** as parameters
+""" parameter required
+sim_t
 """
 #################################
-##   topology ##
-#################################
-link_attr = {'weight':'10', 'capacity':'10000000', 'delay':'0.01'} # link Attribute
-
-
-#################################
 ##   Parameter For Normal Case ##
 #################################
-sim_t = 8000
+# sim_t = 8000
 start = 0
 DEFAULT_PROFILE = ((sim_t,),(1,))
 
-
 # gen_desc = {'TYPE':'harpoon', 'flow_size_mean':'4e5', 'flow_size_var':'100', 'flow_arrival_rate':'0.5'}
-gen_desc = {'TYPE':'harpoon', 'flow_size_mean':'4e3', 'flow_size_var':'100', 'flow_arrival_rate':'1'}
+gen_desc = {'TYPE':'harpoon', 'flow_size_mean':'4e3', 'flow_size_var':'100', 'flow_arrival_rate':'0.5'}
 NORM_DESC = dict(
         TYPE = 'NORMAl',
         start = '0',
         node_para = {'states':[gen_desc]},
         profile = DEFAULT_PROFILE,
+        # there will be traffic from any combination of src_nodes
+        # and dst_nodes
+        # src_nodes = [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13],
+        # src_nodes = [0, 1, 2, 3, 4, 5, 7, 8, 10, 11, 12, 13],
+        # dst_nodes = [0, 1, 2, 3, 4, 5, 7, 8, 10, 11, 12, 13],
+        src_nodes = [0, 1, 2, 3, 4, 5, 7, 8],
+        dst_nodes = [0, 1, 2, 3, 4, 5, 7, 8],
         )
 
-ANO_LIST = []
+# ANOMALY_TIME = (1200, 1400)
+# ANO_DESC = {'anoType':'TARGET_ONE_SERVER',
+ANO_DESC = dict(
+        # anoType = 'anomaly',
+        anoType = 'add_mod',
+        ano_node_seq = 9,
+        T = (1000, 1300),
+        gen_desc = gen_desc,
+        dst_nodes = [1],
+        # change = {'flow_size_mean':2},
+        # change = {'flow_arrival_rate':3},
+        # change = gen_desc,
+        # change = {'flow_arrival_rate':6},
+        # srv_id = 1,
+        )
 
-NET_DESC = dict(
-        topo=topo,
-        # size=topo.shape[0],
-        size=len(topo),
-        srv_list=srv_node_list,
-        link_attr=link_attr,
-        node_type='NNode',
-        node_para={},
-        )
+ANO_LIST = [ANO_DESC]

File share/bg_net_settings_tmp.py

 ipv4_net_addr_base = '10.7.0.1/24'
 link_attr_default = ['2ms','5Mbps']
-link_attr = {   (0, 1): ['0.01s', '10000000bps'],
-    (0, 2): ['0.01s', '10000000bps'],
-    (0, 3): ['0.01s', '10000000bps'],
-    (0, 4): ['0.01s', '10000000bps'],
-    (0, 5): ['0.01s', '10000000bps'],
-    (0, 6): ['0.01s', '10000000bps'],
-    (6, 7): ['0.01s', '10000000bps'],
-    (8, 6): ['0.01s', '10000000bps'],
-    (9, 6): ['0.01s', '10000000bps'],
-    (10, 0): ['0.01s', '10000000bps'],
-    (11, 0): ['0.01s', '10000000bps'],
-    (12, 0): ['0.01s', '10000000bps'],
-    (13, 0): ['0.01s', '10000000bps']}
-link_to_ip_map = {   (0, 1): ('10.0.11.5/24', '10.0.11.4/24'),
-    (0, 2): ('10.0.7.4/24', '10.0.7.5/24'),
-    (0, 3): ('10.0.8.4/24', '10.0.8.5/24'),
-    (0, 4): ('10.0.9.4/24', '10.0.9.5/24'),
-    (0, 5): ('10.0.10.4/24', '10.0.10.5/24'),
-    (0, 6): ('10.0.12.5/24', '10.0.12.4/24'),
-    (6, 7): ('10.0.14.5/24', '10.0.14.4/24'),
-    (8, 6): ('10.0.15.4/24', '10.0.15.5/24'),
-    (9, 6): ('10.0.13.5/24', '10.0.13.4/24'),
-    (10, 0): ('10.0.16.4/24', '10.0.16.5/24'),
-    (11, 0): ('10.0.17.4/24', '10.0.17.5/24'),
-    (12, 0): ('10.0.18.4/24', '10.0.18.5/24'),
-    (13, 0): ('10.0.19.4/24', '10.0.19.5/24')}
-
-pcap_nodes = []
-pcap_links = []
-botmaster_id_set = []
-client_id_set = []
-server_id_set = []
-server_addr = []
+link_attr = {   (0, 1): ['0.002s', '5000000bps'],
+    (0, 2): ['0.002s', '5000000bps'],
+    (0, 6): ['0.002s', '5000000bps'],
+    (2, 3): ['0.002s', '5000000bps'],
+    (3, 4): ['0.002s', '5000000bps'],
+    (4, 5): ['0.002s', '5000000bps'],
+    (6, 7): ['0.002s', '5000000bps'],
+    (8, 6): ['0.002s', '5000000bps'],
+    (9, 6): ['0.002s', '5000000bps'],
+    (10, 5): ['0.002s', '5000000bps'],
+    (10, 11): ['0.002s', '5000000bps'],
+    (12, 11): ['0.002s', '5000000bps'],
+    (12, 13): ['0.002s', '5000000bps']}
+link_to_ip_map = {   (0, 1): ('10.200.1.3/24', '10.200.1.1/24'),
+    (0, 2): ('10.20.30.9/24', '10.20.30.1/24'),
+    (0, 6): ('10.1.1.5/24', '10.1.1.1/24'),
+    (2, 3): ('10.20.30.1/24', '10.20.30.2/24'),
+    (3, 4): ('10.20.30.2/24', '10.20.30.3/24'),
+    (4, 5): ('10.20.30.3/24', '10.20.30.4/24'),
+    (6, 7): ('1.1.1.10/24', '1.1.1.1/24'),
+    (8, 6): ('2.3.5.6/24', '2.3.5.10/24'),
+    (9, 6): ('5.6.8.9/24', '5.6.8.10/24'),
+    (10, 5): ('10.20.30.6/24', '10.20.30.4/24'),
+    (10, 11): ('10.20.30.6/24', '10.20.30.7/24'),
+    (12, 11): ('10.20.30.8/24', '10.20.30.7/24'),
+    (12, 13): ('10.20.30.8/24', '10.20.30.5/24')}

File share/bg_topology.inet

 5	0.000000	0.000000
 6	0.000000	0.000000
 7	0.000000	0.000000
-12	0	1
-13	0	1
-10	0	1
-11	0	1
+12	13	1
+12	11	1
+10	11	1
+10	5	1
 8	6	1
 9	6	1
 0	1	1
 0	2	1
-0	3	1
-0	4	1
-0	5	1
 0	6	1
+2	3	1
+3	4	1
+4	5	1
 6	7	1
+#!/usr/bin/env sh
+./sim -e ManualTopoBTExperiment --net_settings=net_config/aro_demo/nf_net_settings.py --topology_file=net_config/aro_demo/topology.inet --Simulator=Visual -s file_exfiltration