Nice, I have fixed this bug. function _serialize_body shows below:

    def _serialize_body(self):
        msg_pack_into(ofproto.OFP_PACKET_IN_PACK_STR,
                      self.buf, ofproto.OFP_HEADER_SIZE,
                      self.buffer_id, self.total_len, self.reason,
                      self.table_id, self.cookie)
        offset = ofproto.OFP_PACKET_IN_SIZE - ofproto.OFP_MATCH_SIZE
        offset += self.match.serialize(self.buf, offset)
        pad_len = 2
        msg_pack_into("%dx" % pad_len, self.buf, offset)


        if self.data is not None:
            self.buf += self.data



First of all, Indeed, it need 2 bytes padding after match, but I don't know 
why, because the length of ofp_packet_in is 32 which has no need to pad.
Then, the function serialize of OFPMATCH return length + pad_len, so, pad_len 
is 2.(I don't know why, but we can find the same length in function parse)


code of function serialize show below:


    def serialize(self, buf, offset):
        """
        Outputs the expression of the wire protocol of the flow match into
        the buf.
        Returns the output length.
        """
        # XXX compat
        if self._composed_with_old_api():
            return self.serialize_old(buf, offset)


        fields = [ofproto.oxm_from_user(k, uv) for (k, uv)
                  in self._fields2]


        hdr_pack_str = '!HH'
        field_offset = offset + struct.calcsize(hdr_pack_str)
        for (n, value, mask) in fields:
            field_offset += ofproto.oxm_serialize(n, value, mask, buf,
                                                  field_offset)


        length = field_offset - offset
        msg_pack_into(hdr_pack_str, buf, offset,
                      ofproto.OFPMT_OXM, length)
        self.length = length


        pad_len = utils.round_up(length, 8) - length
        ofproto_parser.msg_pack_into("%dx" % pad_len, buf, field_offset)


        return length + pad_len



This bug almost takes my  two days!!! Oh, Yeah! Thank you very much for 
discussing and help!
------------------
Distance ????
_____________________________________________________
School of Information and Communication Engineering
Beijing University of Posts and Telecommunications
Beijing 100876, PR China

??????????????????????????????????????????
_____________________________________________________
Mobile Phone: 
(+86) 151-1698-3550 Beijing 
E-mail:
[email protected]
[email protected]
Homepage:
http://www.muzixing.com





 




------------------ ???????? ------------------
??????: "Yusuke Iwase";<[email protected]>;
????????: 2015??8??25??(??????) ????4:12
??????: "muzixing.com"<[email protected]>; 
????: "ryu-devel"<[email protected]>; 
????: Re: [Ryu-devel] ??????  ????: Re:  LLDP packet parse error: 
LLDPUnknownFormat



Hi,

On 2015??08??25?? 16:40, muzixing.com wrote:
> I think the problem may be here:
> 
>     @classmethod
>     def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
>         msg = super(OFPPacketIn, cls).parser(datapath, version, msg_type,
>                                              msg_len, xid, buf)
>         (msg.buffer_id, msg.total_len, msg.reason,
>          msg.table_id, msg.cookie) = struct.unpack_from(
>             ofproto.OFP_PACKET_IN_PACK_STR,
>             msg.buf, ofproto.OFP_HEADER_SIZE)
> 
>         msg.match = OFPMatch.parser(msg.buf, ofproto.OFP_PACKET_IN_SIZE -
>                                     ofproto.OFP_MATCH_SIZE)
> 
>         match_len = utils.round_up(msg.match.length, 8)
>         msg.data = msg.buf[(ofproto.OFP_PACKET_IN_SIZE -
>                             ofproto.OFP_MATCH_SIZE + match_len + 2):]
> 
>         if msg.total_len < len(msg.data):
>             # discard padding for 8-byte alignment of OFP packet
>             msg.data = msg.data[:msg.total_len]
> 
>         return msg
> 
>     def _serialize_body(self):
>         msg_pack_into(ofproto.OFP_PACKET_IN_PACK_STR,
>                       self.buf, ofproto.OFP_HEADER_SIZE,
>                       self.buffer_id, self.total_len, self.reason,
>                       self.table_id, self.cookie)
>         offset = ofproto.OFP_PACKET_IN_SIZE - ofproto.OFP_MATCH_SIZE
>         match_len = self.match.serialize(self.buf, offset)
> 
>         if self.data is not None:
>             self.buf += self.data
> 
> 
> The round_up function align the match length to 64bit. But I my 
> serialize_body method, I have not implemented the align logic. Is that right??

How about the following align logic?
e.g.)
    def _serialize_body(self):
        msg_pack_into(ofproto.OFP_PACKET_IN_PACK_STR,
                      self.buf, ofproto.OFP_HEADER_SIZE,
                      self.buffer_id, self.total_len, self.reason,
                      self.table_id, self.cookie)
        offset = ofproto.OFP_PACKET_IN_SIZE - ofproto.OFP_MATCH_SIZE
        offset += self.match.serialize(self.buf, offset)
        pad_len = utils.round_up(self.len, 8) - self.len
        msg_pack_into("%dx" % pad_len, self.buf, offset)

        if self.data is not None:
            self.buf += self.data

Thanks,
Iwase

> ------------------
> Distance ????
> 
> _____________________________________________________
> School of Information and Communication Engineering
> Beijing University of Posts and Telecommunications
> Beijing 100876, PR China
> 
> ??????????????????????????????????????????
> _____________________________________________________
> Mobile Phone: 
> (+86) 151-1698-3550 Beijing 
> E-mail:
> [email protected]
> [email protected]
> Homepage:
> http://www.muzixing.com
> 
>  
> 
> 
> ------------------ ???????? ------------------
> *??????:* "Yusuke Iwase";<[email protected]>;
> *????????:* 2015??8??25??(??????) ????1:55
> *??????:* "muzixing.com"<[email protected]>;
> *????:* "ryu-devel"<[email protected]>;
> *????:* Re: [Ryu-devel] ????: Re: LLDP packet parse error: LLDPUnknownFormat
> 
> Hi,
> 
> 
> On 2015??08??25?? 14:18, muzixing.com wrote:
>> I do not mean to send the same packet to another controller.I have to build 
>> a new lldp packet with self-defined information. What's more, I need to send 
>> packetIn to controller, just like a switch, so we should use packetin not 
>> packet out.
> 
> Sorry, I misunderstood.
> 
> Because Ryu does not have implementation for serializing Packet-In message,
> it is difficult to create Packet-In packet data.
> Maybe, you need to implement serialize() method into OFPPacketIn class.
> 
> Thanks,
> Iwase
> 
> 
>> Thank you for your reply.
>> ---????????---
>> ??????:"Yusuke Iwase"<[email protected]>
>> ????????:2015??8??25?? ?????? ????1:2
>> ??????:"15116983550"<[email protected]>
>> ????:"ryu-devel"<[email protected]>
>> ????:Re: [Ryu-devel] LLDP packet parse error: LLDPUnknownFormat
>> Hi,
>> On 2015??08??25?? 12:52, muzixing.com wrote:
>>> Hi all,
>>>    I built an Packet_in packet with LLDP, and send it from a controller to 
>>> another controller. When I parse the packet, I can get PacketIn packet with 
>>> data. But the data is Not LLDP packet.
>>> When parse data ,I get LLDPUnknownFormat exception. The packet information 
>>> show below.
>>>
>>> {'total_len': 87, 'xid': 0, 'msg_type': 10, 'data': 
>>> '\xc2\x00\x00\x0e\x00\x00\x00\x00\x00\x00\x88\xcc\x02\x16\x07dpid:0000000000000001\x04\x05\x02\x00\x00\x00\x01\x06\x02\x00x\x12\x1b\x07domain_id:0000000000000002\x14\x05\x02\x00\x00\xff\xff\x00\x00',
>>>  'msg_len': 135, 'datapath': None, 'buffer_id': 4294967295L, 'reason': 1, 
>>> 'version': 4, 'table_id': 0, 'cookie': 0, 'buf': <read-only buffer for 
>>> 0x9dc2a10, size -1, offset 0 at 0x9e60980>, 'match': 
>>> OFPMatch(oxm_fields={'in_port': 1})}
>>> data: 0xc2 0x0 0x0 0xe 0x0 0x0 0x0 0x0 0x0 0x0 0x88 0xcc 0x2 0x16 0x7 0x64 
>>> 0x70 0x69 0x64 0x3a 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 
>>> 0x30 0x30 0x30 0x30 0x31 0x4 0x5 0x2 0x0 0x0 0x0 0x1 0x6 0x2 0x0 0x78 0x12 
>>> 0x1b 0x7 0x64 0x6f 0x6d 0x61 0x69 0x6e 0x5f 0x69 0x64 0x3a 0x30 0x30 0x30 
>>> 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x32 0x14 0x5 
>>> 0x2 0x0 0x0 0xff 0xff 0x0 0x0
>>> {'data': 
>>> '\xc2\x00\x00\x0e\x00\x00\x00\x00\x00\x00\x88\xcc\x02\x16\x07dpid:0000000000000001\x04\x05\x02\x00\x00\x00\x01\x06\x02\x00x\x12\x1b\x07domain_id:0000000000000002\x14\x05\x02\x00\x00\xff\xff\x00\x00',
>>>  'protocols': 
>>> [ethernet(dst='c2:00:00:0e:00:00',ethertype=534,src='00:00:00:00:88:cc'), 
>>> llc(control=ControlFormatI(pf_bit=0,receive_sequence_number=52,send_sequence_number=56),dsap_addr=7,ssap_addr=100),
>>>  
>>> 'd:0000000000000001\x04\x05\x02\x00\x00\x00\x01\x06\x02\x00x\x12\x1b\x07domain_id:0000000000000002\x14\x05\x02\x00\x00\xff\xff\x00\x00']}
>>>
>>> We can find out that there is LLC in protocols in protocols.
>>> The ethernet type is 534, which is the same with the LLDP chassis_id?? s 
>>> typelen??534.
>> How did you make OFPPacketOut?
>> If you want to set Packet-In data into Packet-Out data,
>> I think you need to set OFPPacketIn.data, which is raw packet data, into 
>> OFPPacketOut.data.
>> e.g.)
>> @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
>> def _packet_in_handler(self, ev):
>> msg = ev.msg
>> data = msg.data
>> ...
>> ...
>> out = parser.OFPPacketOut(..., data=data)  # set OFPPacketIn.data into 
>> OFPPacketOut.data
>> datapath.send_msg(out)
>> Thanks,
>> Iwase
>>>
>>> What should I do?
>>>
>>> Thank you for your time.
>>>
>>>
>>> ------------------
>>> Distance ????
>>>
>>> _____________________________________________________
>>> School of Information and Communication Engineering
>>> Beijing University of Posts and Telecommunications
>>> Beijing 100876, PR China
>>>
>>> ??????????????????????????????????????????
>>> _____________________________________________________
>>> Mobile Phone:
>>> (+86) 151-1698-3550 Beijing
>>> E-mail:
>>> [email protected]
>>> [email protected]
>>> Homepage:
>>> http://www.muzixing.com
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>>
>>>
>>> _______________________________________________
>>> Ryu-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Ryu-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>
>>
>> ------------------------------------------------------------------------------
>>
>>
>>
>> _______________________________________________
>> Ryu-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 
> 
> ------------------------------------------------------------------------------
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to