使用遥控器无法访问网络
No reachability in the network with remote controller
我正在使用下面的代码。在这里,我首先将 hc 添加为主机,在启动 net 之后,我 运行 在 hc 中进行了一个简单的切换,使其成为一个控制器。问题是网络不可达,即 ping 不工作。谁能告诉我是什么导致了这种行为?
def myNetwork():
# Create an instance of Mininet class i.e. the network with default values
net = Mininet()
info( '*** Adding controller\n' )
#c0 = net.addController('c0')
hc = net.addHost( 'hc', ip='127.0.0.1' )
info( '*** Adding switches\n')
s1 = net.addSwitch('s1')
s5 = net.addSwitch('s5')
s2 = net.addSwitch('s2')
info( '*** Adding links\n')
net.addLink(hc, s1)
net.addLink(s1, s5, cls=TCLink)
net.addLink(s5, s2, cls=TCLink)
hosts = list()
# add all remaining hosts to s2
info( '*** Adding hosts and Links\n')
for i in range (1,11):
name = 'h'+str(i)
host = net.addHost(name)
net.addLink( s2, host, cls=TCLink)
hosts.append(host)
info( '*** Starting network\n')
net.start()
hc.cmdPrint('ryu-manager ryu/simple_switch_13.py \
--verbose 1> tmp/controller-ryu.log 2>&1 &')
# Start the Mininet CLI to run commands
CLI(net)
# Stop the network
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
myNetwork()
代码中遗漏了很多部分,并且缩进不正确。
创建遥控器不需要hc。您可以使用 system("START CONTROLLER COMMAND") 来 运行 像 ryu 这样的远程控制器(但我建议 运行 脚本之外的命令)。比使用 net.addController 函数使用 cls=RemoteController.
def myNetwork():
# Create an instance of Mininet class i.e. the network with default values
net = Mininet(controller=RemoteController)
#info( '*** Adding controller\n' )
c0 = net.addController('c0', cls=RemoteController)
#hc = net.addHost( 'hc', ip='127.0.0.1' )
info( '*** Adding switches\n')
s1 = net.addSwitch('s1')
s5 = net.addSwitch('s5')
s2 = net.addSwitch('s2')
info( '*** Adding links\n')
#net.addLink(hc, s1)
net.addLink(s1, s5, cls=TCLink)
net.addLink(s5, s2, cls=TCLink)
hosts = list()
# add all remaining hosts to s2
info( '*** Adding hosts and Links\n')
for i in range (1,11):
name = 'h'+str(i)
host = net.addHost(name)
net.addLink( s2, host, cls=TCLink)
hosts.append(host)
info( '*** Starting network\n')
net.start()
#hc.cmdPrint('ryu-manager ryu/simple_switch_13.py \
# --verbose 1> tmp/controller-ryu.log 2>&1 &')
# Start the Mininet CLI to run commands
CLI(net)
# Stop the network
net.stop()
if __name__ == '__main__':
from mininet.log import setLogLevel, info
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.node import RemoteController
setLogLevel( 'info' )
myNetwork()
我正在使用下面的代码。在这里,我首先将 hc 添加为主机,在启动 net 之后,我 运行 在 hc 中进行了一个简单的切换,使其成为一个控制器。问题是网络不可达,即 ping 不工作。谁能告诉我是什么导致了这种行为?
def myNetwork():
# Create an instance of Mininet class i.e. the network with default values
net = Mininet()
info( '*** Adding controller\n' )
#c0 = net.addController('c0')
hc = net.addHost( 'hc', ip='127.0.0.1' )
info( '*** Adding switches\n')
s1 = net.addSwitch('s1')
s5 = net.addSwitch('s5')
s2 = net.addSwitch('s2')
info( '*** Adding links\n')
net.addLink(hc, s1)
net.addLink(s1, s5, cls=TCLink)
net.addLink(s5, s2, cls=TCLink)
hosts = list()
# add all remaining hosts to s2
info( '*** Adding hosts and Links\n')
for i in range (1,11):
name = 'h'+str(i)
host = net.addHost(name)
net.addLink( s2, host, cls=TCLink)
hosts.append(host)
info( '*** Starting network\n')
net.start()
hc.cmdPrint('ryu-manager ryu/simple_switch_13.py \
--verbose 1> tmp/controller-ryu.log 2>&1 &')
# Start the Mininet CLI to run commands
CLI(net)
# Stop the network
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
myNetwork()
代码中遗漏了很多部分,并且缩进不正确。
创建遥控器不需要hc。您可以使用 system("START CONTROLLER COMMAND") 来 运行 像 ryu 这样的远程控制器(但我建议 运行 脚本之外的命令)。比使用 net.addController 函数使用 cls=RemoteController.
def myNetwork():
# Create an instance of Mininet class i.e. the network with default values
net = Mininet(controller=RemoteController)
#info( '*** Adding controller\n' )
c0 = net.addController('c0', cls=RemoteController)
#hc = net.addHost( 'hc', ip='127.0.0.1' )
info( '*** Adding switches\n')
s1 = net.addSwitch('s1')
s5 = net.addSwitch('s5')
s2 = net.addSwitch('s2')
info( '*** Adding links\n')
#net.addLink(hc, s1)
net.addLink(s1, s5, cls=TCLink)
net.addLink(s5, s2, cls=TCLink)
hosts = list()
# add all remaining hosts to s2
info( '*** Adding hosts and Links\n')
for i in range (1,11):
name = 'h'+str(i)
host = net.addHost(name)
net.addLink( s2, host, cls=TCLink)
hosts.append(host)
info( '*** Starting network\n')
net.start()
#hc.cmdPrint('ryu-manager ryu/simple_switch_13.py \
# --verbose 1> tmp/controller-ryu.log 2>&1 &')
# Start the Mininet CLI to run commands
CLI(net)
# Stop the network
net.stop()
if __name__ == '__main__':
from mininet.log import setLogLevel, info
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.node import RemoteController
setLogLevel( 'info' )
myNetwork()