Hello every one,

I am trying to capture Packet_In as pcap file


from ryu.lib import pcaplib


def __init__(self, *args, **kwargs):
        super(SimpleSwitch13, self).__init__(*args, **kwargs)

        self.pcap_writer = pcaplib.Writer(open('mypcap.pcap', 'wb'))


@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def switch_features_handler(self, ev):
.
.
   if pkt.get_protocol(ipv4.ipv4):
          self.pcap_writer.write_pkt(ev.msg.data)
          self.pktcounter =self.pktcounter+1

Repeatedly, after 100 packet I want to use the pcap file with some tool, but 
the file would not be ready to use until I stop the controller.

therefor, I tried to read the file and save it in another file like


 scapy_cap = rdpcap('mypcap.pcap')
          for x in scapy_cap:
                 wrpcap('foo.pcap', x)

I got  " scapy.error.Scapy_Exception: No data could be read! "

and I also try somthing like this


for ts, buf in pcaplib.Reader(open('mypcap.pcap', 'rb')):
    pkt = packet.Packet(buf)

    wrpcap('foo.pcap', x)

but I got the next error "TypeError: cannot convert 'ethernet' object to bytes"




Any advice would be appreciated

Abdullah
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to