Source

imalse / core / ns3 / node / imalse_netns_node.py

Full commit
import sys

from core.real.node import PhysicalNode
from core.ns3.util.netns3 import NetnsNode

class ImalseNetnsNode(NetnsNode, PhysicalNode):
    """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)
        PhysicalNode.__init__(self)

    def ping(self, sock, data, threaded):        
        cmd = ["ping", "-b", "-c", str(data.num_packets), "-i", str(data.interval),\
               "-l", str(data.preload), "-s", str(data.packet_size),\
                data.hostname]
        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'