资源简介
资源提供了一种数据分段与重组算法,并通过C语言编程实现
代码片段和文件信息
#include
#include “adp.h“
#include “physap.h“
#include “net.h“
#include “mib.h“
struct adp_data_struct{
uint16_t payload_len;
char payload[NET_DRIVE_MTU];
};
struct xmit_proc {
uint8_t seqs;
uint8_t nsegs;
struct seg_struct psdu;
};
struct adp_proc{
struct adp_data_struct txp;
struct adp_data_struct rxp;
struct xmit_proc xmitProc;
};
static struct adp_proc *adp_process=NULL;
static u8 tx_lock=false;
static int tail_len =0;
extern void uts_unlock(void) ;
static void
tx_confirm_handler(uint8_t * mpdu int status) {
if (status || (adp_process->xmitProc.seqs > adp_process->xmitProc.nsegs)) {
// printk(KERN_INFO “xmit:[%s] finished:[%s] \n“status?“faild“:“success“
// adp_process->xmitProc.seqs > adp_process->xmitProc.nsegs?“yes“:“no“);
adp_process->xmitProc.seqs = 0;
adp_process->xmitProc.nsegs = 0;
uts_unlock();
tx_lock=false;
memset(&adp_process->txp 0x0 sizeof (struct adp_data_struct));
return;
}
if (adp_process->xmitProc.seqs == adp_process->xmitProc.nsegs) {
adp_process->xmitProc.psdu.hdr.type = SEG_TAIL;
adp_process->xmitProc.psdu.hdr.seqs = adp_process->xmitProc.nsegs;
adp_process->xmitProc.psdu.hdr.seg_length = tail_len ? tail_len : MAX_SEG_LEN;
} else {
adp_process->xmitProc.psdu.hdr.type = SEG_MID;
adp_process->xmitProc.psdu.hdr.seqs = adp_process->xmitProc.seqs;
adp_process->xmitProc.psdu.hdr.seg_length = MAX_SEG_LEN;
}
memcpy( adp_process->xmitProc.psdu.data adp_process->txp.payload + adp_process->xmitProc.seqs * MAX_SEG_LEN adp_process->xmitProc.psdu.hdr.seg_length);
adp_process->xmitProc.seqs++;
if(physap_xmit_mpdu_csma((unsigned char *) &adp_process->xmitProc.psdu adp_process->xmitProc.psdu.hdr.seg_length + 4 tx_confirm_handler)) {
// printk(KERN_WARNING “send [%d] segments failed! \n“adp_process->xmitProc.seqs);
memset(&adp_process->txp 0x0 sizeof (struct adp_data_struct));
adp_process->xmitProc.seqs = 0;
adp_process->xmitProc.nsegs = 0;
uts_unlock();
tx_lock=false;
return;
}
}
void adp_req(char *data uint16_t len) {
if(tx_lock)
return;
tx_lock=true;
tail_len=len%MAX_SEG_LEN;
adp_process->txp.payload_len = len;
memcpy(adp_process->txp.payload data len);
adp_process->xmitProc.nsegs =tail_len?len /MAX_SEG_LEN:(len / MAX_SEG_LEN-1);
adp_process->xmitProc.seqs = 0;
adp_process->xmitProc.psdu.hdr.type = SEG_FIRST;
/*just one segment*/
if ((len ==MAX_SEG_LEN) || (!adp_process->xmitProc.nsegs)) {
adp_process->xmitProc.psdu.hdr.seqs = 0;
adp_process->xmitProc.psdu.hdr.seg_length = adp_process->txp.payload_len;
} else { //one more fregment send first segment
adp_process->xmitProc.psdu.hdr.seqs = adp_process->xmitProc.nsegs;
adp_process->xmitProc.psdu.hdr.seg_leng
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6584 2016-01-14 15:00 数据包分段与重组算法原理及其实现\adp.c
文件 985 2018-05-03 16:40 数据包分段与重组算法原理及其实现\adp.h
文件 54388 2015-12-29 14:01 数据包分段与重组算法原理及其实现\分段与重组.odt
目录 0 2016-04-01 11:05 数据包分段与重组算法原理及其实现
----------- --------- ---------- ----- ----
61957 4
评论
共有 条评论