当前位置: 首页>>代码示例>>Python>>正文


Python ofp_event.EventOFPPacketIn方法代码示例

本文整理汇总了Python中ryu.controller.ofp_event.EventOFPPacketIn方法的典型用法代码示例。如果您正苦于以下问题:Python ofp_event.EventOFPPacketIn方法的具体用法?Python ofp_event.EventOFPPacketIn怎么用?Python ofp_event.EventOFPPacketIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ryu.controller.ofp_event的用法示例。


在下文中一共展示了ofp_event.EventOFPPacketIn方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_Packet_in

# 需要导入模块: from ryu.controller import ofp_event [as 别名]
# 或者: from ryu.controller.ofp_event import EventOFPPacketIn [as 别名]
def test_Packet_in(self):
        sa = SimpleArp()

        datapath = _Datapath()
        e = ethernet.ethernet(dstMac, srcMac, ether.ETH_TYPE_ARP)
        a = arp(1, 0x0800, 6, 4, 1, srcMac, srcIp, targetMac, dstIp)
        p = Packet()
        p.add_protocol(e)
        p.add_protocol(a)
        p.serialize()

        packetIn = OFPPacketIn(datapath, match=OFPMatch(in_port=1), data=buffer(p.data))

        ev = ofp_event.EventOFPPacketIn(packetIn)

        result = sa.packet_in_handler(ev)
        self.assertEqual(result, 0) 
开发者ID:ttsubo,项目名称:simpleRouter,代码行数:19,代码来源:test_SimpleArp.py

示例2: test_pkt_in_filter_pass

# 需要导入模块: from ryu.controller import ofp_event [as 别名]
# 或者: from ryu.controller.ofp_event import EventOFPPacketIn [as 别名]
def test_pkt_in_filter_pass(self):
        datapath = ProtocolDesc(version=ofproto_v1_3.OFP_VERSION)
        e = ethernet.ethernet(mac.BROADCAST_STR,
                              mac.BROADCAST_STR,
                              ether.ETH_TYPE_8021Q)
        v = vlan.vlan()
        i = ipv4.ipv4()
        pkt = (e / v / i)
        pkt.serialize()
        pkt_in = ofproto_v1_3_parser.OFPPacketIn(datapath,
                                                 data=six.binary_type(pkt.data))
        ev = ofp_event.EventOFPPacketIn(pkt_in)
        ok_(self.app.packet_in_handler(ev)) 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:15,代码来源:test_ofp_pktinfilter.py

示例3: test_pkt_in_filter_discard

# 需要导入模块: from ryu.controller import ofp_event [as 别名]
# 或者: from ryu.controller.ofp_event import EventOFPPacketIn [as 别名]
def test_pkt_in_filter_discard(self):
        datapath = ProtocolDesc(version=ofproto_v1_3.OFP_VERSION)
        e = ethernet.ethernet(mac.BROADCAST_STR,
                              mac.BROADCAST_STR,
                              ether.ETH_TYPE_IP)
        i = ipv4.ipv4()
        pkt = (e / i)
        pkt.serialize()
        pkt_in = ofproto_v1_3_parser.OFPPacketIn(datapath,
                                                 data=six.binary_type(pkt.data))
        ev = ofp_event.EventOFPPacketIn(pkt_in)
        ok_(not self.app.packet_in_handler(ev)) 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:14,代码来源:test_ofp_pktinfilter.py

示例4: test_pkt_in_filter_truncated

# 需要导入模块: from ryu.controller import ofp_event [as 别名]
# 或者: from ryu.controller.ofp_event import EventOFPPacketIn [as 别名]
def test_pkt_in_filter_truncated(self):
        datapath = ProtocolDesc(version=ofproto_v1_3.OFP_VERSION)
        truncated_data = ''
        pkt_in = ofproto_v1_3_parser.OFPPacketIn(datapath,
                                                 data=truncated_data)
        ev = ofp_event.EventOFPPacketIn(pkt_in)
        ok_(not self.app.packet_in_handler(ev)) 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:9,代码来源:test_ofp_pktinfilter.py

示例5: test_Packet_in_1_arpRequest

# 需要导入模块: from ryu.controller import ofp_event [as 别名]
# 或者: from ryu.controller.ofp_event import EventOFPPacketIn [as 别名]
def test_Packet_in_1_arpRequest(self):
        print "*** Case1: HOST1からARP Request受信 ***"

        sr = SimpleForward()
        dstMac = "ff:ff:ff:ff:ff:ff"
        srcMac = HOST_MACADDR1
        srcIp = HOST_IPADDR1
        dstIp = ROUTER_IPADDR1
        targetMac = dstMac
        targetIp = dstIp

        datapath = _Datapath()
        e = ethernet(dstMac, srcMac, ether.ETH_TYPE_ARP)
        a = arp(1, 0x0800, 6, 4, 1, srcMac, srcIp, targetMac, targetIp)
        p = Packet()
        p.add_protocol(e)
        p.add_protocol(a)
        p.serialize()

        packetIn = OFPPacketIn(datapath, match=OFPMatch(in_port=1), data=buffer(p.data))

        ev = ofp_event.EventOFPPacketIn(packetIn)

        result = sr.packet_in_handler(ev)
        self.assertEqual(result, 0)
        print "" 
开发者ID:ttsubo,项目名称:simpleRouter,代码行数:28,代码来源:test_SimpleForward.py

示例6: test_Packet_in_2_icmpEcho1

# 需要导入模块: from ryu.controller import ofp_event [as 别名]
# 或者: from ryu.controller.ofp_event import EventOFPPacketIn [as 别名]
def test_Packet_in_2_icmpEcho1(self):
        print "*** Case2: HOST2のMAC未学習の時、HOST1からICMP Echoを受信 ***"

        sr = SimpleForward()
        dstMac = ROUTER_MACADDR1
        srcMac = HOST_MACADDR1
        srcIp = HOST_IPADDR1
        dstIp = HOST_IPADDR2
        targetMac = dstMac
        targetIp = dstIp
        ttl = 64

        datapath = _Datapath()
        e = ethernet(dstMac, srcMac, ether.ETH_TYPE_IP)

        iph = ipv4(4, 5, 0, 0, 0, 2, 0, ttl, 1, 0, srcIp, dstIp)
        echo = icmp.echo(1, 1, 'unit test')
        icmph = icmp.icmp(8, 0, 0, echo)

        p = Packet()
        p.add_protocol(e)
        p.add_protocol(iph)
        p.add_protocol(icmph)
        p.serialize()

        packetIn = OFPPacketIn(datapath, match=OFPMatch(in_port=1), data=buffer(p.data))

        ev = ofp_event.EventOFPPacketIn(packetIn)

        result = sr.packet_in_handler(ev)
        self.assertEqual(result, 1)
        print "" 
开发者ID:ttsubo,项目名称:simpleRouter,代码行数:34,代码来源:test_SimpleForward.py

示例7: test_Packet_in_3_arpReply2

# 需要导入模块: from ryu.controller import ofp_event [as 别名]
# 或者: from ryu.controller.ofp_event import EventOFPPacketIn [as 别名]
def test_Packet_in_3_arpReply2(self):
        print "*** Case3: HOST1のMAC学習済の時、HOST2からARP Replyを受信 ***"

        sr = SimpleForward()
        sr.HOST_MACADDR1 = HOST_MACADDR1
        sr.HOST_MACADDR2 = HOST_MACADDR2

        dstMac = ROUTER_MACADDR2
        srcMac = HOST_MACADDR2
        srcIp = HOST_IPADDR2
        dstIp = ROUTER_IPADDR2
        targetMac = dstMac
        targetIp = dstIp

        datapath = _Datapath()
        e = ethernet(dstMac, srcMac, ether.ETH_TYPE_ARP)
        a = arp(1, 0x0800, 6, 4, 2, srcMac, srcIp, targetMac, targetIp)
        p = Packet()
        p.add_protocol(e)
        p.add_protocol(a)
        p.serialize()

        packetIn = OFPPacketIn(datapath, match=OFPMatch(in_port=2), data=buffer(p.data))

        ev = ofp_event.EventOFPPacketIn(packetIn)

        result = sr.packet_in_handler(ev)
        self.assertEqual(result, 0)
        print "" 
开发者ID:ttsubo,项目名称:simpleRouter,代码行数:31,代码来源:test_SimpleForward.py

示例8: test_Packet_in_4_icmpEcho2

# 需要导入模块: from ryu.controller import ofp_event [as 别名]
# 或者: from ryu.controller.ofp_event import EventOFPPacketIn [as 别名]
def test_Packet_in_4_icmpEcho2(self):
        print "*** Case4: HOST2からHOST1以外の宛先IPへのIPパケットを受信 ***"

        sr = SimpleForward()
        sr.HOST_MACADDR1 = HOST_MACADDR1
        sr.HOST_MACADDR2 = HOST_MACADDR2

        dstMac = ROUTER_MACADDR2
        srcMac = HOST_MACADDR2
        srcIp = HOST_IPADDR2
        dstIp = "91.189.89.22"
        ttl = 64

        datapath = _Datapath()
        e = ethernet(dstMac, srcMac, ether.ETH_TYPE_IP)

        iph = ipv4(4, 5, 0, 0, 0, 2, 0, ttl, 1, 0, srcIp, dstIp)

        p = Packet()
        p.add_protocol(e)
        p.add_protocol(iph)
        p.serialize()

        packetIn = OFPPacketIn(datapath, match=OFPMatch(in_port=2), data=buffer(p.data))

        ev = ofp_event.EventOFPPacketIn(packetIn)

        result = sr.packet_in_handler(ev)
        self.assertEqual(result, 1)
        print "" 
开发者ID:ttsubo,项目名称:simpleRouter,代码行数:32,代码来源:test_SimpleForward.py


注:本文中的ryu.controller.ofp_event.EventOFPPacketIn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。