zoukankan      html  css  js  c++  java
  • 2019 SDN上机第6次作业

    一、使用Python脚本完成拓扑搭建,并连接ryu控制器。

    二。使用Ryu的REST API下发流表实现和第2次实验同样的VLAN

    
    curl -X POST -d '{
        "dpid": 1,
        "priority":1,
        "match":{
            "in_port":2
        },
        "actions":[
            {
                "type": "PUSH_VLAN",     
                "ethertype": 33024       
            },
            {
                "type": "SET_FIELD",
                "field": "vlan_vid",     
                "value": 4096            
            },
            {
                "type": "OUTPUT",
                "port": 1
            }
        ]
    }' http://127.0.0.1:8080/stats/flowentry/add
    
    
    curl -X POST -d '{
        "dpid": 1,
        "priority":1,
        "match":{
            "in_port":3
        },
        "actions":[
            {
                "type": "PUSH_VLAN",     
                "ethertype": 33024      
            },
            {
                "type": "SET_FIELD",
                "field": "vlan_vid",     
                "value": 4097            
            },
            {
                "type": "OUTPUT",
                "port": 1
            }
        ]
    }' http://127.0.0.1:8080/stats/flowentry/add
    
    
    curl -X POST -d '{
        "dpid": 1,
        "priority":1,
        "match":{
            "in_port":4
        },
        "actions":[
            {
                "type": "PUSH_VLAN",     
                "ethertype": 33024       
            },
            {
                "type": "SET_FIELD",
                "field": "vlan_vid",     
                "value": 4098            
            },
            {
                "type": "OUTPUT",
                "port": 1
            }
        ]
    }' http://127.0.0.1:8080/stats/flowentry/add
    
    
    
    
    curl -X POST -d '{
        "dpid": 1,
        "priority":1,
        "match":{
            "dl_vlan": "0"
        },
        "actions":[
            {
                "type": "POP_VLAN",     
            },
            {
                "type": "OUTPUT",
                "port": 2
            }
        ]
    }' http://localhost:8080/stats/flowentry/add
    
    #向端口3转发
    curl -X POST -d '{
        "dpid": 1,
        "priority":1,
        "match":{
            "dl_vlan": "1"
        },
        "actions":[
            {
                "type": "POP_VLAN",     
            },
            {
                "type": "OUTPUT",
                "port": 3
            }
        ]
    }' http://localhost:8080/stats/flowentry/add
    
    #向端口4转发
    curl -X POST -d '{
        "dpid": 1,
        "priority":1,
        "match":{
            "dl_vlan": "2"
        },
        "actions":[
            {
                "type": "POP_VLAN",     
            },
            {
                "type": "OUTPUT",
                "port": 4
            }
        ]
    }' http://localhost:8080/stats/flowentry/add
    
    
    #s2
    
    
    curl -X POST -d '{
        "dpid": 2,
        "priority":1,
        "match":{
            "in_port":2
        },
        "actions":[
            {
                "type": "PUSH_VLAN",     
                "ethertype": 33024      
            },
            {
                "type": "SET_FIELD",
                "field": "vlan_vid",    
                "value": 4096           
            },
            {
                "type": "OUTPUT",
                "port": 1
            }
        ]
    }' http://127.0.0.1:8080/stats/flowentry/add
    
    
    curl -X POST -d '{
        "dpid": 2,
        "priority":1,
        "match":{
            "in_port":3
        },
        "actions":[
            {
                "type": "PUSH_VLAN",     
                "ethertype": 33024       
            },
            {
                "type": "SET_FIELD",
                "field": "vlan_vid",     
                "value": 4097            
            },
            {
                "type": "OUTPUT",
                "port": 1
            }
        ]
    }' http://127.0.0.1:8080/stats/flowentry/add
    
    
    curl -X POST -d '{
        "dpid": 2,
        "priority":1,
        "match":{
            "in_port":4
        },
        "actions":[
            {
                "type": "PUSH_VLAN",     
                "ethertype": 33024       
            },
            {
                "type": "SET_FIELD",
                "field": "vlan_vid",     
                "value": 4098            
            },
            {
                "type": "OUTPUT",
                "port": 1
            }
        ]
    }' http://127.0.0.1:8080/stats/flowentry/add
    
    
    
    
    curl -X POST -d '{
        "dpid": 2,
        "priority":1,
        "match":{
            "dl_vlan": "0"
        },
        "actions":[
            {
                "type": "POP_VLAN",    
            },
            {
                "type": "OUTPUT",
                "port": 2
            }
        ]
    }' http://localhost:8080/stats/flowentry/add
    
    #向端口3转发
    curl -X POST -d '{
        "dpid": 2,
        "priority":1,
        "match":{
            "dl_vlan": "1"
        },
        "actions":[
            {
                "type": "POP_VLAN",     
            },
            {
                "type": "OUTPUT",
                "port": 3
            }
        ]
    }' http://localhost:8080/stats/flowentry/add
    
    #向端口4转发
    curl -X POST -d '{
        "dpid": 2,
        "priority":1,
        "match":{
            "dl_vlan": "2"
        },
        "actions":[
            {
                "type": "POP_VLAN",     
            },
            {
                "type": "OUTPUT",
                "port": 4
            }
        ]
    }' http://localhost:8080/stats/flowentry/add
    

    3.对比两种方法,写出你的实验体会

    ryu查看流表跟方便。

  • 相关阅读:
    android.os.FileUriExposedException: exposed beyond app through ClipData.Item.getUri()踩坑记录
    【Android】 recycleview显示空白踩坑
    eclipse导入新项目,文件没有报错,但项目名一直报红
    【原因分析】The superclass "javax.servlet.http.HttpServlet" was not found on the Java Bu
    SSM框架的搭建-xml文件报错-.xsd文件缺失
    命令行安装matplotlib中遇到问题及解决(简单记录)
    eclipse里tomcat子容器缺失解决
    导入javaFX
    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
    eclipse左边目录(Project Explorer)不小心删除后怎么找回来
  • 原文地址:https://www.cnblogs.com/booob/p/11985099.html
Copyright © 2011-2022 走看看