當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。