3

1、分组情况
|

学号
|
姓名
|
贡献度
|
| ---- | ---- | ---- | ---- |
|
031802606
|
胡佳伟
|
25%
|
|
031802608
|
黄霄瑞(组长)
|
35%
|
|
031802603
|
陈书航
|
20%
|
|
031802605
|
贺劲渲
|
20%
|
2实现关键

搭建拓扑代码
from mininet.topo import Topo

class MyTopo( Topo ):

def __init__( self ):

    # initilaize topology   
    Topo.__init__( self )

    # add hosts and switches
    host1 = self.addHost( 'h1' )
    host2 = self.addHost( 'h2' )
    host3 = self.addHost( 'h3' )
    host4 = self.addHost( 'h4' )
    switch1 = self.addSwitch( 's1' )
    switch2 = self.addSwitch( 's2' )
    switch3 = self.addSwitch( 's3' )
    switch4 = self.addSwitch( 's4' )
   	

    # add links
    self.addLink(host1,switch1)
    self.addLink(switch1,switch2)
    self.addLink(switch1,switch3)
    self.addLink(switch1,switch4)
    self.addLink(switch2,switch4)
    self.addLink(switch3,switch4)
    self.addLink(switch4,host2)
    self.addLink(switch4,host3)
    self.addLink(switch4,host4)

topos = { 'mytopo': ( lambda: MyTopo() ) }
流表代码:

设置h2发往s4的端口1的流表,优先级最高

	h2_to_s4_1 ='{"flow": [{"id": "41","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.2/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
        		'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "1"},"order": "0"}]}}]},'\
        		'"priority": "115","cookie": "1","table_id": "0"}]}'
	lh2_to_s4_1 ='{"flow": [{"id": "41","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.2/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
            	'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "2"},"order": "0"}]}}]},'\
        		'"priority": "105","cookie": "1","table_id": "0"}]}'

	#设置h3发往s4的端口1的流表,优先级最高
	h3_to_s4_1 ='{"flow": [{"id": "51","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.3/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
            	'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "1"},"order": "0"}]}}]},'\
        		'"priority": "115","cookie": "1","table_id": "0"}]}'


	#设置h4发往s4的端口1的流表,优先级最高
	h4_to_s4_1 ='{"flow": [{"id": "61","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.4/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
            	'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "1"},"order": "0"}]}}]},'\
        		'"priority": "115","cookie": "1","table_id": "0"}]}'

	#当s4的端口1流量满载时,h2发的数据包走端口2,3的流表,优先级高	
	h2_to_s4_2 ='{"flow": [{"id": "42","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.2/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
            	'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "2"},"order": "0"}]}}]},'\
        		'"priority": "112","cookie": "1","table_id": "0"}]}'
	h2_to_s4_3 ='{"flow": [{"id": "43","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.2/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
            	'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "3"},"order": "0"}]}}]},'\
        		'"priority": "110","cookie": "1","table_id": "0"}]}'

	#当s4的端口1流量满载时,h3发的数据包走端口2,3的流表,优先级高
	h3_to_s4_2 ='{"flow": [{"id": "52","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.3/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
            	'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "2"},"order": "0"}]}}]},'\
        		'"priority": "112","cookie": "1","table_id": "0"}]}'
	h3_to_s4_3 ='{"flow": [{"id": "53","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.3/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
            	'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "3"},"order": "0"}]}}]},'\
        		'"priority": "110","cookie": "1","table_id": "0"}]}'

	#当s4的端口1流量满载时,h4发的数据包走端口2,3的流表,优先级高
	h4_to_s4_2 ='{"flow": [{"id": "62","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.4/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
            	'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "2"},"order": "0"}]}}]},'\
        		'"priority": "112","cookie": "1","table_id": "0"}]}'
	h4_to_s4_3 ='{"flow": [{"id": "63","match": {"ethernet-match":'\
           		'{"ethernet-type": {"type": "2048"}},'\
				'"ipv4-source":"10.0.0.4/32","ipv4-destination": "10.0.0.1/32"},'\
        		'"instructions": {"instruction": [{"order": "0",'\
            	'"apply-actions": {"action": [{"output-action": {'\
            	'"output-node-connector": "3"},"order": "0"}]}}]},'\
        		'"priority": "110","cookie": "1","table_id": "0"}]}'

	#s2流表
	s2_2to1='{"flow": [{"id": "1","match": {"ethernet-match":'\
        '{"ethernet-type": {"type": "2048"}},'\
		'"ipv4-source":"10.0.0.2/32","ipv4-destination": "10.0.0.1/32"},'\
        '"instructions": {"instruction": [{"order": "0",'\
        '"apply-actions": {"action": [{"output-action": {'\
        '"output-node-connector": "1"},"order": "0"}]}}]},'\
        '"priority": "105","cookie": "1","table_id": "0"}]}'
	#s3流表
	s3_2to1='{"flow": [{"id": "1","match": {"ethernet-match":'\
        	'{"ethernet-type": {"type": "2048"}},'\
			'"ipv4-source":"10.0.0.2/32","ipv4-destination": "10.0.0.1/32"},'\
        	'"instructions": {"instruction": [{"order": "0",'\
        	'"apply-actions": {"action": [{"output-action": {'\
        	'"output-node-connector": "1"},"order": "0"}]}}]},'\
        	'"priority": "105","cookie": "1","table_id": "0"}]}'
	#s1流表
	s1_234to1='{"flow": [{"id": "1","match": {"ethernet-match":'\
        	'{"ethernet-type": {"type": "2048"}},'\
			'"ipv4-source":"10.0.0.2/32","ipv4-destination": "10.0.0.1/32"},'\
        	'"instructions": {"instruction": [{"order": "0",'\
        	'"apply-actions": {"action": [{"output-action": {'\
        	'"output-node-connector": "1"},"order": "0"}]}}]},'\
        	'"priority": "105","cookie": "1","table_id": "0"}]}'

	headers = {'Content-type': 'application/json'}

操作步骤:
a.在创建拓扑前,先打开opendaylight控制器
b.创建拓扑,并查看拓扑结构
c.测试主机之间的连通
d.wireshark抓包监控流量
e.调用负载均衡程序controller.py,使用sudo python controller.py命令执行
f.查看交换机s2流表项
3、心得体会
a.胡佳伟
SDN, software Defined Network 是对传统网络架构的一次革新。经过短短两个月的学习和实践,我对sdn有了初步了解。SDN,软件定义网络,关键就是弄清楚三件事:网络、软件、软件与网络怎么结合。经过几次实验我对这些方面都有了一定了解,同时还学会了虚拟机的使用已经一些python、java的编程知识,对接口的应用也有了一定的了解。
b.黄霄瑞
学期刚开始老师就有问我们对sdn了解多少,其实当时我对sdn毫无了解,甚至都没有听过这个东西,听老师介绍后感觉又是网络又是编程这东西好难搞啊,后面老师给我们一步一步讲解,并且给我布置实验作业,我通过对实验的完成对sdn有了越来越深的了解,感觉它听着难但是真正去实践的话就还好。希望以后还有更多的机会接触和学习sdn。
c.贺劲渲
最开始选这门课时候其实没啥概念,只是为了学习要求的小贰分而已,这学期不选这个下学期也得大数据,开学后通过老师的讲解,我发现了这学分修得很有意义,sdn是一个新兴的方向,相对于传统网络结构它有着很多的优点,并且有着很大的探索空间,目前网络上关于它的知识也很少,我感觉这会是一个很有前景的方向,希望以后有机会在这方面有所发展。
d.陈书航
上学期刚学完了计算机网络,在选课时看到软件定义网络瞬间就来了兴趣,网络还能与软件挂上关系,我毅然决然选了这门课,通过课程的学习我初步了解了sdn究竟是个什么能干什么,特别是在学习过程中的几个实验确实很有意思,让我了解了不一样的网络与编程,虽然有时候会遇到困难,但克服之后可取反而更多,今后我也会继续学习相关知识,寻找其中乐趣。

posted @ 2020-11-29 16:48  misasaya  阅读(133)  评论(0)    收藏  举报