コード例 #1
0
ファイル: submit.py プロジェクト: rchota01/SDN
def output(partIdx):
    """Uses the student code to compute the output for test cases."""
    outputString = ''

    if partIdx == 0:  # This is agPAx
        topo = SingleSwitchTopo(2)

        NetASMSwitch.CTL_ADDRESS = "127.0.0.1"
        NetASMSwitch.CTL_PORT = 7791

        print "a. Firing up Mininet"
        net = Mininet(topo,
                      switch=NetASMSwitch,
                      autoSetMacs=True,
                      controller=lambda name: RemoteController(name))

        NetASMSwitch.start_datapath(net.switches,
                                    address="127.0.0.1",
                                    port=6633)
        net.start()

        h1 = net.get('h1')
        h2 = net.get('h2')

        print "b. Starting Test"
        # Start pings
        outputString += h1.cmd('ping', '-c2', h2.IP())
        outputString += h2.cmd('ping', '-c2', h1.IP())

        print "c. Stopping Mininet"
        net.stop()
        NetASMSwitch.stop_datapath()

    return outputString.strip()
コード例 #2
0
def test():
    op = OptionParser()
    op.add_option('--cli', action="store_true", dest="cli")
    op.add_option('--ports', action="store", dest="ports")

    op.set_defaults(cli=False, ports=2)
    options, args = op.parse_args()

    topo = SingleSwitchTopo(int(options.ports))

    NetASMSwitch.CTL_ADDRESS = "127.0.0.1"
    NetASMSwitch.CTL_PORT = 7791

    net = Mininet(topo,
                  switch=NetASMSwitch,
                  autoSetMacs=True,
                  controller=lambda name: RemoteController(name))

    NetASMSwitch.start_datapath(net.switches, address="127.0.0.1", port=6633)
    net.start()

    if options.cli:
        CLI(net)
    else:
        net.pingAll()

    net.stop()
    NetASMSwitch.stop_datapath()
コード例 #3
0
ファイル: submit.py プロジェクト: 09beeihaq/Coursera-SDN
def output(partIdx):
  """Uses the student code to compute the output for test cases."""
  outputString = ''

  if partIdx == 0: # This is agPAx
    topo = SingleSwitchTopo(2)

    NetASMSwitch.CTL_ADDRESS = "127.0.0.1"
    NetASMSwitch.CTL_PORT = 7791

    print "a. Firing up Mininet"
    net = Mininet(topo, switch=NetASMSwitch, autoSetMacs=True, controller=lambda name: RemoteController(name))

    NetASMSwitch.start_datapath(net.switches, address="127.0.0.1", port=6633)
    net.start()

    h1 = net.get('h1')
    h2 = net.get('h2')

    print "b. Starting Test"
    # Start pings
    outputString += h1.cmd('ping', '-c2', h2.IP())
    outputString += h2.cmd('ping', '-c2', h1.IP())

    print "c. Stopping Mininet"
    net.stop()
    NetASMSwitch.stop_datapath()

  return outputString.strip()
コード例 #4
0
def test():
    op = OptionParser()
    op.add_option('--cli', action="store_true", dest="cli")
    op.add_option('--ports', action="store", dest="ports")

    op.set_defaults(cli=False, ports=2)
    options, args = op.parse_args()

    topo = SingleSwitchTopo(int(options.ports))

    NetASMSwitch.CTL_ADDRESS = "127.0.0.1"
    NetASMSwitch.CTL_PORT = 7791

    net = Mininet(topo, switch=NetASMSwitch, autoSetMacs=True, controller=lambda name: RemoteController(name))

    NetASMSwitch.start_datapath(net.switches, address="127.0.0.1", port=6633)
    net.start()

    if options.cli:
        CLI(net)
    else:
        net.pingAll()

    net.stop()
    NetASMSwitch.stop_datapath()
コード例 #5
0
def test():
    topo = SingleSwitchTopo(2)

    NetASMSwitch.CTL_ADDRESS = "127.0.0.1"
    NetASMSwitch.CTL_PORT = 7791

    net = Mininet(topo, switch=NetASMSwitch, autoSetMacs=True, controller=lambda name: RemoteController(name))

    for switch in net.switches:
        switch.policy = 'netasm.examples.netasm.standalone.hub'

    NetASMSwitch.start_datapath(net.switches, address="127.0.0.1", port=6633, standalone=True)
    net.start()

    net.pingAll()

    net.stop()
    NetASMSwitch.stop_datapath()