June 2017
Intermediate to advanced
446 pages
10h 10m
English
In this section, we will take a closer look at the PacketIn message and parse the packet so we can further process the event and determine the corresponding action. In chapter11_2.py, we can use the ryu.lib.packet.packet method to decode the packet:
from ryu.lib.packet import packetimport array...@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)def _packet_in_handler(self, ev): print("msg.data: {}".format(array.array('B', ev.msg.data))) pkt = packet.Packet(ev.msg.data) for p in pkt.protocols: print(p.protocol_name, p)
Note that ev.msg.data is in bytearray format, which is why use the array.array() function to print it out. We can then initiate a ping, h1 ping -c 2 h2, and observe in the output the arp from h1 to ...
Read now
Unlock full access