Hi,
I trying to get first few bytes of payload of the packet_in.
if I use *pkt[-1]* to extract the payload, I am getting " 'tcp' object is
not iterable" error.

other wise, if I use *pkt.data* , I am seeing some unknown symbols
prepended with payload.

def _packet_in_handler(self, ev):

        # If you hit this you might want to increase

        # the "miss_send_length" of your switch

        if ev.msg.msg_len < ev.msg.total_len:

            self.logger.debug("packet truncated: only %s of %s bytes",

                              ev.msg.msg_len, ev.msg.total_len)

        msg = ev.msg

        datapath = msg.datapath

        ofproto = datapath.ofproto

        parser = datapath.ofproto_parser

        in_port = msg.match['in_port']


        pkt = packet.Packet(msg.data)

        eth = pkt.get_protocols(ethernet.ethernet)[0]

        data = pkt.data

        if data:

           print "data:", data


        if eth.ethertype == ether_types.ETH_TYPE_LLDP:

            # ignore lldp packet

            return

        dst = eth.dst

        src = eth.src

        pkt_arp = pkt.get_protocol(arp.arp)

        pkt_ipv4 = pkt.get_protocol(ipv4.ipv4)

        if pkt_ipv4:

                src_ip = pkt_ipv4.src

                dst_ip = pkt_ipv4.dst

                print "IP_SRC:", src_ip

                print "IP_DST:", dst_ip


        pkt_tcp = pkt.get_protocol(tcp.tcp)

        if pkt_tcp:

                tcp_src_port = pkt_tcp.src_port

                tcp_dst_port = pkt_tcp.dst_port

                print "TCP_Source_port:", tcp_src_port

                print "TCP_Dst_port:", tcp_dst_port


        pkt_icmp = pkt.get_protocol(icmp.icmp)

        if pkt_icmp:

                data= pkt_icmp.data

                print "ICMP Contains:", data


        if ( not pkt_arp):

                payload = bytearray(pkt.data)

                payload1 = pkt[-1]

                print "Payload by pkt[-1]:", payload1

                if payload:

                        print "Payload:", payload, "length_payload:", len
(payload)

                        print "Payload of six bytes:", payload[0:6]




*The output I am seeing when I am using netcat to send a text file from h1
to h2 connected by OVS:*

packet in 37769644528961 02:f6:aa:70:88:e7 02:e4:2e:e4:8a:23 5

packet truncated: only 170 of 1514 bytes

data: ?.?#??p?E???@@B






?

 '?,??G???Qi

??2?&?tadata field called Tunnel-ID associated with it (see A.2.3.7)

IP_SRC: 10.10.1.1

IP_DST: 10.10.1.10

TCP_Source_port: 33292

TCP_Dst_port: 9999

Payload by pkt[-1]: tadata field called Tunnel-ID associated with it (see
A.2.3.7)

Payload: ?.?#??p?E???@@B






?

 '?,??G???Qi

??2?&?tadata field called Tunnel-ID associated with it (see A.2.3.7)
length_payload: 128

Payload of six bytes: ?.?#


May I please, know how to get first six bytes of payload?

Thanks

Gandhimathi
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to