예제 #1
0
    def __init__(self, mininet, stdin=sys.stdin, script=None):
        """Start and run interactive or batch mode CLI
           mininet: Mininet network object
           stdin: standard input for CLI
           script: script to run in batch mode"""

        if mobility.isMobility == False and mobility.DRAW and mininet.alreadyPlotted == False:
            mininet.checkAPAdhoc()

            for sta in mininet.stations:
                if 'position' not in sta.params:
                    sta.params['position'] = 0, 0, 0

            if mobility.accessPoints == []:
                mobility.accessPoints = mininet.accessPoints
            if mobility.stations == []:
                mobility.stations = mininet.stations

            nodes = mininet.stations + mininet.accessPoints + mininet.plotNodes

            try:
                if mininet.is3d:
                    plot3d.instantiateGraph(mininet.MAX_X, mininet.MAX_Y,
                                            mininet.MAX_Z)
                    plot3d.graphInstantiateNodes(nodes)
                else:
                    plot2d.instantiateGraph(mininet.MAX_X, mininet.MAX_Y)
                    plot2d.plotGraph(nodes, mininet.srcConn, mininet.dstConn)
                    plot2d.graphPause()
            except:
                info(
                    'Warning: This OS does not support GUI. Running without GUI.\n'
                )
                mobility.DRAW = False

        self.mn = mininet
        # Local variable bindings for py command
        self.locals = {'net': mininet}
        # Attempt to handle input
        self.stdin = stdin
        self.inPoller = poll()
        self.inPoller.register(stdin)
        self.inputFile = script

        Cmd.__init__(self)
        info('*** Starting CLI:\n')

        if self.inputFile:
            self.do_source(self.inputFile)
            return

        self.initReadline()
        self.run()
예제 #2
0
 def checkDimension(self, nodes):
     try:
         if self.is3d:
             plot3d.instantiateGraph(self.MAX_X, self.MAX_Y, self.MAX_Z)
             plot3d.graphInstantiateNodes(nodes)
         else:
             plot2d.instantiateGraph(self.MAX_X, self.MAX_Y)
             plot2d.plotGraph(nodes, self.srcConn, self.dstConn)
             plot2d.graphPause()
     except:
         info(
             'Warning: This OS does not support GUI. Running without GUI.\n'
         )
         self.DRAW = False
예제 #3
0
    def __init__(self, mininet, stdin=sys.stdin, script=None):
        """Start and run interactive or batch mode CLI
           mininet: Mininet network object
           stdin: standard input for CLI
           script: script to run in batch mode"""

        if mobility.isMobility == False and mobility.DRAW:

            for sta in mininet.stations:
                if 'position' not in sta.params:
                    sta.params['position'] = 0, 0, 0

            if mobility.apList == []:
                mobility.apList = mininet.accessPoints
            if mobility.staList == []:
                mobility.staList = mininet.stations
            nodes = mininet.stations + mininet.accessPoints

            if mininet.is3d:
                plot3d.instantiateGraph(mininet.MAX_X, mininet.MAX_Y,
                                        mininet.MAX_Z)
                plot3d.graphInstantiateNodes(nodes)
            else:
                plot2d.instantiateGraph(mininet.MAX_X, mininet.MAX_Y)
                plot2d.plotGraph(nodes, [], [], mininet.MAX_X, mininet.MAX_Y)
                plot2d.graphPause()

        self.mn = mininet
        # Local variable bindings for py command
        self.locals = {'net': mininet}
        # Attempt to handle input
        self.stdin = stdin
        self.inPoller = poll()
        self.inPoller.register(stdin)
        self.inputFile = script

        Cmd.__init__(self)
        info('*** Starting CLI:\n')

        if self.inputFile:
            self.do_source(self.inputFile)
            return

        self.initReadline()
        self.run()
예제 #4
0
def instantiateGraph(mininet):
    MIN_X = mininetWiFi.MIN_X
    MIN_Y = mininetWiFi.MIN_Y
    MIN_Z = mininetWiFi.MIN_Z
    MAX_X = mininetWiFi.MAX_X
    MAX_Y = mininetWiFi.MAX_Y
    MAX_Z = mininetWiFi.MAX_Z
    nodes = mininet.stations + mininet.accessPoints
    for node in nodes:
        replayingMobility.addNode(node)

    if MIN_Z != 0 or MAX_Z != 0:
        plot3d.instantiateGraph(MIN_X, MIN_Y, MIN_Z, MAX_X, MAX_Y, MAX_Z)
        plot3d.graphInstantiateNodes(nodes)
        mininetWiFi.is3d = True
    else:
        plot2d.instantiateGraph(MIN_X, MIN_Y, MAX_X, MAX_Y)
        plot2d.plotGraph(nodes)