码迷,mamicode.com
首页 > 其他好文 > 详细

[环境搭建]SDN网络感知服务与最短路径应用

时间:2018-05-27 10:42:59      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:weight   help   ror   The   .com   forward   ppa   python模块   err   

  • 1.安装python模块networkx

pip install networkx

技术分享图片

  • 2.给Network_Awareness.py加修改权限

chmod 777 Network_Awareness.py

  • 3.下载安装ryu

git clone git://github.com/osrg/ryu.git

cd ryu sudo python

./setup.py install

#若已安装ryu,删了再装, pip uninstall ryu

  • 4.修改“***/ryu/ryu/flags.py"文件,在实例“CONF”调用的方法“register_cli_opts”的字典里添加:

CONF.register_cli_opts([

# k_shortest_forwarding

cfg.IntOpt(‘k-paths‘, default=1, help=‘number for k shortest paths‘),

cfg.StrOpt(‘weight‘, default=‘hop‘,

help=‘weight type of computing shortest path.‘)])

如图:

  • 技术分享图片

  • 5.修改文件"/ryu/ryu/topology/switches.py",在“PortData”类的初始化方法中添加了实例变量“self.delay”:

self.delay = 0

技术分享图片

  • 在“@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)”下添加:

def packet_in_handler(self, ev):

# add code for getting LLDP packet receiving timestamp

recv_timestamp = time.time()

if not self.link_discovery:

return

msg = ev.msg

try:

src_dpid, src_port_no = LLDPPacket.lldp_parse(msg.data)

except LLDPPacket.LLDPUnknownFormat as e:

# This handler can receive all the packtes which can be

# not-LLDP packet. Ignore it silently

return

dst_dpid = msg.datapath.id

if msg.datapath.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:

dst_port_no = msg.in_port

elif msg.datapath.ofproto.OFP_VERSION >= ofproto_v1_2.OFP_VERSION:

dst_port_no = msg.match[‘in_port‘]

else:

LOG.error(‘cannot accept LLDP. unsupported version. %x‘,

msg.datapath.ofproto.OFP_VERSION)

# get the lldp delay, and save it into port_data.

for port in self.ports.keys():

if src_dpid == port.dpid and src_port_no == port.port_no:

send_timestamp = self.ports[port].timestamp

if send_timestamp:

self.ports[port].delay = recv_timestamp - send_timestamp

    • 技术分享图片

  • 6.重新编译安装ryu

cd ***/ryu

python setup.py install

  • 7.启动ryu控制器

ryu-manager shortest_forwarding.py --observe-links --k-paths=2 --weight=bw

  • 8.开启mininet并连接控制器

mn --controller=remote,ip=192.168.1.197,port=6653

注:“ip”填写的是启动ryu控制器的那台主机的ip

[环境搭建]SDN网络感知服务与最短路径应用

标签:weight   help   ror   The   .com   forward   ppa   python模块   err   

原文地址:https://www.cnblogs.com/ownhp/p/9094912.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!