Hi,

I made a simple pcap parse tool using pcaplib.
For constructing OpenFlow message from pcap files, please refer to the 
following tool.


$ cat display_pcap_data.py
#!/usr/bin/env python

import argparse

import six

from ryu.lib import pcaplib
from ryu.lib.packet import packet
from ryu.ofproto import ofproto_parser
from ryu.ofproto import ofproto_protocol


parser = argparse.ArgumentParser(
     description='Display packet data from pcap file.')

parser.add_argument('file', metavar='FILE', type=str,
                     help='an packet data file')

args = parser.parse_args()

frame_count = 0
for ts, buf in pcaplib.Reader(open(args.file, 'rb')):
     frame_count += 1
     pkt = packet.Packet(buf)

     raw_buf = pkt[-1]
     if not isinstance(raw_buf, six.binary_type):
         print("*** %d, %f\n%s\n" % (frame_count, ts, pkt))
         continue

     version, msg_type, msg_len, xid = ofproto_parser.header(raw_buf)
     try:
         msg = ofproto_parser.msg(
             ofproto_protocol.ProtocolDesc(version),
             version, msg_type, msg_len, xid, raw_buf)
         print("*** %d, %f\n%s, %s\n" % (frame_count, ts, pkt[:-1], msg))
     except:
         print('version=%s, msg_type=%s, msg_len=%s, xid=%s' %
               (version, msg_type, msg_len, xid))


But please note this tool can NOT parse "Controller-to-Switch" ONE-WAY messages
(e.g. OFPT_FEATURES_REQUEST message), because Ryu does not support to parse it.


Thanks,
Iwase

On 2016年05月31日 03:14, Truong Huu Trung wrote:
> Hi team,
>
> I want to construct OF message from a pcap file.
> Ryu has support for writing and reading pcap.
> But, what api can I use to create an OF message from pcap?
> Please help!
>
> Thanks,
> Trung
> --
> Best regards,
> Trung Truong
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
>
>
>
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to