基于TD3的sdn流量调度

半成品未完成,供参考:

采用mininet和ryu实验,

创建fattree(4,8,8),带宽设置为10Gbps,负荷为80%,主机数为8,寻找4条最短路径,产生的流量数为40。

状态为(40,5)

速率维数为2*72

路径为2*28(28表示不同主机的通信)

动作维度为2*(72+28)

评价指标:

Flow Completion Time 流完成时间

Deadline Meet Rate 截止时间完成率也就是数据流在规定的时间是否到达目的地

Tputi  FCT / Size

定义输入的数据流分布:

flowsize数据流字节大小的分布函数,

小于等于6的占0.15

(6,13)大小的占0.2-0.15=0.05

(13,19)大小的占0.3-0.2=0.1

以此类推

首先通过环境reset初始化网络:

Fattree结构:

https://blog.csdn.net/qq_49588762/article/details/115296838

整个拓扑网络分为三个层次:自上而下分别为边缘层(edge)、汇聚层(aggregate)和核心层(core),其中汇聚层交换机与边缘层交换机构成一个pod,交换设备均采用商用交换设备。下图是pod=4=k density=2,主机数16,density =2表示每个接入层交换机2台主机,交换机20台,核心层4台,汇聚层8台,边缘层8台。

https://img-blog.csdnimg.cn/20210329110740739.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ5NTg4NzYy,size_16,color_FFFFFF,t_70#pic_center

获取到网络数据:主要是主机名,对应IP地址和MAC地址

self.HostList, self.HostIPList, self.HostNameIPMAC------------- [<Host h001: h001-eth0:10.1.0.1 pid=26371> , <Host h002: h002-eth0:10.2.0.1 pid=26373> , <Host h003: h003-eth0:10.3.0.1 pid=26375> , <Host h004: h004-eth0:10.4.0.1 pid=26377> , <Host h005: h005-eth0:10.5.0.1 pid=26379> , <Host h006: h006-eth0:10.6.0.1 pid=26381> , <Host h007: h007-eth0:10.7.0.1 pid=26383> , <Host h008: h008-eth0:10.8.0.1 pid=26385> ] ['10.1.0.1', '10.2.0.1', '10.3.0.1', '10.4.0.1', '10.5.0.1', '10.6.0.1', '10.7.0.1', '10.8.0.1'] {'h001': ('10.1.0.1', '00:00:00:00:00:01'), 'h002': ('10.2.0.1', '00:00:00:00:00:02'), 'h003': ('10.3.0.1', '00:00:00:00:00:03'), 'h004': ('10.4.0.1', '00:00:00:00:00:04'), 'h005': ('10.5.0.1', '00:00:00:00:00:05'), 'h006': ('10.6.0.1', '00:00:00:00:00:06'), 'h007': ('10.7.0.1', '00:00:00:00:00:07'), 'h008': ('10.8.0.1', '00:00:00:00:00:08')}

再得到access-table,即交换机及对应端口与8台主机的连接关系:

Access_table------------- {('3001', '3'): ('10.1.0.1', '00:00:00:00:00:01'), ('3002', '3'): ('10.2.0.1', '00:00:00:00:00:02'), ('3003', '3'): ('10.3.0.1', '00:00:00:00:00:03'), ('3004', '3'): ('10.4.0.1', '00:00:00:00:00:04'), ('3005', '3'): ('10.5.0.1', '00:00:00:00:00:05'), ('3006', '3'): ('10.6.0.1', '00:00:00:00:00:06'), ('3007', '3'): ('10.7.0.1', '00:00:00:00:00:07'), ('3008', '3'): ('10.8.0.1', '00:00:00:00:00:08')}

然后就是安装上面对应主机和交换机出端口的流表:

上面的print输出如下:

k,v------------- ('3001', '3') ('10.1.0.1', '00:00:00:00:00:01')

sw,port,ip------------- 3001 3 10.1.0.1

cmd------------- ovs-ofctl add-flow 3001 -O OpenFlow13

'table=0,idle_timeout=0,hard_timeout=0,priority=1,arp,nw_dst=10.1.0.1,actions=output:3'

cmd------------- ovs-ofctl add-flow 3001 -O OpenFlow13

 'table=1,idle_timeout=0,hard_timeout=0,priority=1,ip,nw_dst=10.1.0.1,actions=output:3'

上面增加的两条流表的意思是:交换机3001收到的目的IP为10.1.0.1的arp和ip数据包出端口是3端口。

OpenvSwitch的操作命令有若干个,其中比较重要的有

ovs-vsctl   获取或者更改ovs-vswitchd的配置信息,此工具操作的时候会更新ovsdb-server中的数据库

ovs-ofctl     操作交换机里的流表

ovsdb-tool  对ovsdb数据库操作,不经过ovsdb-server模块

然后通过子进程将ryurest运行起来:

再通过self.envrest.rest_api()获取交换机id和端口信息:

    def rest_api(self):

        ##########################################

        # 交换机id、端口信息

        ##########################################

        url1 = 'http://127.0.0.1:8080/v1.0/topology/switches'

        r1 = requests.get(url1)

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

       self.switch_port_table = sorted(self.switch_port_table.items(), key=lambda x: x[0])

        print (self.switch_port_table)

#[('00000000000003e9', {'1': '1001-eth1', '4': '1001-eth4', '2': '1001-eth2', '3': '1001-eth3'}), ('00000000000003ea', {'1': '1002-eth1', '4': '1002-eth4', '2': '1002-eth2', '3': '1002-eth3'}), ('00000000000003eb', {'1': '1003-eth1', '4': '1003-eth4', '2': '1003-eth2', '3': '1003-eth3'}), ('00000000000003ec', {'1': '1004-eth1', '4': '1004-eth4', '2': '1004-eth2', '3': '1004-eth3'}), ('00000000000007d1', {'1': '2001-eth1', '4': '2001-eth4', '2': '2001-eth2', '3': '2001-eth3'}), ('00000000000007d2', {'1': '2002-eth1', '4': '2002-eth4', '2': '2002-eth2', '3': '2002-eth3'}), ('00000000000007d3', {'4': '2003-eth4', '1': '2003-eth1', '2': '2003-eth2', '3': '2003-eth3'}), ('00000000000007d4', {'1': '2004-eth1', '4': '2004-eth4', '2': '2004-eth2', '3': '2004-eth3'}), ('00000000000007d5', {'4': '2005-eth4', '1': '2005-eth1', '2': '2005-eth2', '3': '2005-eth3'}), ('

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

chenos121

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值