/*
*Author : DavidLin
*Date : 2014-12-25pm
*Email : linpeng1577@163.com or linpeng1577@gmail.com
*world : the city of SZ, in China
*Ver : 000.000.001
*For : threads for rxtx!
*history : editor time do
* 1)LinPeng 2014-12-25 created this file!
* 2)
*/
信令帧,数据帧的长度不同,不同数据帧之间的长度更是千差万别,所以通讯协议中,帧的可变长实现是有重要的现实意义的。
如何实现:
1.通过帧尾部的移位;
2.逐层增加长度项。
比如有2层协议
typedef struct net_packet_t {
ip_packet_t ip;
size_t size; //用于获取ip包长度
};
typedef struct ip_packet_t {
char head;
char pay[MAX]; //需要移位变长
size_t chksum;
char tail;
};
phy_tx(&net, net.size); //发送格式,根据帧实际长度发送
转载于:https://blog.51cto.com/linpeng/1596733