Hi Sunil,
You want to use "ryu.lib.pcaplib" on outside of Ryu Application, right?
If so, of course yes.
"pcaplib" is available like Python library.
The following script is a simple tool for displaying pcap file using "pcaplib"
and the packet libraries of Ryu.
I'm usually using this tool for the debugging purpose.
======
#!/usr/bin/env python
import argparse
import six
from ryu.utils import binary_str
from ryu.lib import pcaplib
from ryu.lib.packet import packet
parser = argparse.ArgumentParser(
description='Display packets contained in pcap file.')
parser.add_argument('file', metavar='FILE', type=str,
help='pcap file to display')
args = parser.parse_args()
def main():
cnt = 0
for ts, buf in pcaplib.Reader(open(args.file, 'rb')):
cnt += 1
try:
pkt = packet.Packet(buf)
except Exception as e:
print(e)
print('===\n%s\n===' % binary_str(buf))
continue
print("\n*** %d, %f\n" % (cnt, ts))
for p in pkt.protocols:
if isinstance(p, six.binary_type):
print(binary_str(p))
else:
print(p)
print("\n")
if __name__ == '__main__':
main()
======
Thanks,
Iwase
On 2017年09月27日 08:48, Sunil wrote:
Hello,
I was wondering if it is possible to use the Ryu libraries primarily for pcap/ extraction purpose
similar to what tshark is using. I understand that it is not the original purpose for Ryu
implementation, but i was using the packetIn sample code and i see a pretty powerful pcap libraries
underneath. Is my understanding right and if so, can I do it ?
thanks
Sunil.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel