Mininet with SSL connection

本文介绍了一种使用Python脚本在Mininet环境中配置多节点Open vSwitch网络的方法,通过调整参数实现与远程控制器的SSL连接,确保网络的可靠性和安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#!/usr/bin/python
# author:Spark.liu , date:2014/6/10
# this script will add a linear a topolgoy with your set  switch number,
# the switch will connect to remote controller your set by SSL session , so before running it ,pls add your certificaion to local OVS and remote controller  
# for running this script ,your system should installed Mininet and OVS


from mininet.net import Mininet
from mininet.node import Controller,RemoteController
from mininet.cli import CLI
from mininet.log import setLogLevel,info

# change following parameter to simulate swtich number
switch_number = 10

# change following parameter with your remote controller IP
Controller_ip = "1.1.1.1"

def emptyNet():
    net = Mininet( controller=RemoteController )
    count = 1
    s_list = []
    while ( count < switch_number+1 ):
         host_str = 'h%d'   %(count)
         switch_str = 's%d' %(count)
         host = net.addHost( host_str )
         switch = net.addSwitch( switch_str )
     s_list.append(switch)
         net.addLink( host, switch)
         count += 1
 
    for i,s in enumerate(s_list):
        if i <  switch_number-1 :
            net.addLink(s_list[i],s_list[i+1])
    net.start()

    # ssh into controller from each swtich instance
    for i,s in enumerate(s_list):
       # s.cmd("ovs-vsctl set-controller s%s ssl:%s:6633" % (i+1,Controller_ip))
        s.cmd("ovs-vsctl set-controller s%s other-config:datapath_id=11100000000%s  ssl:%s:6633" % (i+1,i+1,Controller_ip))
    CLI(net)
    net.stop()

if __name__ == '__main__':
    setLogLevel('info')
    emptyNet()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值