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

Reply via email to