模仿数据链路层的
gobackn协议
/*该协议是搭载ack的回退n步协议*/
#include
#include "protocol.h"
#define max_seq 7
#define flag 126
#define ESC 100
#define wait_time 2700 //发送计时器等待的时间
#define ack_wait_time 280
static int phl_ready = 0;
unsigned char buf[max_seq+1][270];
unsigned char ack[8]; //发送空的ack帧
unsigned char in_buf[600], last_buf[520];//接收时的缓冲区;去掉冗余之后的缓冲区,为防备因误码两帧合并为一帧而定义了很大一个数组
int nbuffered=0; //发送的帧数
int buf_size[max_seq+1]; //记下以发送各帧的帧长
int next_frame_to_send=0;
int frame_in_phl=0; //用于成帧
int frame_expected=0;
int ack_expected=0;
int between(int a,int b,int c)
{
if( ((a<=b)&&(b
1