Anonymous avatar Anonymous committed 8500024

add more material to help webpage

Comments (0)

Files changed (52)

core/ns3/Node/ImalseNetnsSimNode.py

             msg = self.get_msg(packet)
         except:
             self.logger.error('Probably you are not using NS3 with imalse customaization?' +
-                    'Use deprec API with suppport only very limitted msgs')
+                    ' Use deprec API will suppport only very limitted msgs')
             msg = self.get_msg_deprec(packet)
 
         self.logger.debug('Node [%s] has receive message %s from sock [%s] and node [%s]'%(self.name, msg, sock, _from) )
             p = self.add_msg(p, data)
         except:
             self.logger.error('Probably you are not using NS3 with imalse customaization?' +
-                    'Use deprec API with suppport only very limitted msgs')
+                    ' Use deprec API will suppport only very limitted msgs')
             p = self.add_msg_deprec(p, data)
 
         self.after(self.sleep_delay, sock.Send, p)

core/ns3/Node_back.py

-#!/usr/bin/env python
-"""
-This file defined the for NS3 simulator.
-two types of nodes are defined:
-    1. **ImalseNetnsNode**, used for netns3 simulation.
-    2. **ImalseNetnsSimNode**, used for ns3 pure simulation.
-"""
-from core.BaseNode import BaseNode
-import sys
-
-from core.real import PhyNode
-from core.ns3.netns3 import NetnsNode
-class ImalseNetnsNode(NetnsNode, PhyNode):
-    """Imalse Netns Node, it will use linux namespace to construct virtual machine.
-    And applications will run in these virtual machines.
-    """
-    NODE_TYPE = 'real_ns3'
-    def __init__(self, *args, **kwargs):
-        self.cmd_set = None
-        NetnsNode.__init__(self, *args, **kwargs)
-        PhyNode.__init__(self)
-
-    def ping(self, sock, data, threaded=False):
-        dst = data['hostname'][0]
-        count = 3
-        cmd = ["ping", "-b", "-c", str(count), str(dst)]
-        print "%s: %s" % (self.name, " ".join(cmd))
-        p, stdin, stdout, stderr = self.popen(cmd)
-        err = stderr.read()
-        out = stdout.read()
-        sys.stderr.write(err)
-        sys.stdout.write(out)
-
-    def stop_ping(self, sock):
-        print 'stop_ping'
-
-nodenum = 0
-import ns3
-
-#############################################
-# NS3 python binding missing some important
-# APIs, MSG_MAP and MSG_RE_MAP are used
-# to hack the API. Need to be fixed later
-#############################################
-## Been Fixed at[2012-08-08 23:20:52], MSG_MAP and MSG_RE_MAP now becomes useless.
-
-MSG_MAP = {
-        'connect_ack': 21,
-        '{"password": ["1234"], "event": ["verify_master"]}':122,
-        '{"msg": ["verifed, hi master, what you want to do?"], "event": ["echo"]}':123,
-        '{"hostname": ["127.0.0.1"], "event": ["forward_to_bots"], "bot_event": ["send_ping"]}':124,
-        '{"event": ["file_exfiltration"]}':125,
-        '{"host": "thales.bu.edu", "password": "imalse", "user": "imalse-ftp", "event": "set_ftp_info"}':126,
-        '{"directory": ".", "pattern": "assword", "suffix": [".txt"], "event": "set_file_filter"}':127,
-        '{"event": "search_and_upload"}':128,
-        '{"hostname": ["127.0.0.1"], "event": ["send_ping"]}':129,
-        }
-MSG_RE_MAP = dict( [ (v,k) for k,v in MSG_MAP.iteritems() ] )
-
-def call_method(method, *args, **kwargs):
-    method(*args, **kwargs)
-
-class SocketDict(dict):
-    def __init__(self):
-        self.sockets = dict()
-        super(SocketDict, self).__init__()
-
-    def hash(self, sock):
-        node = sock.GetNode()
-        typeId = sock.GetTypeId()
-        _from = ns3.Address()
-        sock.GetSockName(_from)
-        return hash((node.GetId(), typeId.GetName(), str(_from), str(sock)))
-
-    def __getitem__(self, sock):
-        return super(SocketDict, self).__getitem__(self.hash(sock))
-
-    def __setitem__(self, sock, value):
-        super(SocketDict, self).__setitem__(self.hash(sock), value)
-        self.sockets[self.hash(sock)] = sock
-
-    def iteritems(self): #FIXME this is not iterator actually
-        return zip([self.sockets[k] for k in self.keys()] , self.values())
-
-    def items(self):
-        return zip([self.sockets[k] for k in self.keys()] , self.values())
-
-
-class ImalseNetnsSimNode(ns3.Node, BaseNode):
-    """Simulated Node in NS3 Adapted for Imalse Simulation"""
-    proto_map = {
-            'udp':ns3.UdpSocketFactory.GetTypeId(),
-            'tcp':ns3.TcpSocketFactory.GetTypeId(),
-            }
-    NODE_TYPE = 'sim_ns3'
-    name = 'ImalseNetnsSimNode'
-    def __init__(self, name=None, *args, **kwargs):
-        BaseNode.__init__(self)
-        if name is None:
-            global nodenum
-            self.name = "sim_n%s" %(nodenum)
-            nodenum += 1
-        else:
-            self.name = name
-
-        ns3.Node.__init__(self)
-        self.sockets = SocketDict()
-        self.sleep_delay = 0
-
-    @property
-    def client_socks(self):
-        return [sock for sock, v in self.sockets.iteritems() if v['type'] == 'client']
-
-    def create_sock(self, desc):
-        sock = ns3.Socket.CreateSocket(self, self.proto_map[desc['proto']])
-        self.logger.debug('node [%s] create sock [%s] with desc [%s]'%(self.name, str(sock), str(desc)))
-        self.sockets[sock] = desc
-        return sock
-
-    def after(self, t, method, *args, **kwargs):
-        """schedue a even after t seconds"""
-        def void_return_method(*args, **kwargs):
-            method(*args, **kwargs)
-        return ns3.Simulator.Schedule(ns3.Simulator.Now()+ns3.Seconds(t),
-                void_return_method,
-                *args,
-                **kwargs)
-
-    def bind(self, sock, addr_port):
-        self.logger.debug('Node [%s] start to bind to %s'%(self.name, addr_port) )
-        addr = self._search_server_addr(addr_port[0])
-        # import pdb;pdb.set_trace()
-        dst = ns3.InetSocketAddress (addr, addr_port[1])
-        # dst = ns3.InetSocketAddress (ns3.Ipv4Address('10.0.1.1'), addr_port[1])
-        sock.Bind(dst);
-        # sock.Bind();
-
-    def _search_server_addr(self, addr):
-        if addr:
-            return ns3.Ipv4Address(addr)
-        else:
-            return self.server_addr_set[0].GetLocal()
-
-    def listen(self, sock, backlog):
-        self.logger.debug('Node [%s] start to listen'%(self.name) )
-        sock.Listen()
-
-    def recv(self, sock, bufsize, dispatcher=None, threaded=False):
-        self.logger.debug('Node [%s] has set recv dispatcher [%s] for sock [%s]'%(self.name, dispatcher, str(sock)) )
-        sock.SetRecvCallback(dispatcher)
-        self.logger.debug('Node [%s] has finish set recv dispatcher for sock [%s]'%(self.name, str(sock)) )
-        sock.Recv()
-        self.logger.debug('sock.Recv finished')
-        # sock.Recv(bufsize, 0)
-
-    def dispatcher(self, sock):
-        """node level dispatcher, it will read data from the socket,
-        parse the data into approariate format and handle the data to
-        cmd.dispatcher()
-        """
-#FIXME this function was not exculated in pure simulation mode
-        # if self.name == "sim_n%s" %(2):
-            # import pdb;pdb.set_trace()
-
-        _from = ns3.Address()
-        packet = sock.RecvFrom (_from)
-        # import pdb;pdb.set_trace()
-        msg = self.get_msg(packet)
-        self.logger.debug('Node [%s] has receive message %s from sock [%s] and node [%s]'%(self.name, msg, sock, _from) )
-
-        if msg == 'connect_ack':
-            self.logger.debug('Node [%s] call self.recv_ack s'%(self.name) )
-            self.cmd_set.recv_ack()
-        else:
-            self.logger.debug('Node [%s] call cmd_set.dispatcher'%(self.name) )
-            self.cmd_set.dispatcher(sock, msg)
-
-        # self.recv(sock, 512, self.dispatcher)
-        self.after(0.1, self.recv, sock, 512, self.dispatcher)
-        # self.after(0, self.recv, sock, 512, self.dispatcher)
-
-    def sleep(self, t, call_back=None):
-        if call_back:
-            self.after(t, call_back)
-            return
-        self.sleep_delay = t #FIXME Just to Make Botmaster API Unchanged
-
-    def connect(self, sock, addr_port):
-        """Will set Connect callback function. If succeeded, self.recv will be called. otherwise
-        the sock will be closed"""
-        server_addr = self._search_server_addr(addr_port[0])
-        print 'server_addr, ', server_addr
-        print 'serval local, ', self.server_addr_set[0].GetLocal()
-        # import pdb;pdb.set_trace()
-        assert(str(server_addr) == str(self.server_addr_set[0].GetLocal()))
-        # import pdb;pdb.set_trace()
-
-        inetAddr = ns3.InetSocketAddress(
-                server_addr,
-                # self.server_addr_set[0].GetLocal(), # connect to first server
-                addr_port[1]
-                )
-
-        def connect_succeeded(sock):
-            self.logger.debug('Node [%s] connect succeeded'%(self.name) )
-            self.recv(sock, 512, self.dispatcher)
-
-        def connect_failed(sock):
-            self.logger.debug('Node [%s] connect failed'%(self.name) )
-            self.close_sock(sock)
-
-        sock.SetConnectCallback(connect_succeeded, connect_failed)
-        ret = sock.Connect(inetAddr)
-        # print 'ret, ', ret
-        # x = inetAddr.GetIpv4()
-        # from inspect import getmembers
-        # for a, b in getmembers(x): print a, b
-        # print sock
-        # print ns3.InetSocketAddress.IsMatchingType(inetAddr)
-        # ns3.TcpSocketFactory.GetTypeId()
-        # import pdb;pdb.set_trace()
-        # self.after(0, sock.Connect, inetAddr)
-        # import pdb;pdb.set_trace()
-
-    @staticmethod
-    def get_msg(p):
-        """get message from the pacetk"""
-        h = ns3.ImalseHeader()
-        p.RemoveHeader(h)
-        msg = h.GetData()
-        return msg
-
-    @staticmethod
-    def add_msg(p, msg):
-        """add message to pacekt"""
-        h = ns3.ImalseHeader()
-        h.SetData(msg)
-        p.AddHeader(h)
-        return p
-
-    @staticmethod
-    def get_msg_deprec(p):
-        """get_msg and add_msg are two hack function"""
-        print 'p.GetSize(), ', p.GetSize()
-        # import pdb;pdb.set_trace()
-        return MSG_RE_MAP[p.GetSize()]
-        # return MSG_RE_MAP[21]
-
-    @staticmethod
-    def add_msg_deprec(p, msg):
-        """encode the message to the packet"""
-        msg_id = MSG_MAP.get(msg, None) # FIXME use padding length to present msg, a wordround for python bug
-        if not msg_id:
-            raise Exception('Unknown Message %s'%(msg))
-        # p.AddPaddingAtEnd(msg_id)
-        # FIXME due to the bug of pyviz, we cannot AddPading to existing packets, instead
-        # a new packet is created
-        p2 = ns3.Packet(msg_id)
-        return p2
-        # if data == "connect_ack":
-            # tag = ConnectACKTag()
-        # p.AddPacketTag(tag)
-
-    def send(self, sock, data):
-        self.logger.debug('Node [%s] send data [%s] on socket [%s]'%(self.name, str(data), str(sock)) )
-        p = ns3.Packet()
-        p = self.add_msg(p, data)
-        self.after(self.sleep_delay, sock.Send, p)
-        # self.after(self.sleep_delay, self.send, sock, data)
-        # value = sock.Send(p)
-        # self.logger.debug('Node [%s] send out [%i] bytes'%(self.name, value) )
-        # if value == -1:
-            # raise Exception('Fail in Send traffic')
-        self.sleep_delay = 0
-
-    def stop(self):
-        pass
-
-    ####################################
-    ##    File System              #####
-    ####################################
-    def get_file_list(self, *args, **kwargs):
-        return ['pesudo_file.txt']
-
-    def load_file(self, *args, **kwargs):
-        return 'password'
-
-
-    def ftp_upload(self, f, host, user, password):
-        print 'File [%s] has been uploaded to ftp %s'%(f, host)
-
-    ####################################
-    ##    File System              #####
-    ####################################
-    def ping(self, sock, data, threaded):
-        print 'ImalseNetnsSimNode.ping: this is just a stub, please finish it'
-
Add a comment to this file

doc/build/doctrees/API.doctree

Binary file modified.

Add a comment to this file

doc/build/doctrees/environment.pickle

Binary file modified.

Add a comment to this file

doc/build/doctrees/index.doctree

Binary file modified.

Add a comment to this file

doc/build/html/.doctrees/API.doctree

Binary file modified.

Add a comment to this file

doc/build/html/.doctrees/environment.pickle

Binary file modified.

Add a comment to this file

doc/build/html/.doctrees/index.doctree

Binary file modified.

doc/build/html/API.html

         <li class="right" style="margin-right: 10px">
           <a href="genindex.html" title="General Index"
              accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="index.html">imalse 0.0 alpha documentation</a> &raquo;</li> 
       </ul>
     </div>  
 <dl class="method">
 <dt id="core.CMD.dispatcher">
 <tt class="descname">dispatcher</tt><big>(</big><em>sock</em>, <em>data</em><big>)</big><a class="headerlink" href="#core.CMD.dispatcher" title="Permalink to this definition">¶</a></dt>
-<dd><p>data may contain on or more command
+<dd><p>data may contain one or more command
 Args:</p>
 <blockquote>
 <div><ul>
 <dl class="method">
 <dt id="core.CMD.start">
 <tt class="descname">start</tt><big>(</big><big>)</big><a class="headerlink" href="#core.CMD.start" title="Permalink to this definition">¶</a></dt>
-<dd><p>start the command set</p>
+<dd><p>start the command set, execuate the <em>start_action</em> specifed in <strong>desc</strong></p>
 </dd></dl>
 
 </dd></dl>
 <dl class="class">
 <dt id="core.BaseNode.BaseNode">
 <em class="property">class </em><tt class="descclassname">core.BaseNode.</tt><tt class="descname">BaseNode</tt><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode" title="Permalink to this definition">¶</a></dt>
-<dd><p>Virtual Base Class For all nodes</p>
+<dd><p>Virtual Base Class For all nodes
+All Type of Nodes Should Implment API in this abstract first</p>
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.accept">
+<tt class="descname">accept</tt><big>(</big><em>sock</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.accept"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.accept" title="Permalink to this definition">¶</a></dt>
+<dd><p>accept from the <strong>sock</strong>, will return the accepted socket</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.bind">
+<tt class="descname">bind</tt><big>(</big><em>sock</em>, <em>port</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.bind"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.bind" title="Permalink to this definition">¶</a></dt>
+<dd><p>bind <strong>sock</strong> to <strong>port</strong></p>
+</dd></dl>
+
+<dl class="attribute">
+<dt id="core.BaseNode.BaseNode.client_socks">
+<tt class="descname">client_socks</tt><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.client_socks"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.client_socks" title="Permalink to this definition">¶</a></dt>
+<dd><p>all sockets whose type is client</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.close">
+<tt class="descname">close</tt><big>(</big><em>sock</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.close"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.close" title="Permalink to this definition">¶</a></dt>
+<dd><p>close the <strong>sock</strong></p>
+</dd></dl>
+
 <dl class="method">
 <dt id="core.BaseNode.BaseNode.close_socks">
 <tt class="descname">close_socks</tt><big>(</big><em>socks_seq_set</em>, <em>_type='client'</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.close_socks"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.close_socks" title="Permalink to this definition">¶</a></dt>
-<dd><p>sock_seq_set is the sequence of socks in this type of sock</p>
+<dd><p><strong>sock_seq_set</strong> is the sequence of socks in this type of sock.
+for example, if _type = &#8216;client&#8217;, socks_seq_set = [0], then the first
+client sock need to be closed.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.connect">
+<tt class="descname">connect</tt><big>(</big><em>sock</em>, <em>addr_port</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.connect"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.connect" title="Permalink to this definition">¶</a></dt>
+<dd><p>connect the <strong>sock</strong> to the server with address and port specfied by
+<strong>addr_port</strong></p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.create_sock">
+<tt class="descname">create_sock</tt><big>(</big><em>desc</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.create_sock"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.create_sock" title="Permalink to this definition">¶</a></dt>
+<dd><p>create_sock with parameter specified by <strong>desc</strong>, <strong>desc</strong> can be the
+address and port it tries to connect and the type of the connection</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.listen">
+<tt class="descname">listen</tt><big>(</big><em>sock</em>, <em>backlog</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.listen"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.listen" title="Permalink to this definition">¶</a></dt>
+<dd><p>listen to the <strong>sock</strong>. <strong>backlog</strong> is the max number of connection
+it can maintain</p>
+</dd></dl>
+
+<dl class="attribute">
+<dt id="core.BaseNode.BaseNode.now">
+<tt class="descname">now</tt><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.now"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.now" title="Permalink to this definition">¶</a></dt>
+<dd><p>get current time, either simulation time or real time.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.ping">
+<tt class="descname">ping</tt><big>(</big><em>sock</em>, <em>data</em>, <em>threaded=False</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.ping"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.ping" title="Permalink to this definition">¶</a></dt>
+<dd><p>send ping traffic using <strong>sock</strong> and the server information is
+stored in <strong>data</strong>. A new thread will be created if the <strong>threaded</strong>
+is true</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.recv">
+<tt class="descname">recv</tt><big>(</big><em>sock</em>, <em>bufsize</em>, <em>dispatcher</em>, <em>threaded=False</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.recv"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.recv" title="Permalink to this definition">¶</a></dt>
+<dd><p>receive some data from <strong>sock</strong>,
+- <strong>bufsize</strong> is the max size for the buffer.
+- <strong>dispatecher</strong> is a function handler that will manipulate the data
+- <strong>threaded</strong> if it is true a new thread wiill be created to avoid</p>
+<blockquote>
+<div>blocking the main process. Only real node suppport this. in sim
+Node and netns3 node, threading is not allowed.</div></blockquote>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.send">
+<tt class="descname">send</tt><big>(</big><em>sock</em>, <em>data</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.send"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.send" title="Permalink to this definition">¶</a></dt>
+<dd><p>set <strong>data</strong> from sock.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.sendto">
+<tt class="descname">sendto</tt><big>(</big><em>sock</em>, <em>data</em>, <em>addr</em>, <em>port</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.sendto"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.sendto" title="Permalink to this definition">¶</a></dt>
+<dd><p>send <strong>data</strong> from <strong>sock</strong> to <strong>addr</strong> and <strong>port</strong>, use UDP
+protocol</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.set_master_sock">
+<tt class="descname">set_master_sock</tt><big>(</big><em>sock</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.set_master_sock"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.set_master_sock" title="Permalink to this definition">¶</a></dt>
+<dd><p>set the <strong>sock</strong> to be the master sock. If a sock is master sock,
+then node will for commands from the master socks</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.sleep">
+<tt class="descname">sleep</tt><big>(</big><em>t</em>, <em>call_back=None</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.sleep"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.sleep" title="Permalink to this definition">¶</a></dt>
+<dd><p>sleep the node for a <strong>t</strong> seconds, if <strong>call_back</strong> is specified,
+it will be called after node wake from sleep</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.start">
+<tt class="descname">start</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.start" title="Permalink to this definition">¶</a></dt>
+<dd><p>start the node</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.BaseNode.BaseNode.stop_app">
+<tt class="descname">stop_app</tt><big>(</big><em>sock</em>, <em>app_name</em><big>)</big><a class="reference internal" href="_modules/core/BaseNode.html#BaseNode.stop_app"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.BaseNode.BaseNode.stop_app" title="Permalink to this definition">¶</a></dt>
+<dd><p>stop the app run on <strong>sock</strong> with app_name</p>
 </dd></dl>
 
 </dd></dl>
 <h2>Simulation<a class="headerlink" href="#simulation" title="Permalink to this headline">¶</a></h2>
 <div class="section" id="topology-mode">
 <h3>Topology Mode<a class="headerlink" href="#topology-mode" title="Permalink to this headline">¶</a></h3>
+<dl class="class">
+<dt id="core.ns3.Topology.TopologyReader">
+<em class="property">class </em><tt class="descclassname">core.ns3.Topology.</tt><tt class="descname">TopologyReader</tt><big>(</big><em>fileName=None</em>, <em>NodeCreator=&lt;type 'network.Node'&gt;</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyReader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.TopologyReader" title="Permalink to this definition">¶</a></dt>
+<dd><p>base class for Topology Reader</p>
+</dd></dl>
+
+<dl class="class">
+<dt id="core.ns3.Topology.InetTopologyReader">
+<em class="property">class </em><tt class="descclassname">core.ns3.Topology.</tt><tt class="descname">InetTopologyReader</tt><big>(</big><em>fileName=None</em>, <em>NodeCreator=&lt;type 'network.Node'&gt;</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#InetTopologyReader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.InetTopologyReader" title="Permalink to this definition">¶</a></dt>
+<dd><p>reader for <a href="#id1"><span class="problematic" id="id2">`inet topology generator file&lt;http://topology.eecs.umich.edu/inet/&gt;`_</span></a></p>
+</dd></dl>
+
+<dl class="class">
+<dt id="core.ns3.Topology.TopologyReaderHelper">
+<em class="property">class </em><tt class="descclassname">core.ns3.Topology.</tt><tt class="descname">TopologyReaderHelper</tt><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyReaderHelper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.TopologyReaderHelper" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<span class="target" id="module-core.ns3.Topology"></span><p>This is python implementation of NS3 topology-reader module
+pybindgen is far from mature and cannot generate usable python binding
+for this module, so I simply reimplement it in python.</p>
+<dl class="class">
+<dt>
+<em class="property">class </em><tt class="descclassname">core.ns3.Topology.</tt><tt class="descname">InetTopologyReader</tt><big>(</big><em>fileName=None</em>, <em>NodeCreator=&lt;type 'network.Node'&gt;</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#InetTopologyReader"><span class="viewcode-link">[source]</span></a></dt>
+<dd><p>reader for <a href="#id3"><span class="problematic" id="id4">`inet topology generator file&lt;http://topology.eecs.umich.edu/inet/&gt;`_</span></a></p>
+</dd></dl>
+
+<dl class="class">
+<dt id="core.ns3.Topology.ManualTopologyNet">
+<em class="property">class </em><tt class="descclassname">core.ns3.Topology.</tt><tt class="descname">ManualTopologyNet</tt><big>(</big><em>_input</em>, <em>_format</em>, <em>NodeCreator</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#ManualTopologyNet"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.ManualTopologyNet" title="Permalink to this definition">¶</a></dt>
+<dd><p>Topology network with manual ip settings</p>
+<dl class="method">
+<dt id="core.ns3.Topology.ManualTopologyNet.init_net_device">
+<tt class="descname">init_net_device</tt><big>(</big><em>net_settings</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#ManualTopologyNet.init_net_device"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.ManualTopologyNet.init_net_device" title="Permalink to this definition">¶</a></dt>
+<dd><p>Initial the ip address and network devices</p>
+</dd></dl>
+
+</dd></dl>
+
+<dl class="class">
+<dt id="core.ns3.Topology.TopologyNet">
+<em class="property">class </em><tt class="descclassname">core.ns3.Topology.</tt><tt class="descname">TopologyNet</tt><big>(</big><em>_input</em>, <em>_format</em>, <em>NodeCreator</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.TopologyNet" title="Permalink to this definition">¶</a></dt>
+<dd><p>Load Topology File and Contruct the Network Accordingly</p>
+<dl class="method">
+<dt id="core.ns3.Topology.TopologyNet.init_link">
+<tt class="descname">init_link</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet.init_link"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.TopologyNet.init_link" title="Permalink to this definition">¶</a></dt>
+<dd><p>Construct Point to Point Link in the Network</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.ns3.Topology.TopologyNet.init_net_device">
+<tt class="descname">init_net_device</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet.init_net_device"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.TopologyNet.init_net_device" title="Permalink to this definition">¶</a></dt>
+<dd><p>Initial the ip address and network devices</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.ns3.Topology.TopologyNet.install_stack">
+<tt class="descname">install_stack</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet.install_stack"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.TopologyNet.install_stack" title="Permalink to this definition">¶</a></dt>
+<dd><p>Install Internet Stack</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.ns3.Topology.TopologyNet.load_file">
+<tt class="descname">load_file</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet.load_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#core.ns3.Topology.TopologyNet.load_file" title="Permalink to this definition">¶</a></dt>
+<dd><p>Load Topology File</p>
+</dd></dl>
+
+</dd></dl>
+
+<dl class="class">
+<dt>
+<em class="property">class </em><tt class="descclassname">core.ns3.Topology.</tt><tt class="descname">TopologyReader</tt><big>(</big><em>fileName=None</em>, <em>NodeCreator=&lt;type 'network.Node'&gt;</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyReader"><span class="viewcode-link">[source]</span></a></dt>
+<dd><p>base class for Topology Reader</p>
+</dd></dl>
+
+<dl class="class">
+<dt>
+<em class="property">class </em><tt class="descclassname">core.ns3.Topology.</tt><tt class="descname">TopologyNet</tt><big>(</big><em>_input</em>, <em>_format</em>, <em>NodeCreator</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet"><span class="viewcode-link">[source]</span></a></dt>
+<dd><p>Load Topology File and Contruct the Network Accordingly</p>
+<dl class="method">
+<dt>
+<tt class="descname">init_link</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet.init_link"><span class="viewcode-link">[source]</span></a></dt>
+<dd><p>Construct Point to Point Link in the Network</p>
+</dd></dl>
+
+<dl class="method">
+<dt>
+<tt class="descname">init_net_device</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet.init_net_device"><span class="viewcode-link">[source]</span></a></dt>
+<dd><p>Initial the ip address and network devices</p>
+</dd></dl>
+
+<dl class="method">
+<dt>
+<tt class="descname">install_stack</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet.install_stack"><span class="viewcode-link">[source]</span></a></dt>
+<dd><p>Install Internet Stack</p>
+</dd></dl>
+
+<dl class="method">
+<dt>
+<tt class="descname">load_file</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/core/ns3/Topology.html#TopologyNet.load_file"><span class="viewcode-link">[source]</span></a></dt>
+<dd><p>Load Topology File</p>
+</dd></dl>
+
+</dd></dl>
+
 </div>
 <div class="section" id="netns3-mode">
 <h3>Netns3 Mode<a class="headerlink" href="#netns3-mode" title="Permalink to this headline">¶</a></h3>
 <p>This section contains the functions for NS3 support.</p>
+<dl class="class">
+<dt id="core.ns3.Experiment.ImalseExperiment">
+<em class="property">class </em><tt class="descclassname">core.ns3.Experiment.</tt><tt class="descname">ImalseExperiment</tt><a class="headerlink" href="#core.ns3.Experiment.ImalseExperiment" title="Permalink to this definition">¶</a></dt>
+<dd><p>Base class for all ImalseExperiment</p>
+<dl class="method">
+<dt id="core.ns3.Experiment.ImalseExperiment.get_node">
+<tt class="descname">get_node</tt><big>(</big><em>i</em><big>)</big><a class="headerlink" href="#core.ns3.Experiment.ImalseExperiment.get_node" title="Permalink to this definition">¶</a></dt>
+<dd><p>get ith nodes</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.ns3.Experiment.ImalseExperiment.node_run">
+<tt class="descname">node_run</tt><big>(</big><em>node</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#core.ns3.Experiment.ImalseExperiment.node_run" title="Permalink to this definition">¶</a></dt>
+<dd><p>run a command on a specific node</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.ns3.Experiment.ImalseExperiment.print_srv_addr">
+<tt class="descname">print_srv_addr</tt><big>(</big><big>)</big><a class="headerlink" href="#core.ns3.Experiment.ImalseExperiment.print_srv_addr" title="Permalink to this definition">¶</a></dt>
+<dd><p>print out the address of the server</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.ns3.Experiment.ImalseExperiment.start_nodes">
+<tt class="descname">start_nodes</tt><big>(</big><big>)</big><a class="headerlink" href="#core.ns3.Experiment.ImalseExperiment.start_nodes" title="Permalink to this definition">¶</a></dt>
+<dd><p>specify when each node should start</p>
+</dd></dl>
+
+</dd></dl>
+
 </div>
 <div class="section" id="pure-simulation-mode">
 <h3>Pure Simulation Mode<a class="headerlink" href="#pure-simulation-mode" title="Permalink to this headline">¶</a></h3>
+<dl class="class">
+<dt id="core.ns3.Node.ImalseNetnsSimNode">
+<em class="property">class </em><tt class="descclassname">core.ns3.Node.</tt><tt class="descname">ImalseNetnsSimNode</tt><big>(</big><em>name=None</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#core.ns3.Node.ImalseNetnsSimNode" title="Permalink to this definition">¶</a></dt>
+<dd><p>Simulated Node in NS3 Adapted for Imalse Simulation</p>
+<dl class="staticmethod">
+<dt id="core.ns3.Node.ImalseNetnsSimNode.add_msg">
+<em class="property">static </em><tt class="descname">add_msg</tt><big>(</big><em>p</em>, <em>msg</em><big>)</big><a class="headerlink" href="#core.ns3.Node.ImalseNetnsSimNode.add_msg" title="Permalink to this definition">¶</a></dt>
+<dd><p>add message to pacekt</p>
+</dd></dl>
+
+<dl class="staticmethod">
+<dt id="core.ns3.Node.ImalseNetnsSimNode.add_msg_deprec">
+<em class="property">static </em><tt class="descname">add_msg_deprec</tt><big>(</big><em>p</em>, <em>msg</em><big>)</big><a class="headerlink" href="#core.ns3.Node.ImalseNetnsSimNode.add_msg_deprec" title="Permalink to this definition">¶</a></dt>
+<dd><p>encode the message to the packet</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.ns3.Node.ImalseNetnsSimNode.after">
+<tt class="descname">after</tt><big>(</big><em>t</em>, <em>method</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#core.ns3.Node.ImalseNetnsSimNode.after" title="Permalink to this definition">¶</a></dt>
+<dd><p>schedue a even after t seconds</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.ns3.Node.ImalseNetnsSimNode.connect">
+<tt class="descname">connect</tt><big>(</big><em>sock</em>, <em>addr_port</em><big>)</big><a class="headerlink" href="#core.ns3.Node.ImalseNetnsSimNode.connect" title="Permalink to this definition">¶</a></dt>
+<dd><p>Will set Connect callback function. If succeeded, self.recv will be called. otherwise
+the sock will be closed</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="core.ns3.Node.ImalseNetnsSimNode.dispatcher">
+<tt class="descname">dispatcher</tt><big>(</big><em>sock</em><big>)</big><a class="headerlink" href="#core.ns3.Node.ImalseNetnsSimNode.dispatcher" title="Permalink to this definition">¶</a></dt>
+<dd><p>node level dispatcher, it will read data from the socket,
+parse the data into approariate format and handle the data to
+cmd.dispatcher()</p>
+</dd></dl>
+
+<dl class="staticmethod">
+<dt id="core.ns3.Node.ImalseNetnsSimNode.get_msg">
+<em class="property">static </em><tt class="descname">get_msg</tt><big>(</big><em>p</em><big>)</big><a class="headerlink" href="#core.ns3.Node.ImalseNetnsSimNode.get_msg" title="Permalink to this definition">¶</a></dt>
+<dd><p>get message from the pacetk</p>
+</dd></dl>
+
+<dl class="staticmethod">
+<dt id="core.ns3.Node.ImalseNetnsSimNode.get_msg_deprec">
+<em class="property">static </em><tt class="descname">get_msg_deprec</tt><big>(</big><em>p</em><big>)</big><a class="headerlink" href="#core.ns3.Node.ImalseNetnsSimNode.get_msg_deprec" title="Permalink to this definition">¶</a></dt>
+<dd><p>get_msg and add_msg are two hack function</p>
+</dd></dl>
+
+</dd></dl>
+
+<dl class="class">
+<dt id="core.ns3.Experiment.ImalsePureSimExperiment">
+<em class="property">class </em><tt class="descclassname">core.ns3.Experiment.</tt><tt class="descname">ImalsePureSimExperiment</tt><a class="headerlink" href="#core.ns3.Experiment.ImalsePureSimExperiment" title="Permalink to this definition">¶</a></dt>
+<dd><p>Pure Sim Experiemtn Doesn&#8217;t depend on netns3 can run in simulated time</p>
+<dl class="staticmethod">
+<dt id="core.ns3.Experiment.ImalsePureSimExperiment.event">
+<em class="property">static </em><tt class="descname">event</tt><big>(</big><em>time</em>, <em>func</em>, <em>*args</em>, <em>**kwds</em><big>)</big><a class="headerlink" href="#core.ns3.Experiment.ImalsePureSimExperiment.event" title="Permalink to this definition">¶</a></dt>
+<dd><p>schedule an event to simulator</p>
+</dd></dl>
+
+</dd></dl>
+
 <div class="toctree-wrapper compound">
 <ul class="simple">
 </ul>
         <li class="right" style="margin-right: 10px">
           <a href="genindex.html" title="General Index"
              >index</a></li>
+        <li class="right" >
+          <a href="py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="index.html">imalse 0.0 alpha documentation</a> &raquo;</li> 
       </ul>
     </div>
Add a comment to this file

doc/build/html/_images/ImalseCMD.png

Added
New image

doc/build/html/_modules/core.html

         <li class="right" style="margin-right: 10px">
           <a href="../genindex.html" title="General Index"
              accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="index.html" accesskey="U">Module code</a> &raquo;</li> 
       </ul>
         <li class="right" style="margin-right: 10px">
           <a href="../genindex.html" title="General Index"
              >index</a></li>
+        <li class="right" >
+          <a href="../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="index.html" >Module code</a> &raquo;</li> 
       </ul>

doc/build/html/_modules/core/BaseNode.html

         <li class="right" style="margin-right: 10px">
           <a href="../../genindex.html" title="General Index"
              accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../index.html" >Module code</a> &raquo;</li>
           <li><a href="../core.html" accesskey="U">core</a> &raquo;</li> 
         <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
 
 
-    <span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
+<div class="viewcode-block" id="BaseNode.start"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.start">[docs]</a>    <span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
     <span class="c">#################################</span>
     <span class="c">###  Some Utility Function    ###</span>
-    <span class="c">#################################</span>
+    <span class="c">#################################</span></div>
     <span class="nd">@property</span>
-    <span class="k">def</span> <span class="nf">now</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">sleep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">call_back</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
+<div class="viewcode-block" id="BaseNode.now"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.now">[docs]</a>    <span class="k">def</span> <span class="nf">now</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
+<div class="viewcode-block" id="BaseNode.sleep"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.sleep">[docs]</a>    <span class="k">def</span> <span class="nf">sleep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">call_back</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
     <span class="k">def</span> <span class="nf">create_timer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">call_back</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
     <span class="c">#################################</span>
     <span class="c">###  Network Related          ###</span>
     <span class="c">#################################</span>
-    <span class="k">def</span> <span class="nf">set_master_sock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span>
+<div class="viewcode-block" id="BaseNode.set_master_sock"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.set_master_sock">[docs]</a>    <span class="k">def</span> <span class="nf">set_master_sock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">sockets</span><span class="p">[</span><span class="n">sock</span><span class="p">][</span><span class="s">&#39;type&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;master&#39;</span>
 
     <span class="c"># @property</span>
-    <span class="c"># def client_socks(self): abstract_method()</span>
+    <span class="c"># def client_socks(self): abstract_method()</span></div>
     <span class="nd">@property</span>
-    <span class="k">def</span> <span class="nf">client_socks</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+<div class="viewcode-block" id="BaseNode.client_socks"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.client_socks">[docs]</a>    <span class="k">def</span> <span class="nf">client_socks</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="k">return</span> <span class="p">[</span><span class="n">sock</span> <span class="k">for</span> <span class="n">sock</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sockets</span><span class="o">.</span><span class="n">iteritems</span><span class="p">()</span> <span class="k">if</span> <span class="n">v</span><span class="p">[</span><span class="s">&#39;type&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;client&#39;</span><span class="p">]</span>
-    <span class="c">#### Socket API ####</span>
-    <span class="k">def</span> <span class="nf">create_sock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">desc</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">bind</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">port</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">listen</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">backlog</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">accept</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">recv</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">bufsize</span><span class="p">,</span> <span class="n">dispatcher</span><span class="p">,</span> <span class="n">threaded</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">send</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">connect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">addr_port</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">sendto</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">addr</span><span class="p">,</span> <span class="n">port</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
+    <span class="c">#### Socket API ####</span></div>
+<div class="viewcode-block" id="BaseNode.create_sock"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.create_sock">[docs]</a>    <span class="k">def</span> <span class="nf">create_sock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">desc</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
+<div class="viewcode-block" id="BaseNode.bind"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.bind">[docs]</a>    <span class="k">def</span> <span class="nf">bind</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">port</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
+<div class="viewcode-block" id="BaseNode.listen"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.listen">[docs]</a>    <span class="k">def</span> <span class="nf">listen</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">backlog</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
+<div class="viewcode-block" id="BaseNode.accept"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.accept">[docs]</a>    <span class="k">def</span> <span class="nf">accept</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
+<div class="viewcode-block" id="BaseNode.recv"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.recv">[docs]</a>    <span class="k">def</span> <span class="nf">recv</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">bufsize</span><span class="p">,</span> <span class="n">dispatcher</span><span class="p">,</span> <span class="n">threaded</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
+<div class="viewcode-block" id="BaseNode.send"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.send">[docs]</a>    <span class="k">def</span> <span class="nf">send</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
+<div class="viewcode-block" id="BaseNode.connect"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.connect">[docs]</a>    <span class="k">def</span> <span class="nf">connect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">addr_port</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
+<div class="viewcode-block" id="BaseNode.sendto"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.sendto">[docs]</a>    <span class="k">def</span> <span class="nf">sendto</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">addr</span><span class="p">,</span> <span class="n">port</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
+<div class="viewcode-block" id="BaseNode.close"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.close">[docs]</a>    <span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
 <div class="viewcode-block" id="BaseNode.close_socks"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.close_socks">[docs]</a>    <span class="k">def</span> <span class="nf">close_socks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">socks_seq_set</span><span class="p">,</span> <span class="n">_type</span><span class="o">=</span><span class="s">&#39;client&#39;</span><span class="p">):</span>
         <span class="sd">&quot;&quot;&quot;sock_seq_set is the sequence of socks in this type of sock&quot;&quot;&quot;</span>
         <span class="n">socks_set</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">client_socks</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">socks_seq_set</span><span class="p">]</span>
     <span class="c">#################################</span>
     <span class="c">###  Application Layer    #######</span>
     <span class="c">#################################</span></div>
-    <span class="k">def</span> <span class="nf">ping</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">threaded</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
+<div class="viewcode-block" id="BaseNode.ping"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.ping">[docs]</a>    <span class="k">def</span> <span class="nf">ping</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">threaded</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span></div>
     <span class="k">def</span> <span class="nf">ftp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">threaded</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
     <span class="k">def</span> <span class="nf">icmp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">threaded</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
     <span class="k">def</span> <span class="nf">http</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">threaded</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-    <span class="k">def</span> <span class="nf">stop_app</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">app_name</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
-</pre></div></div>
+<div class="viewcode-block" id="BaseNode.stop_app"><a class="viewcode-back" href="../../api.html#core.BaseNode.BaseNode.stop_app">[docs]</a>    <span class="k">def</span> <span class="nf">stop_app</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">app_name</span><span class="p">):</span> <span class="n">abstract_method</span><span class="p">()</span>
+</pre></div></div></div>
 
           </div>
         </div>
         <li class="right" style="margin-right: 10px">
           <a href="../../genindex.html" title="General Index"
              >index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../index.html" >Module code</a> &raquo;</li>
           <li><a href="../core.html" >core</a> &raquo;</li> 

doc/build/html/_modules/core/Client.html

         <li class="right" style="margin-right: 10px">
           <a href="../../genindex.html" title="General Index"
              accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../index.html" >Module code</a> &raquo;</li>
           <li><a href="../core.html" accesskey="U">core</a> &raquo;</li> 
         <li class="right" style="margin-right: 10px">
           <a href="../../genindex.html" title="General Index"
              >index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../index.html" >Module code</a> &raquo;</li>
           <li><a href="../core.html" >core</a> &raquo;</li> 

doc/build/html/_modules/core/Server.html

         <li class="right" style="margin-right: 10px">
           <a href="../../genindex.html" title="General Index"
              accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../index.html" >Module code</a> &raquo;</li>
           <li><a href="../core.html" accesskey="U">core</a> &raquo;</li> 
         <li class="right" style="margin-right: 10px">
           <a href="../../genindex.html" title="General Index"
              >index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
         <li><a href="../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../index.html" >Module code</a> &raquo;</li>
           <li><a href="../core.html" >core</a> &raquo;</li> 

doc/build/html/_modules/core/ns3/Experiment.html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
+
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     
-    <title>core.ns3.Experiment &mdash; imalse v0.0 alpha documentation</title>
+    <title>core.ns3.Experiment &mdash; imalse 0.0 alpha documentation</title>
+    
     <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
     <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
+    
     <script type="text/javascript">
       var DOCUMENTATION_OPTIONS = {
         URL_ROOT:    '../../../',
     <script type="text/javascript" src="../../../_static/jquery.js"></script>
     <script type="text/javascript" src="../../../_static/underscore.js"></script>
     <script type="text/javascript" src="../../../_static/doctools.js"></script>
-    <link rel="top" title="imalse v0.0 alpha documentation" href="../../../index.html" />
+    <link rel="top" title="imalse 0.0 alpha documentation" href="../../../index.html" />
     <link rel="up" title="core" href="../../core.html" /> 
   </head>
   <body>
         <li class="right" >
           <a href="../../../py-modindex.html" title="Python Module Index"
              >modules</a> |</li>
-        <li><a href="../../../index.html">imalse v0.0 alpha documentation</a> &raquo;</li>
+        <li><a href="../../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../../index.html" >Module code</a> &raquo;</li>
           <li><a href="../../core.html" accesskey="U">core</a> &raquo;</li> 
       </ul>
           <div class="body">
             
   <h1>Source code for core.ns3.Experiment</h1><div class="highlight"><pre>
-<span class="sd">&quot;&quot;&quot;</span>
-<span class="sd">this file describe the netns3 experiment for imalse</span>
-<span class="sd">&quot;&quot;&quot;</span>
-<span class="kn">from</span> <span class="nn">core.ns3.netns3</span> <span class="kn">import</span> <span class="n">NetnsExperiment</span>
-<span class="kn">from</span> <span class="nn">core.ns3.Node</span> <span class="kn">import</span> <span class="n">ImalseNetnsNode</span>
-<span class="kn">import</span> <span class="nn">ns3</span>
-<span class="kn">from</span> <span class="nn">util</span> <span class="kn">import</span> <span class="n">load_module</span>
-<span class="kn">from</span> <span class="nn">util</span> <span class="kn">import</span> <span class="n">get_scenario_option</span><span class="p">,</span> <span class="n">abstract_method</span>
+<span class="kn">from</span> <span class="nn">Experiment</span> <span class="kn">import</span> <span class="n">ImalseExperiment</span>
+<span class="kn">from</span> <span class="nn">ImalsePureSimExperiment</span> <span class="kn">import</span> <span class="n">ImalsePureSimExperiment</span>
 
-<span class="n">NODE_NUM</span> <span class="o">=</span> <span class="mi">0</span>
-
-<div class="viewcode-block" id="ImalseExperiment"><a class="viewcode-back" href="../../../API.html#core.ns3.Experiment.ImalseExperiment">[docs]</a><span class="k">class</span> <span class="nc">ImalseExperiment</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
-    <span class="sd">&quot;&quot;&quot; Base class for all ImalseExperiment</span>
-<span class="sd">    &quot;&quot;&quot;</span>
-    <span class="n">server_id_set</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
-    <span class="n">botmaster_id_set</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">]</span>
-    <span class="n">client_id_set</span> <span class="o">=</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">]</span>
-
-    <span class="nd">@property</span>
-    <span class="k">def</span> <span class="nf">id_set</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">server_id_set</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">botmaster_id_set</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">client_id_set</span>
-
-    <span class="k">def</span> <span class="nf">initparser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parser</span><span class="p">):</span>
-        <span class="n">scenario_ops</span> <span class="o">=</span> <span class="n">get_scenario_option</span><span class="p">()</span>
-        <span class="n">parser</span><span class="o">.</span><span class="n">add_option</span><span class="p">(</span><span class="s">&#39;-s&#39;</span><span class="p">,</span> <span class="s">&#39;--scenario&#39;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s">&quot;scenario&quot;</span><span class="p">,</span>
-                <span class="n">default</span><span class="o">=</span><span class="s">&#39;ddos_ping_flooding&#39;</span><span class="p">,</span>
-                <span class="n">help</span><span class="o">=</span><span class="s">&#39;specify the scenario you want to execute. Scenearios availiable are: </span><span class="si">%s</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">scenario_ops</span><span class="p">),</span>
-                <span class="p">)</span>
-
-    <span class="k">def</span> <span class="nf">_init</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="k">pass</span>
-    <span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="k">pass</span>
-
-<div class="viewcode-block" id="ImalseExperiment.get_node"><a class="viewcode-back" href="../../../API.html#core.ns3.Experiment.ImalseExperiment.get_node">[docs]</a>    <span class="k">def</span> <span class="nf">get_node</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;get ith nodes&quot;&quot;&quot;</span>
-        <span class="n">abstract_method</span><span class="p">()</span>
-</div>
-    <span class="nd">@property</span>
-    <span class="k">def</span> <span class="nf">node_num</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="n">abstract_method</span><span class="p">()</span>
-
-<div class="viewcode-block" id="ImalseExperiment.node_run"><a class="viewcode-back" href="../../../API.html#core.ns3.Experiment.ImalseExperiment.node_run">[docs]</a>    <span class="k">def</span> <span class="nf">node_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">node</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;run a command on a specific node&quot;&quot;&quot;</span>
-        <span class="n">node</span><span class="o">.</span><span class="n">cmd_set</span><span class="o">.</span><span class="n">_trigger</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
-</div>
-<div class="viewcode-block" id="ImalseExperiment.start_nodes"><a class="viewcode-back" href="../../../API.html#core.ns3.Experiment.ImalseExperiment.start_nodes">[docs]</a>    <span class="k">def</span> <span class="nf">start_nodes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;specify when each node should start&quot;&quot;&quot;</span>
-        <span class="c"># start servers</span>
-        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">server_id_set</span><span class="p">:</span>
-            <span class="k">print</span> <span class="s">&#39;node [</span><span class="si">%i</span><span class="s">] type [</span><span class="si">%s</span><span class="s">] start at [</span><span class="si">%f</span><span class="s">]s&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="s">&#39;server&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">event</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">node_run</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">),</span> <span class="s">&#39;start&#39;</span><span class="p">)</span>
-
-        <span class="c"># start clients</span>
-        <span class="n">t</span> <span class="o">=</span> <span class="mi">0</span>
-        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">client_id_set</span><span class="p">:</span>
-            <span class="n">t</span> <span class="o">+=</span> <span class="mi">2</span>
-            <span class="k">print</span> <span class="s">&#39;node [</span><span class="si">%i</span><span class="s">] type [</span><span class="si">%s</span><span class="s">] start at [</span><span class="si">%f</span><span class="s">]s&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="s">&#39;client&#39;</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">event</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">node_run</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">),</span> <span class="s">&#39;start&#39;</span><span class="p">)</span>
-
-        <span class="c"># start botmaster</span>
-        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">botmaster_id_set</span><span class="p">:</span>
-            <span class="k">print</span> <span class="s">&#39;node [</span><span class="si">%i</span><span class="s">] type [</span><span class="si">%s</span><span class="s">] start at [</span><span class="si">%f</span><span class="s">]s&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="s">&#39;botmaster&#39;</span><span class="p">,</span> <span class="n">t</span><span class="o">+</span><span class="mi">2</span><span class="p">)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">event</span><span class="p">(</span><span class="n">t</span><span class="o">+</span><span class="mi">2</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">node_run</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">),</span> <span class="s">&#39;start&#39;</span><span class="p">)</span>
-</div>
-    <span class="k">def</span> <span class="nf">_install_cmds</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">srv_addr</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;install different command set to nodes according to their type</span>
-<span class="sd">        can manually set the server address</span>
-<span class="sd">        &quot;&quot;&quot;</span>
-        <span class="n">scen</span> <span class="o">=</span> <span class="n">load_module</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">scenario</span><span class="p">)</span>
-        <span class="n">botmaster_desc</span> <span class="o">=</span> <span class="n">scen</span><span class="o">.</span><span class="n">botmaster_desc</span>
-        <span class="n">server_desc</span> <span class="o">=</span> <span class="n">scen</span><span class="o">.</span><span class="n">server_desc</span>
-        <span class="n">client_desc</span> <span class="o">=</span> <span class="n">scen</span><span class="o">.</span><span class="n">client_desc</span>
-        <span class="c"># botmaster_desc[&#39;srv_addr&#39;] = &quot;10.1.1.1&quot;</span>
-        <span class="k">print</span> <span class="s">&#39;srv_addr, &#39;</span><span class="p">,</span> <span class="n">srv_addr</span>
-        <span class="k">if</span> <span class="n">srv_addr</span><span class="p">:</span>
-            <span class="n">botmaster_desc</span><span class="p">[</span><span class="s">&#39;srv_addr&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">srv_addr</span>
-            <span class="n">server_desc</span><span class="p">[</span><span class="s">&#39;srv_addr&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">srv_addr</span>
-            <span class="n">client_desc</span><span class="p">[</span><span class="s">&#39;srv_addr&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">srv_addr</span>
-
-        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">xrange</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">node_num</span><span class="p">):</span>
-            <span class="k">if</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">botmaster_id_set</span><span class="p">:</span>
-                <span class="n">cmd</span> <span class="o">=</span> <span class="n">scen</span><span class="o">.</span><span class="n">BotMaster</span><span class="p">(</span><span class="n">botmaster_desc</span><span class="p">)</span>
-            <span class="k">elif</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">server_id_set</span><span class="p">:</span>
-                <span class="n">cmd</span> <span class="o">=</span> <span class="n">scen</span><span class="o">.</span><span class="n">ServerCMD</span><span class="p">(</span><span class="n">server_desc</span><span class="p">)</span>
-            <span class="k">elif</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">client_id_set</span><span class="p">:</span>
-                <span class="n">cmd</span> <span class="o">=</span> <span class="n">scen</span><span class="o">.</span><span class="n">ClientCMD</span><span class="p">(</span><span class="n">client_desc</span><span class="p">)</span>
-            <span class="k">else</span><span class="p">:</span>
-                <span class="k">continue</span>
-            <span class="n">cmd</span><span class="o">.</span><span class="n">install</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
-
-    <span class="k">def</span> <span class="nf">_get_server_addr</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;The all the server address&quot;&quot;&quot;</span>
-        <span class="n">addr_set</span> <span class="o">=</span> <span class="p">[]</span>
-        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">server_id_set</span><span class="p">:</span>
-            <span class="n">ipv4Addr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">.</span><span class="n">GetObject</span><span class="p">(</span><span class="n">ns3</span><span class="o">.</span><span class="n">TypeId</span><span class="o">.</span><span class="n">LookupByName</span><span class="p">(</span><span class="s">&quot;ns3::Ipv4&quot;</span><span class="p">))</span><span class="o">.</span><span class="n">GetAddress</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
-            <span class="n">addr_set</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ipv4Addr</span><span class="p">)</span>
-        <span class="k">return</span> <span class="n">addr_set</span>
-
-    <span class="k">def</span> <span class="nf">_get_server_nodes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">server_id_set</span><span class="p">]</span>
-
-    <span class="k">def</span> <span class="nf">_set_server_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;Only Set Server information for simulated nodes&quot;&quot;&quot;</span>
-        <span class="n">server_addr_set</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_server_addr</span><span class="p">()</span>
-        <span class="n">server_set</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_server_nodes</span><span class="p">()</span>
-        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">xrange</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">node_num</span><span class="p">):</span>
-            <span class="k">if</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">server_id_set</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">.</span><span class="n">NODE_TYPE</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">&#39;real&#39;</span><span class="p">):</span>
-                <span class="k">continue</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">.</span><span class="n">server_addr_set</span> <span class="o">=</span> <span class="n">server_addr_set</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">.</span><span class="n">server_set</span> <span class="o">=</span> <span class="n">server_set</span>
-
-<div class="viewcode-block" id="ImalseExperiment.print_srv_addr"><a class="viewcode-back" href="../../../API.html#core.ns3.Experiment.ImalseExperiment.print_srv_addr">[docs]</a>    <span class="k">def</span> <span class="nf">print_srv_addr</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;print out the address of the server&quot;&quot;&quot;</span>
-        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">server_id_set</span><span class="p">:</span>
-            <span class="n">ipv4Addr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">.</span><span class="n">GetObject</span><span class="p">(</span><span class="n">ns3</span><span class="o">.</span><span class="n">TypeId</span><span class="o">.</span><span class="n">LookupByName</span><span class="p">(</span><span class="s">&quot;ns3::Ipv4&quot;</span><span class="p">))</span><span class="o">.</span><span class="n">GetAddress</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
-            <span class="k">print</span> <span class="s">&#39;The server addr of server [</span><span class="si">%i</span><span class="s"> ]: &#39;</span><span class="o">%</span><span class="p">(</span><span class="n">i</span><span class="p">),</span> <span class="n">ipv4Addr</span>
-
-<span class="c"># for test, just select the first node as server, the second node as botmaster, all other nodes</span>
-<span class="c"># are clients</span></div></div>
-<span class="kn">import</span> <span class="nn">optparse</span>
-<div class="viewcode-block" id="ImalseNetnsExperiment"><a class="viewcode-back" href="../../../API.html#core.ns3.Experiment.ImalseNetnsExperiment">[docs]</a><span class="k">class</span> <span class="nc">ImalseNetnsExperiment</span><span class="p">(</span><span class="n">ImalseExperiment</span><span class="p">,</span> <span class="n">NetnsExperiment</span><span class="p">):</span>
-    <span class="sd">&quot;&quot;&quot;Base Class for Imalse Experiment in netns3 mode</span>
-<span class="sd">    &quot;&quot;&quot;</span>
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
-        <span class="c"># super(ImalseNetnsExperiment, self).__init__(*args, **kwargs)</span>
-        <span class="n">NetnsExperiment</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
-        <span class="n">ImalseExperiment</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">_init</span><span class="p">()</span>
-
-    <span class="k">def</span> <span class="nf">initparser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parser</span><span class="p">):</span>
-        <span class="n">ImalseExperiment</span><span class="o">.</span><span class="n">initparser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parser</span><span class="p">)</span>
-        <span class="n">NetnsExperiment</span><span class="o">.</span><span class="n">initparser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parser</span><span class="p">)</span>
-
-<div class="viewcode-block" id="ImalseNetnsExperiment.get_node"><a class="viewcode-back" href="../../../API.html#core.ns3.Experiment.ImalseNetnsExperiment.get_node">[docs]</a>    <span class="k">def</span> <span class="nf">get_node</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;get ith nodes&quot;&quot;&quot;</span>
-        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">nodes</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
-</div>
-    <span class="nd">@property</span>
-    <span class="k">def</span> <span class="nf">node_num</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nodes</span><span class="p">)</span>
-
-    <span class="nd">@staticmethod</span>
-    <span class="k">def</span> <span class="nf">NodeCreator</span><span class="p">():</span>
-        <span class="k">global</span> <span class="n">NODE_NUM</span>
-        <span class="n">NODE_NUM</span> <span class="o">+=</span> <span class="mi">1</span>
-        <span class="n">name</span> <span class="o">=</span> <span class="s">&quot;n</span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span><span class="n">NODE_NUM</span>
-        <span class="k">return</span> <span class="n">ImalseNetnsNode</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">logfile</span> <span class="o">=</span> <span class="s">&quot;/tmp/</span><span class="si">%s</span><span class="s">.log&quot;</span> <span class="o">%</span> <span class="n">name</span><span class="p">)</span>
-
-</div>
-<span class="sd">&quot;&quot;&quot;</span>
-<span class="sd">In Pure Sim experiments, all nodes are simulated. So we don&#39;t need</span>
-<span class="sd">the real-time schedular.</span>
-<span class="sd">&quot;&quot;&quot;</span>
-<span class="kn">from</span> <span class="nn">core.ns3.Node</span> <span class="kn">import</span> <span class="n">ImalseNetnsSimNode</span>
-<span class="kn">import</span> <span class="nn">ns.core</span>
-
-<div class="viewcode-block" id="ImalsePureSimExperiment"><a class="viewcode-back" href="../../../API.html#core.ns3.Experiment.ImalsePureSimExperiment">[docs]</a><span class="k">class</span> <span class="nc">ImalsePureSimExperiment</span><span class="p">(</span><span class="n">ImalseExperiment</span><span class="p">):</span>
-    <span class="sd">&quot;&quot;&quot;Pure Sim Experiemtn Doesn&#39;t depend on netns3 can run in simulated time&quot;&quot;&quot;</span>
-    <span class="k">def</span> <span class="nf">initparser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parser</span><span class="p">):</span>
-        <span class="nb">super</span><span class="p">(</span><span class="n">ImalsePureSimExperiment</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">initparser</span><span class="p">(</span><span class="n">parser</span><span class="p">)</span>
-        <span class="n">parser</span><span class="o">.</span><span class="n">set_defaults</span><span class="p">(</span><span class="n">SimulatorImplementationType</span><span class="o">=</span><span class="s">&#39;Default&#39;</span><span class="p">)</span>
-        <span class="n">parser</span><span class="o">.</span><span class="n">add_option</span><span class="p">(</span><span class="s">&quot;&quot;</span><span class="p">,</span> <span class="s">&quot;--SimulatorImpl&quot;</span><span class="p">,</span> <span class="n">dest</span> <span class="o">=</span> <span class="s">&quot;SimulatorImplementationType&quot;</span><span class="p">,</span>
-                <span class="n">help</span><span class="o">=</span><span class="s">&quot;the simulator implementation Type, available options are[&#39;Realtime&#39;, &#39;Default&#39;, &#39;Visual&#39;]&quot;</span><span class="p">)</span>
-
-
-        <span class="n">parser</span><span class="o">.</span><span class="n">set_defaults</span><span class="p">(</span><span class="n">numnodes</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> <span class="n">simtime</span> <span class="o">=</span> <span class="mi">30</span><span class="p">)</span>
-        <span class="n">parser</span><span class="o">.</span><span class="n">add_option</span><span class="p">(</span><span class="s">&quot;-n&quot;</span><span class="p">,</span> <span class="s">&quot;--numnodes&quot;</span><span class="p">,</span> <span class="n">dest</span> <span class="o">=</span> <span class="s">&quot;numnodes&quot;</span><span class="p">,</span> <span class="nb">type</span> <span class="o">=</span> <span class="nb">int</span><span class="p">,</span>
-                          <span class="n">help</span> <span class="o">=</span> <span class="s">&quot;number of nodes; default = </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span>
-                          <span class="n">parser</span><span class="o">.</span><span class="n">defaults</span><span class="p">[</span><span class="s">&quot;numnodes&quot;</span><span class="p">])</span>
-        <span class="n">parser</span><span class="o">.</span><span class="n">add_option</span><span class="p">(</span><span class="s">&quot;-t&quot;</span><span class="p">,</span> <span class="s">&quot;--simtime&quot;</span><span class="p">,</span> <span class="n">dest</span> <span class="o">=</span> <span class="s">&quot;simtime&quot;</span><span class="p">,</span> <span class="nb">type</span> <span class="o">=</span> <span class="nb">float</span><span class="p">,</span>
-                          <span class="n">help</span> <span class="o">=</span> <span class="s">&quot;simulation run time; default = </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span>
-                          <span class="n">parser</span><span class="o">.</span><span class="n">defaults</span><span class="p">[</span><span class="s">&quot;simtime&quot;</span><span class="p">])</span>
-
-    <span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="nb">super</span><span class="p">(</span><span class="n">ImalsePureSimExperiment</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">setup</span><span class="p">()</span>
-        <span class="n">ns</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">GlobalValue</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="s">&quot;SimulatorImplementationType&quot;</span><span class="p">,</span>
-                <span class="n">ns</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">StringValue</span><span class="p">(</span><span class="s">&quot;ns3::</span><span class="si">%s</span><span class="s">SimulatorImpl&quot;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">SimulatorImplementationType</span><span class="p">)))</span>
-
-    <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">setup</span><span class="p">()</span>
-        <span class="k">print</span> <span class="s">&quot;running simulator for </span><span class="si">%s</span><span class="s"> sec&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">simtime</span>
-        <span class="n">ns</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">Simulator</span><span class="o">.</span><span class="n">Stop</span><span class="p">(</span><span class="n">ns</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">Seconds</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">simtime</span><span class="p">))</span>
-        <span class="c"># ns.core.Simulator.Run(signal_check_frequency = -1)</span>
-        <span class="n">ns</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">Simulator</span><span class="o">.</span><span class="n">Run</span><span class="p">()</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">cleanup</span><span class="p">()</span>
-        <span class="n">ns</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">Simulator</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
-        <span class="k">print</span> <span class="s">&quot;simulator done&quot;</span>
-
-    <span class="nd">@staticmethod</span>
-<div class="viewcode-block" id="ImalsePureSimExperiment.event"><a class="viewcode-back" href="../../../API.html#core.ns3.Experiment.ImalsePureSimExperiment.event">[docs]</a>    <span class="k">def</span> <span class="nf">event</span><span class="p">(</span><span class="n">time</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwds</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;schedule an event to simulator&quot;&quot;&quot;</span>
-        <span class="k">def</span> <span class="nf">run</span><span class="p">():</span>
-            <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwds</span><span class="p">)</span>
-        <span class="n">ns</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">Simulator</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">ns</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">Time</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">time</span><span class="p">)),</span> <span class="n">run</span><span class="p">)</span>
-</div>
-    <span class="nd">@staticmethod</span>
-    <span class="k">def</span> <span class="nf">NodeCreator</span><span class="p">():</span>
-        <span class="k">return</span> <span class="n">ImalseNetnsSimNode</span><span class="p">()</span>
-
-    <span class="k">def</span> <span class="nf">main</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">run</span> <span class="o">=</span> <span class="bp">True</span><span class="p">):</span>
-        <span class="n">usage</span> <span class="o">=</span> <span class="s">&quot;%prog [-h] &quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">usagestr</span><span class="p">()</span> <span class="o">+</span> <span class="s">&quot; ...&quot;</span>
-        <span class="n">parser</span> <span class="o">=</span> <span class="n">optparse</span><span class="o">.</span><span class="n">OptionParser</span><span class="p">(</span><span class="n">usage</span> <span class="o">=</span> <span class="n">usage</span><span class="p">)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">initparser</span><span class="p">(</span><span class="n">parser</span><span class="p">)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
-        <span class="k">if</span> <span class="n">run</span><span class="p">:</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
-
-    <span class="k">def</span> <span class="nf">usagestr</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="k">return</span> <span class="s">&quot;[-n &lt;numnodes&gt;] [-t &lt;simtime&gt;]&quot;</span>
-
-    <span class="k">def</span> <span class="nf">print_help</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="n">parser</span> <span class="o">=</span> <span class="n">optparse</span><span class="o">.</span><span class="n">OptionParser</span><span class="p">(</span><span class="n">usage</span> <span class="o">=</span> <span class="s">&#39;&#39;</span><span class="p">)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">initparser</span><span class="p">(</span><span class="n">parser</span><span class="p">)</span>
-        <span class="n">parser</span><span class="o">.</span><span class="n">print_help</span><span class="p">()</span>
-
-    <span class="k">def</span> <span class="nf">cleanup</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="n">ns</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">Simulator</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
-        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">xrange</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">node_num</span><span class="p">):</span>
-            <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_node</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
-            <span class="n">n</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span></div>
+<span class="k">try</span><span class="p">:</span>
+    <span class="kn">from</span> <span class="nn">ImalseNetnsExperiment</span> <span class="kn">import</span> <span class="n">ImalseNetnsExperiment</span>
+<span class="k">except</span><span class="p">:</span>
+    <span class="k">print</span><span class="p">(</span><span class="s">&#39;NetnsExperiment cannot be imported&#39;</span><span class="p">)</span>
 </pre></div>
 
           </div>
 <div id="searchbox" style="display: none">
   <h3>Quick search</h3>
     <form class="search" action="../../../search.html" method="get">
-      <input type="text" name="q" size="18" />
+      <input type="text" name="q" />
       <input type="submit" value="Go" />
       <input type="hidden" name="check_keywords" value="yes" />
       <input type="hidden" name="area" value="default" />
         <li class="right" >
           <a href="../../../py-modindex.html" title="Python Module Index"
              >modules</a> |</li>
-        <li><a href="../../../index.html">imalse v0.0 alpha documentation</a> &raquo;</li>
+        <li><a href="../../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../../index.html" >Module code</a> &raquo;</li>
           <li><a href="../../core.html" >core</a> &raquo;</li> 
       </ul>
     </div>
     <div class="footer">
         &copy; Copyright 2012, Jing Conan Wang.
-      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
+      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
     </div>
   </body>
 </html>

doc/build/html/_modules/core/ns3/Node.html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
+
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     
-    <title>core.ns3.Node &mdash; imalse v0.0 alpha documentation</title>
+    <title>core.ns3.Node &mdash; imalse 0.0 alpha documentation</title>
+    
     <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
     <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
+    
     <script type="text/javascript">
       var DOCUMENTATION_OPTIONS = {
         URL_ROOT:    '../../../',
     <script type="text/javascript" src="../../../_static/jquery.js"></script>
     <script type="text/javascript" src="../../../_static/underscore.js"></script>
     <script type="text/javascript" src="../../../_static/doctools.js"></script>
-    <link rel="top" title="imalse v0.0 alpha documentation" href="../../../index.html" />
+    <link rel="top" title="imalse 0.0 alpha documentation" href="../../../index.html" />
     <link rel="up" title="core" href="../../core.html" /> 
   </head>
   <body>
         <li class="right" >
           <a href="../../../py-modindex.html" title="Python Module Index"
              >modules</a> |</li>
-        <li><a href="../../../index.html">imalse v0.0 alpha documentation</a> &raquo;</li>
+        <li><a href="../../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../../index.html" >Module code</a> &raquo;</li>
           <li><a href="../../core.html" accesskey="U">core</a> &raquo;</li> 
       </ul>
   <h1>Source code for core.ns3.Node</h1><div class="highlight"><pre>
 <span class="c">#!/usr/bin/env python</span>
 <span class="sd">&quot;&quot;&quot;</span>
-<span class="sd">This file defined the for NS3 simulator.</span>
+<span class="sd">This module defined the for NS3 node.</span>
 <span class="sd">two types of nodes are defined:</span>
 <span class="sd">    1. **ImalseNetnsNode**, used for netns3 simulation.</span>
 <span class="sd">    2. **ImalseNetnsSimNode**, used for ns3 pure simulation.</span>
 <span class="sd">&quot;&quot;&quot;</span>
-<span class="kn">from</span> <span class="nn">core.BaseNode</span> <span class="kn">import</span> <span class="n">BaseNode</span>
-<span class="kn">import</span> <span class="nn">sys</span>
+<span class="k">try</span><span class="p">:</span>
+    <span class="kn">from</span> <span class="nn">ImalseNetnsNode</span> <span class="kn">import</span> <span class="n">ImalseNetnsNode</span>
+<span class="k">except</span><span class="p">:</span>
+    <span class="k">print</span><span class="p">(</span><span class="s">&#39;ImalseNetnsNode cannot be imported&#39;</span><span class="p">)</span>
 
-<span class="kn">from</span> <span class="nn">core.real</span> <span class="kn">import</span> <span class="n">PhyNode</span>
-<span class="kn">from</span> <span class="nn">core.ns3.netns3</span> <span class="kn">import</span> <span class="o">*</span>
-<div class="viewcode-block" id="ImalseNetnsNode"><a class="viewcode-back" href="../../../API.html#core.ns3.Node.ImalseNetnsNode">[docs]</a><span class="k">class</span> <span class="nc">ImalseNetnsNode</span><span class="p">(</span><span class="n">NetnsNode</span><span class="p">,</span> <span class="n">PhyNode</span><span class="p">):</span>
-    <span class="sd">&quot;&quot;&quot;Imalse Netns Node, it will use linux namespace to construct virtual machine.</span>
-<span class="sd">    And applications will run in these virtual machines.</span>
-<span class="sd">    &quot;&quot;&quot;</span>
-    <span class="n">NODE_TYPE</span> <span class="o">=</span> <span class="s">&#39;real_ns3&#39;</span>
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">cmd_set</span> <span class="o">=</span> <span class="bp">None</span>
-        <span class="n">NetnsNode</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
-        <span class="n">PhyNode</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
-
-    <span class="k">def</span> <span class="nf">ping</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">threaded</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
-        <span class="n">dst</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;hostname&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
-        <span class="n">count</span> <span class="o">=</span> <span class="mi">3</span>
-        <span class="n">cmd</span> <span class="o">=</span> <span class="p">[</span><span class="s">&quot;ping&quot;</span><span class="p">,</span> <span class="s">&quot;-b&quot;</span><span class="p">,</span> <span class="s">&quot;-c&quot;</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">count</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">dst</span><span class="p">)]</span>
-        <span class="k">print</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="s">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">cmd</span><span class="p">))</span>
-        <span class="n">p</span><span class="p">,</span> <span class="n">stdin</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span>
-        <span class="n">err</span> <span class="o">=</span> <span class="n">stderr</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
-        <span class="n">out</span> <span class="o">=</span> <span class="n">stdout</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
-        <span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">err</span><span class="p">)</span>
-        <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>
-
-    <span class="k">def</span> <span class="nf">stop_ping</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span>
-        <span class="k">print</span> <span class="s">&#39;stop_ping&#39;</span>
-</div>
-<span class="n">nodenum</span> <span class="o">=</span> <span class="mi">0</span>
-<span class="kn">import</span> <span class="nn">ns3</span>
-<span class="c"># class ConnectACKTag(ns3.Tag):</span>
-<span class="c">#     def __init__(self):</span>
-<span class="c">#         pass</span>
-<span class="c">#     def GetSerializedSize (self):</span>
-<span class="c">#         pass</span>
-        <span class="c"># return 0</span>
-<span class="c">#     def Serialize (self, tag_buffer):</span>
-        <span class="c"># tag_buffer = &quot;CONECT_ACK&quot;</span>
-<span class="c">#         pass</span>
-<span class="c">#     def Deserialize (self, tag_buffer):</span>
-        <span class="c"># self.data = tag_buffer</span>
-<span class="c">#         pass</span>
-<span class="c">#     def Print (os):</span>
-<span class="c">#         pass</span>
-
-<span class="c">#############################################</span>
-<span class="c"># NS3 python binding missing some important</span>
-<span class="c"># APIs, MSG_MAP and MSG_RE_MAP are used</span>
-<span class="c"># to hack the API. Need to be fixed later</span>
-<span class="c">#############################################</span>
-<span class="n">MSG_MAP</span> <span class="o">=</span> <span class="p">{</span>
-        <span class="s">&#39;connect_ack&#39;</span><span class="p">:</span> <span class="mi">21</span><span class="p">,</span>
-        <span class="s">&#39;{&quot;password&quot;: [&quot;1234&quot;], &quot;event&quot;: [&quot;verify_master&quot;]}&#39;</span><span class="p">:</span><span class="mi">122</span><span class="p">,</span>
-        <span class="s">&#39;{&quot;msg&quot;: [&quot;verifed, hi master, what you want to do?&quot;], &quot;event&quot;: [&quot;echo&quot;]}&#39;</span><span class="p">:</span><span class="mi">123</span><span class="p">,</span>
-        <span class="s">&#39;{&quot;hostname&quot;: [&quot;127.0.0.1&quot;], &quot;event&quot;: [&quot;forward_to_bots&quot;], &quot;bot_event&quot;: [&quot;send_ping&quot;]}&#39;</span><span class="p">:</span><span class="mi">124</span><span class="p">,</span>
-        <span class="s">&#39;{&quot;event&quot;: [&quot;file_exfiltration&quot;]}&#39;</span><span class="p">:</span><span class="mi">125</span><span class="p">,</span>
-        <span class="s">&#39;{&quot;host&quot;: &quot;thales.bu.edu&quot;, &quot;password&quot;: &quot;imalse&quot;, &quot;user&quot;: &quot;imalse-ftp&quot;, &quot;event&quot;: &quot;set_ftp_info&quot;}&#39;</span><span class="p">:</span><span class="mi">126</span><span class="p">,</span>
-        <span class="s">&#39;{&quot;directory&quot;: &quot;.&quot;, &quot;pattern&quot;: &quot;assword&quot;, &quot;suffix&quot;: [&quot;.txt&quot;], &quot;event&quot;: &quot;set_file_filter&quot;}&#39;</span><span class="p">:</span><span class="mi">127</span><span class="p">,</span>
-        <span class="s">&#39;{&quot;event&quot;: &quot;search_and_upload&quot;}&#39;</span><span class="p">:</span><span class="mi">128</span><span class="p">,</span>
-        <span class="s">&#39;{&quot;hostname&quot;: [&quot;127.0.0.1&quot;], &quot;event&quot;: [&quot;send_ping&quot;]}&#39;</span><span class="p">:</span><span class="mi">129</span><span class="p">,</span>
-        <span class="p">}</span>
-<span class="n">MSG_RE_MAP</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span> <span class="p">[</span> <span class="p">(</span><span class="n">v</span><span class="p">,</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">v</span> <span class="ow">in</span> <span class="n">MSG_MAP</span><span class="o">.</span><span class="n">iteritems</span><span class="p">()</span> <span class="p">]</span> <span class="p">)</span>
-
-<span class="k">def</span> <span class="nf">call_method</span><span class="p">(</span><span class="n">method</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
-    <span class="n">method</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
-
-<span class="k">class</span> <span class="nc">SocketDict</span><span class="p">(</span><span class="nb">dict</span><span class="p">):</span>
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">sockets</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
-        <span class="nb">super</span><span class="p">(</span><span class="n">SocketDict</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__init__</span><span class="p">()</span>
-
-    <span class="k">def</span> <span class="nf">hash</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span>
-        <span class="n">node</span> <span class="o">=</span> <span class="n">sock</span><span class="o">.</span><span class="n">GetNode</span><span class="p">()</span>
-        <span class="n">typeId</span> <span class="o">=</span> <span class="n">sock</span><span class="o">.</span><span class="n">GetTypeId</span><span class="p">()</span>
-        <span class="n">_from</span> <span class="o">=</span> <span class="n">ns3</span><span class="o">.</span><span class="n">Address</span><span class="p">()</span>
-        <span class="n">sock</span><span class="o">.</span><span class="n">GetSockName</span><span class="p">(</span><span class="n">_from</span><span class="p">)</span>
-        <span class="k">return</span> <span class="nb">hash</span><span class="p">((</span><span class="n">node</span><span class="o">.</span><span class="n">GetId</span><span class="p">(),</span> <span class="n">typeId</span><span class="o">.</span><span class="n">GetName</span><span class="p">(),</span> <span class="nb">str</span><span class="p">(</span><span class="n">_from</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">sock</span><span class="p">)))</span>
-
-    <span class="k">def</span> <span class="nf">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span>
-        <span class="k">return</span> <span class="nb">super</span><span class="p">(</span><span class="n">SocketDict</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">hash</span><span class="p">(</span><span class="n">sock</span><span class="p">))</span>
-
-    <span class="k">def</span> <span class="nf">__setitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
-        <span class="nb">super</span><span class="p">(</span><span class="n">SocketDict</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__setitem__</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">hash</span><span class="p">(</span><span class="n">sock</span><span class="p">),</span> <span class="n">value</span><span class="p">)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">sockets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">hash</span><span class="p">(</span><span class="n">sock</span><span class="p">)]</span> <span class="o">=</span> <span class="n">sock</span>
-
-    <span class="k">def</span> <span class="nf">iteritems</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="c">#FIXME this is not iterator actually</span>
-        <span class="k">return</span> <span class="nb">zip</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">sockets</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">keys</span><span class="p">()]</span> <span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
-
-    <span class="k">def</span> <span class="nf">items</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="k">return</span> <span class="nb">zip</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">sockets</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">keys</span><span class="p">()]</span> <span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
-
-
-<div class="viewcode-block" id="ImalseNetnsSimNode"><a class="viewcode-back" href="../../../API.html#core.ns3.Node.ImalseNetnsSimNode">[docs]</a><span class="k">class</span> <span class="nc">ImalseNetnsSimNode</span><span class="p">(</span><span class="n">ns3</span><span class="o">.</span><span class="n">Node</span><span class="p">,</span> <span class="n">BaseNode</span><span class="p">):</span>
-    <span class="sd">&quot;&quot;&quot;Simulated Node in NS3 Adapted for Imalse Simulation&quot;&quot;&quot;</span>
-    <span class="n">proto_map</span> <span class="o">=</span> <span class="p">{</span>
-            <span class="s">&#39;udp&#39;</span><span class="p">:</span><span class="n">ns3</span><span class="o">.</span><span class="n">UdpSocketFactory</span><span class="o">.</span><span class="n">GetTypeId</span><span class="p">(),</span>
-            <span class="s">&#39;tcp&#39;</span><span class="p">:</span><span class="n">ns3</span><span class="o">.</span><span class="n">TcpSocketFactory</span><span class="o">.</span><span class="n">GetTypeId</span><span class="p">(),</span>
-            <span class="p">}</span>
-    <span class="n">NODE_TYPE</span> <span class="o">=</span> <span class="s">&#39;sim_ns3&#39;</span>
-    <span class="n">name</span> <span class="o">=</span> <span class="s">&#39;ImalseNetnsSimNode&#39;</span>
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
-        <span class="n">BaseNode</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
-        <span class="k">if</span> <span class="n">name</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
-            <span class="k">global</span> <span class="n">nodenum</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s">&quot;sim_n</span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span><span class="p">(</span><span class="n">nodenum</span><span class="p">)</span>
-            <span class="n">nodenum</span> <span class="o">+=</span> <span class="mi">1</span>
-        <span class="k">else</span><span class="p">:</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
-
-        <span class="n">ns3</span><span class="o">.</span><span class="n">Node</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">sockets</span> <span class="o">=</span> <span class="n">SocketDict</span><span class="p">()</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">sleep_delay</span> <span class="o">=</span> <span class="mi">0</span>
-
-    <span class="nd">@property</span>
-    <span class="k">def</span> <span class="nf">client_socks</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="k">return</span> <span class="p">[</span><span class="n">sock</span> <span class="k">for</span> <span class="n">sock</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sockets</span><span class="o">.</span><span class="n">iteritems</span><span class="p">()</span> <span class="k">if</span> <span class="n">v</span><span class="p">[</span><span class="s">&#39;type&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;client&#39;</span><span class="p">]</span>
-
-    <span class="k">def</span> <span class="nf">create_sock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">desc</span><span class="p">):</span>
-        <span class="n">sock</span> <span class="o">=</span> <span class="n">ns3</span><span class="o">.</span><span class="n">Socket</span><span class="o">.</span><span class="n">CreateSocket</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">proto_map</span><span class="p">[</span><span class="n">desc</span><span class="p">[</span><span class="s">&#39;proto&#39;</span><span class="p">]])</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;node [</span><span class="si">%s</span><span class="s">] create sock [</span><span class="si">%s</span><span class="s">] with desc [</span><span class="si">%s</span><span class="s">]&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">sock</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">desc</span><span class="p">)))</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">sockets</span><span class="p">[</span><span class="n">sock</span><span class="p">]</span> <span class="o">=</span> <span class="n">desc</span>
-        <span class="k">return</span> <span class="n">sock</span>
-
-<div class="viewcode-block" id="ImalseNetnsSimNode.after"><a class="viewcode-back" href="../../../API.html#core.ns3.Node.ImalseNetnsSimNode.after">[docs]</a>    <span class="k">def</span> <span class="nf">after</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">method</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;schedue a even after t seconds&quot;&quot;&quot;</span>
-        <span class="k">def</span> <span class="nf">void_return_method</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
-            <span class="n">method</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
-        <span class="k">return</span> <span class="n">ns3</span><span class="o">.</span><span class="n">Simulator</span><span class="o">.</span><span class="n">Schedule</span><span class="p">(</span><span class="n">ns3</span><span class="o">.</span><span class="n">Simulator</span><span class="o">.</span><span class="n">Now</span><span class="p">()</span><span class="o">+</span><span class="n">ns3</span><span class="o">.</span><span class="n">Seconds</span><span class="p">(</span><span class="n">t</span><span class="p">),</span>
-                <span class="n">void_return_method</span><span class="p">,</span>
-                <span class="o">*</span><span class="n">args</span><span class="p">,</span>
-                <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
-</div>
-    <span class="k">def</span> <span class="nf">bind</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">addr_port</span><span class="p">):</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] start to bind to </span><span class="si">%s</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">addr_port</span><span class="p">)</span> <span class="p">)</span>
-        <span class="n">addr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_search_server_addr</span><span class="p">(</span><span class="n">addr_port</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
-        <span class="c"># import pdb;pdb.set_trace()</span>
-        <span class="n">dst</span> <span class="o">=</span> <span class="n">ns3</span><span class="o">.</span><span class="n">InetSocketAddress</span> <span class="p">(</span><span class="n">addr</span><span class="p">,</span> <span class="n">addr_port</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
-        <span class="c"># dst = ns3.InetSocketAddress (ns3.Ipv4Address(&#39;10.0.1.1&#39;), addr_port[1])</span>
-        <span class="n">sock</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">dst</span><span class="p">);</span>
-        <span class="c"># sock.Bind();</span>
-
-    <span class="k">def</span> <span class="nf">_search_server_addr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">addr</span><span class="p">):</span>
-        <span class="k">if</span> <span class="n">addr</span><span class="p">:</span>
-            <span class="k">return</span> <span class="n">ns3</span><span class="o">.</span><span class="n">Ipv4Address</span><span class="p">(</span><span class="n">addr</span><span class="p">)</span>
-        <span class="k">else</span><span class="p">:</span>
-            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">server_addr_set</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">GetLocal</span><span class="p">()</span>
-
-    <span class="k">def</span> <span class="nf">listen</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">backlog</span><span class="p">):</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] start to listen&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="p">)</span>
-        <span class="n">sock</span><span class="o">.</span><span class="n">Listen</span><span class="p">()</span>
-
-    <span class="k">def</span> <span class="nf">recv</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">bufsize</span><span class="p">,</span> <span class="n">dispatcher</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">threaded</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] has set recv dispatcher [</span><span class="si">%s</span><span class="s">] for sock [</span><span class="si">%s</span><span class="s">]&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">dispatcher</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">sock</span><span class="p">))</span> <span class="p">)</span>
-        <span class="n">sock</span><span class="o">.</span><span class="n">SetRecvCallback</span><span class="p">(</span><span class="n">dispatcher</span><span class="p">)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] has finish set recv dispatcher for sock [</span><span class="si">%s</span><span class="s">]&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">sock</span><span class="p">))</span> <span class="p">)</span>
-        <span class="n">sock</span><span class="o">.</span><span class="n">Recv</span><span class="p">()</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;sock.Recv finished&#39;</span><span class="p">)</span>
-        <span class="c"># sock.Recv(bufsize, 0)</span>
-
-<div class="viewcode-block" id="ImalseNetnsSimNode.dispatcher"><a class="viewcode-back" href="../../../API.html#core.ns3.Node.ImalseNetnsSimNode.dispatcher">[docs]</a>    <span class="k">def</span> <span class="nf">dispatcher</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;node level dispatcher, it will read data from the socket,</span>
-<span class="sd">        parse the data into approariate format and handle the data to</span>
-<span class="sd">        cmd.dispatcher()</span>
-<span class="sd">        &quot;&quot;&quot;</span>
-<span class="c">#FIXME this function was not exculated in pure simulation mode</span>
-        <span class="c"># if self.name == &quot;sim_n%s&quot; %(2):</span>
-            <span class="c"># import pdb;pdb.set_trace()</span>
-
-        <span class="n">_from</span> <span class="o">=</span> <span class="n">ns3</span><span class="o">.</span><span class="n">Address</span><span class="p">()</span>
-        <span class="n">packet</span> <span class="o">=</span> <span class="n">sock</span><span class="o">.</span><span class="n">RecvFrom</span> <span class="p">(</span><span class="n">_from</span><span class="p">)</span>
-        <span class="c"># import pdb;pdb.set_trace()</span>
-        <span class="n">msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_msg</span><span class="p">(</span><span class="n">packet</span><span class="p">)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] has receive message </span><span class="si">%s</span><span class="s"> from sock [</span><span class="si">%s</span><span class="s">] and node [</span><span class="si">%s</span><span class="s">]&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">msg</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">_from</span><span class="p">)</span> <span class="p">)</span>
-
-        <span class="k">if</span> <span class="n">msg</span> <span class="o">==</span> <span class="s">&#39;connect_ack&#39;</span><span class="p">:</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] call self.recv_ack s&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="p">)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">cmd_set</span><span class="o">.</span><span class="n">recv_ack</span><span class="p">()</span>
-        <span class="k">else</span><span class="p">:</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] call cmd_set.dispatcher&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="p">)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">cmd_set</span><span class="o">.</span><span class="n">dispatcher</span><span class="p">(</span><span class="n">sock</span><span class="p">,</span> <span class="n">msg</span><span class="p">)</span>
-
-        <span class="c"># self.recv(sock, 512, self.dispatcher)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">after</span><span class="p">(</span><span class="mf">0.1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">recv</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="mi">512</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">dispatcher</span><span class="p">)</span>
-        <span class="c"># self.after(0, self.recv, sock, 512, self.dispatcher)</span>
-</div>
-    <span class="k">def</span> <span class="nf">sleep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">call_back</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
-        <span class="k">if</span> <span class="n">call_back</span><span class="p">:</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">after</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">call_back</span><span class="p">)</span>
-            <span class="k">return</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">sleep_delay</span> <span class="o">=</span> <span class="n">t</span> <span class="c">#FIXME Just to Make Botmaster API Unchanged</span>
-
-<div class="viewcode-block" id="ImalseNetnsSimNode.connect"><a class="viewcode-back" href="../../../API.html#core.ns3.Node.ImalseNetnsSimNode.connect">[docs]</a>    <span class="k">def</span> <span class="nf">connect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">addr_port</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;Will set Connect callback function. If succeeded, self.recv will be called. otherwise</span>
-<span class="sd">        the sock will be closed&quot;&quot;&quot;</span>
-        <span class="n">server_addr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_search_server_addr</span><span class="p">(</span><span class="n">addr_port</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
-        <span class="k">print</span> <span class="s">&#39;server_addr, &#39;</span><span class="p">,</span> <span class="n">server_addr</span>
-        <span class="k">print</span> <span class="s">&#39;serval local, &#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">server_addr_set</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">GetLocal</span><span class="p">()</span>
-        <span class="k">print</span> <span class="s">&#39;serval local, &#39;</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">server_addr_set</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">GetLocal</span><span class="p">())</span>
-        <span class="k">assert</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">server_addr</span><span class="p">)</span> <span class="o">==</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">server_addr_set</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">GetLocal</span><span class="p">()))</span>
-        <span class="c"># import pdb;pdb.set_trace()</span>
-        <span class="n">inetAddr</span> <span class="o">=</span> <span class="n">ns3</span><span class="o">.</span><span class="n">InetSocketAddress</span><span class="p">(</span>
-                <span class="c"># server_addr,</span>
-                <span class="bp">self</span><span class="o">.</span><span class="n">server_addr_set</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">GetLocal</span><span class="p">(),</span> <span class="c"># connect to first server</span>
-                <span class="n">addr_port</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
-                <span class="p">)</span>
-
-        <span class="k">def</span> <span class="nf">connect_succeeded</span><span class="p">(</span><span class="n">sock</span><span class="p">):</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] connect succeeded&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="p">)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">recv</span><span class="p">(</span><span class="n">sock</span><span class="p">,</span> <span class="mi">512</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">dispatcher</span><span class="p">)</span>
-
-        <span class="k">def</span> <span class="nf">connect_failed</span><span class="p">(</span><span class="n">sock</span><span class="p">):</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] connect failed&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="p">)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">close_sock</span><span class="p">(</span><span class="n">sock</span><span class="p">)</span>
-
-        <span class="n">sock</span><span class="o">.</span><span class="n">SetConnectCallback</span><span class="p">(</span><span class="n">connect_succeeded</span><span class="p">,</span> <span class="n">connect_failed</span><span class="p">)</span>
-        <span class="n">ret</span> <span class="o">=</span> <span class="n">sock</span><span class="o">.</span><span class="n">Connect</span><span class="p">(</span><span class="n">inetAddr</span><span class="p">)</span>
-        <span class="c"># print &#39;ret, &#39;, ret</span>
-        <span class="c"># x = inetAddr.GetIpv4()</span>
-        <span class="c"># from inspect import getmembers</span>
-        <span class="c"># for a, b in getmembers(x): print a, b</span>
-        <span class="c"># print sock</span>
-        <span class="c"># print ns3.InetSocketAddress.IsMatchingType(inetAddr)</span>
-        <span class="c"># ns3.TcpSocketFactory.GetTypeId()</span>
-        <span class="c"># import pdb;pdb.set_trace()</span>
-        <span class="c"># self.after(0, sock.Connect, inetAddr)</span>
-        <span class="c"># import pdb;pdb.set_trace()</span>
-</div>
-    <span class="nd">@staticmethod</span>
-<div class="viewcode-block" id="ImalseNetnsSimNode.get_msg"><a class="viewcode-back" href="../../../API.html#core.ns3.Node.ImalseNetnsSimNode.get_msg">[docs]</a>    <span class="k">def</span> <span class="nf">get_msg</span><span class="p">(</span><span class="n">p</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;get_msg and add_msg are two hack function&quot;&quot;&quot;</span>
-        <span class="k">print</span> <span class="s">&#39;p.GetSize(), &#39;</span><span class="p">,</span> <span class="n">p</span><span class="o">.</span><span class="n">GetSize</span><span class="p">()</span>
-        <span class="c"># import pdb;pdb.set_trace()</span>
-        <span class="k">return</span> <span class="n">MSG_RE_MAP</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="n">GetSize</span><span class="p">()]</span>
-        <span class="c"># return MSG_RE_MAP[21]</span>
-</div>
-    <span class="nd">@staticmethod</span>
-<div class="viewcode-block" id="ImalseNetnsSimNode.add_msg"><a class="viewcode-back" href="../../../API.html#core.ns3.Node.ImalseNetnsSimNode.add_msg">[docs]</a>    <span class="k">def</span> <span class="nf">add_msg</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">msg</span><span class="p">):</span>
-        <span class="sd">&quot;&quot;&quot;encode the message to the packet&quot;&quot;&quot;</span>
-        <span class="n">msg_id</span> <span class="o">=</span> <span class="n">MSG_MAP</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">msg</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="c"># FIXME use padding length to present msg, a wordround for python bug</span>
-        <span class="k">if</span> <span class="ow">not</span> <span class="n">msg_id</span><span class="p">:</span>
-            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s">&#39;Unknown Message </span><span class="si">%s</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">msg</span><span class="p">))</span>
-        <span class="c"># p.AddPaddingAtEnd(msg_id)</span>
-        <span class="c"># FIXME due to the bug of pyviz, we cannot AddPading to existing packets, instead</span>
-        <span class="c"># a new packet is created</span>
-        <span class="n">p2</span> <span class="o">=</span> <span class="n">ns3</span><span class="o">.</span><span class="n">Packet</span><span class="p">(</span><span class="n">msg_id</span><span class="p">)</span>
-        <span class="k">return</span> <span class="n">p2</span>
-        <span class="c"># if data == &quot;connect_ack&quot;:</span>
-            <span class="c"># tag = ConnectACKTag()</span>
-        <span class="c"># p.AddPacketTag(tag)</span>
-</div>
-    <span class="k">def</span> <span class="nf">send</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Node [</span><span class="si">%s</span><span class="s">] send data [</span><span class="si">%s</span><span class="s">] on socket [</span><span class="si">%s</span><span class="s">]&#39;</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">sock</span><span class="p">))</span> <span class="p">)</span>
-        <span class="n">p</span> <span class="o">=</span> <span class="n">ns3</span><span class="o">.</span><span class="n">Packet</span><span class="p">()</span>
-        <span class="n">p</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">add_msg</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">after</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sleep_delay</span><span class="p">,</span> <span class="n">sock</span><span class="o">.</span><span class="n">Send</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>
-        <span class="c"># self.after(self.sleep_delay, self.send, sock, data)</span>
-        <span class="c"># value = sock.Send(p)</span>
-        <span class="c"># self.logger.debug(&#39;Node [%s] send out [%i] bytes&#39;%(self.name, value) )</span>
-        <span class="c"># if value == -1:</span>
-            <span class="c"># raise Exception(&#39;Fail in Send traffic&#39;)</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">sleep_delay</span> <span class="o">=</span> <span class="mi">0</span>
-
-    <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
-        <span class="k">pass</span>
-
-    <span class="c">####################################</span>
-    <span class="c">##    File System              #####</span>
-    <span class="c">####################################</span>
-    <span class="k">def</span> <span class="nf">get_file_list</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
-        <span class="k">return</span> <span class="p">[</span><span class="s">&#39;pesudo_file.txt&#39;</span><span class="p">]</span>
-
-    <span class="k">def</span> <span class="nf">load_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
-        <span class="k">return</span> <span class="s">&#39;password&#39;</span>
-
-
-    <span class="k">def</span> <span class="nf">ftp_upload</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">user</span><span class="p">,</span> <span class="n">password</span><span class="p">):</span>
-        <span class="k">print</span> <span class="s">&#39;File [</span><span class="si">%s</span><span class="s">] has been uploaded to ftp </span><span class="si">%s</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">host</span><span class="p">)</span>
-
-    <span class="c">####################################</span>
-    <span class="c">##    File System              #####</span>
-    <span class="c">####################################</span>
-    <span class="k">def</span> <span class="nf">ping</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sock</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">threaded</span><span class="p">):</span>
-        <span class="k">print</span> <span class="s">&#39;ImalseNetnsSimNode.ping: this is just a stub, please finish it&#39;</span>
-</pre></div></div>
+<span class="kn">from</span> <span class="nn">ImalseNetnsSimNode</span> <span class="kn">import</span> <span class="n">ImalseNetnsSimNode</span>
+</pre></div>
 
           </div>
         </div>
 <div id="searchbox" style="display: none">
   <h3>Quick search</h3>
     <form class="search" action="../../../search.html" method="get">
-      <input type="text" name="q" size="18" />
+      <input type="text" name="q" />
       <input type="submit" value="Go" />
       <input type="hidden" name="check_keywords" value="yes" />
       <input type="hidden" name="area" value="default" />
         <li class="right" >
           <a href="../../../py-modindex.html" title="Python Module Index"
              >modules</a> |</li>
-        <li><a href="../../../index.html">imalse v0.0 alpha documentation</a> &raquo;</li>
+        <li><a href="../../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../../index.html" >Module code</a> &raquo;</li>
           <li><a href="../../core.html" >core</a> &raquo;</li> 
       </ul>
     </div>
     <div class="footer">
         &copy; Copyright 2012, Jing Conan Wang.
-      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
+      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
     </div>
   </body>
 </html>

doc/build/html/_modules/core/ns3/Topology.html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
+
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     
-    <title>core.ns3.Topology &mdash; imalse v0.0 alpha documentation</title>
+    <title>core.ns3.Topology &mdash; imalse 0.0 alpha documentation</title>
+    
     <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
     <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
+    
     <script type="text/javascript">
       var DOCUMENTATION_OPTIONS = {
         URL_ROOT:    '../../../',
     <script type="text/javascript" src="../../../_static/jquery.js"></script>
     <script type="text/javascript" src="../../../_static/underscore.js"></script>
     <script type="text/javascript" src="../../../_static/doctools.js"></script>
-    <link rel="top" title="imalse v0.0 alpha documentation" href="../../../index.html" />
+    <link rel="top" title="imalse 0.0 alpha documentation" href="../../../index.html" />
     <link rel="up" title="core" href="../../core.html" /> 
   </head>
   <body>
         <li class="right" >
           <a href="../../../py-modindex.html" title="Python Module Index"
              >modules</a> |</li>
-        <li><a href="../../../index.html">imalse v0.0 alpha documentation</a> &raquo;</li>
+        <li><a href="../../../index.html">imalse 0.0 alpha documentation</a> &raquo;</li>
           <li><a href="../../index.html" >Module code</a> &raquo;</li>
           <li><a href="../../core.html" accesskey="U">core</a> &raquo;</li> 
       </ul>
     <span class="k">def</span> <span class="nf">SetAttribute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> <span class="k">pass</span>
 
 <span class="kn">import</span> <span class="nn">ns.network</span>
-<div class="viewcode-block" id="TopologyReader"><a class="viewcode-back" href="../../../API.html#core.ns3.Topology.TopologyReader">[docs]</a><span class="k">class</span> <span class="nc">TopologyReader</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+<div class="viewcode-block" id="TopologyReader"><a class="viewcode-back" href="../../../api.html#core.ns3.Topology.TopologyReader">[docs]</a><span class="k">class</span> <span class="nc">TopologyReader</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
     <span class="sd">&quot;&quot;&quot;base class for Topology Reader&quot;&quot;&quot;</span>
     <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fileName</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">NodeCreator</span><span class="o">=</span><span class="n">ns</span><span class="o">.</span><span class="n">network</span><span class="o">.</span><span class="n">Node</span><span class="p">):</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">m_linksList</span><span class="o">=</span> <span class="p">[]</span>
 
     <span class="k">def</span> <span class="nf">LinksSize</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m_linksList</span><span class="p">)</span>
+
 </div>
-<div class="viewcode-block" id="InetTopologyReader"><a class="viewcode-back" href="../../../API.html#core.ns3.Topology.InetTopologyReader">[docs]</a><span class="k">class</span> <span class="nc">InetTopologyReader</span><span class="p">(</span><span class="n">TopologyReader</span><span class="p">):</span>
+<span class="k">def</span> <span class="nf">argsort</span><span class="p">(</span><span class="n">seq</span><span class="p">):</span>
+    <span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">seq</span><span class="p">)),</span> <span class="n">key</span><span class="o">=</span><span class="n">seq</span><span class="o">.</span><span class="n">__getitem__</span><span class="p">)</span>
+
+<div class="viewcode-block" id="InetTopologyReader"><a class="viewcode-back" href="../../../api.html#core.ns3.Topology.InetTopologyReader">[docs]</a><span class="k">class</span> <span class="nc">InetTopologyReader</span><span class="p">(</span><span class="n">TopologyReader</span><span class="p">):</span>
     <span class="sd">&quot;&quot;&quot;reader for `inet topology generator file&lt;http://topology.eecs.umich.edu/inet/&gt;`_</span>
 <span class="sd">    &quot;&quot;&quot;</span>
     <span class="k">def</span> <span class="nf">Read</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="n">nodes</span> <span class="o">=</span> <span class="n">ns</span><span class="o">.</span><span class="n">network</span><span class="o">.</span><span class="n">NodeContainer</span><span class="p">()</span>
         <span class="n">fid</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m_fileName</span><span class="p">,</span> <span class="s">&#39;r&#39;</span><span class="p">)</span>
         <span class="n">i</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
+        <span class="n">node_name_list</span> <span class="o">=</span> <span class="p">[]</span>
         <span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
             <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
             <span class="n">line</span> <span class="o">=</span> <span class="n">fid</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                     <span class="n">node</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">m_nodeMap</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
                 <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
                     <span class="n">node</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NodeCreator</span><span class="p">()</span>
+                    <span class="n">node_name_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
                     <span class="n">nodes</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">node</span><span class="p">)</span>
                     <span class="bp">self</span><span class="o">.</span><span class="n">m_nodeMap</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">node</span>
 
             <span class="bp">self</span><span class="o">.</span><span class="n">AddLink</span><span class="p">(</span><span class="n">link</span><span class="p">)</span>
 
         <span class="k">print</span> <span class="s">&#39;finish scanning topology, there are [</span><span class="si">%i</span><span class="s">] nodes&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">nodes</span><span class="o">.</span><span class="n">GetN</span><span class="p">())</span>
-        <span class="k">return</span> <span class="n">nodes</span>
+
+        <span class="c"># can only deal with case that node name is string that can be changed int, like &#39;1&#39;, &#39;2&#39; ...</span>
+        <span class="n">node_id_list</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">node_name_list</span><span class="p">]</span>
+        <span class="k">assert</span><span class="p">(</span> <span class="nb">len</span><span class="p">(</span><span class="n">node_id_list</span><span class="p">)</span> <span class="o">==</span>  <span class="nb">max</span><span class="p">(</span><span class="n">node_id_list</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="c"># must be continous</span>
+        <span class="c"># sort the node according to node id</span>
+        <span class="n">sort_idx</span> <span class="o">=</span> <span class="n">argsort</span><span class="p">(</span><span class="n">node_id_list</span><span class="p">)</span>
+        <span class="n">order_nodes</span> <span class="o">=</span> <span class="n">ns</span><span class="o">.</span><span class="n">network</span><span class="o">.</span><span class="n">NodeContainer</span><span class="p">()</span>
+        <span class="k">for</span> <span class="n">idx</span> <span class="ow">in</span> <span class="n">sort_idx</span><span class="p">:</span>
+            <span class="n">order_nodes</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">nodes</span><span class="o">.</span><span class="n">Get</span><span class="p">(</span><span class="n">idx</span><span class="p">))</span>
+