I'm not completely sure what you want to do. Do you want output like this?

type:            PACKET_IN
xid:             0x00000000
version:         0x04
msg:
  buffer_id:       NO_BUFFER
  total_len:       0x0052
  in_port:         0x00000002
  in_phy_port:     0x00000002
  metadata:        0x0000000000000000
  reason:          APPLY_ACTION
  table_id:        0x00
  cookie:          0x0000000000000000
  match:
    - field:           IN_PORT
      value:           0x00000002
  data:
 
000000000001000000000002080045100044847540004006A22C0A0000020A000001B8FD005019B95CE6A15E2B558018003AD69D00000101080A0055E44A0055D89F474554202F20485454502F312E300D0A
  _pkt_decode:
    - field:           ETH_DST
      value:           '00:00:00:00:00:01'
    - field:           ETH_SRC
      value:           '00:00:00:00:00:02'
    - field:           ETH_TYPE
      value:           0x0800
    - field:           IP_DSCP
      value:           0x04
    - field:           IP_ECN
      value:           0x00
    - field:           IP_PROTO
      value:           0x06
    - field:           IPV4_SRC
      value:           10.0.0.2
    - field:           IPV4_DST
      value:           10.0.0.1
    - field:           NX_IP_TTL
      value:           0x40
    - field:           TCP_SRC
      value:           0xB8FD
    - field:           TCP_DST
      value:           0x0050
    - field:           NX_TCP_FLAGS
      value:           0x0018
    - field:           X_PKT_POS
      value:           0x0036


You can use the oftr tool to do this. It converts OpenFlow message to YAML
(or JSON) and back again. Easiest way to install is from launchpad:
https://launchpad.net/~byllyfish/+archive/ubuntu/oftr

The github repository is https://github.com/byllyfish/oftr

I translated your example to YAML below, then ran `oftr encode
packet_in.yml | oftr decode --pkt-decode` to get the above output.

Contents of packet_in.yml:

version: 0x4
type: PACKET_IN
xid: 0x0
msg:
    in_port: 2
    in_phy_port: 2
    buffer_id: 4294967295
    metadata: 0
    cookie: 0
    data:
000000000001000000000002080045100044847540004006a22c0a0000020a000001b8fd005019b95ce6a15e2b558018003ad69d00000101080a0055e44a0055d89f474554202f20485454502f312e300d0a
    reason: 1
    table_id: 0
    total_len: 82

-Bill


On Sat, Apr 8, 2017 at 7:32 PM, Jibran Ahmed <ahme...@husky.neu.edu> wrote:
>
> Hi RYU-DEV team,
>
> I would like to decode the following message without using the commands
in the RYU Controller. I am failing to do so and was wondering if there was
any lib or script available to do the translation for us. Here the message
is being transferred to a higher layer application and will do the
processing based on message contents. I would ultimately like to have this
message in plain text.
>
> The message example:
> version: 0x4 msg_type 0xa xid 0x0
OFPPacketIn(buffer_id=4294967295,cookie=0,data='\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x02\x08\x00E\x10\x00D\x84u@
\x00@\x06\xa2,\n\x00\x00\x02\n\x00\x00\x01\xb8\xfd\x00P\x19\xb9\\\xe6\xa1^+U\x80\x18\x00:\xd6\x9d\x00\x00\x01\x01\x08\n\x00U\xe4J\x00U\xd8\x9fGET
/ HTTP/1.0\r\n',match=OFPMatch(oxm_fields={'in_port':
2}),reason=1,table_id=0,total_len=82)
>
> I would NOT like to use the following in the controller:
> self.pcap_writer = pcaplib.Writer(open('mypcap.pcap', 'wb'))
> self.pcap_writer.write_pkt(ev.msg.data)
>
> When I use this library (pcaplib) in my python script in the application
server, I am failing to decode it appropriately,
>
> Could you advice! Thanks in advance!
>
> Regards,
> Jibran Ahmed
> Northeastern University, Boston MA
> Telecommunications Department
>
>
>
------------------------------------------------------------------------------
> 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

Reply via email to