if(node is 1 and tick and num_pkts_sent
问题描述:
if(node is 1 and tick and num_pkts_sent //产生DATA分组(随便写个,我只想要个参考)
pkt = (PKT_PTR) malloc(sizeof(PKT));
pkt->type = /* */;
pkt->seq_no = /* */;
pkt->source = /* */;
pkt->dest = /* */;
pkt->size = /* */;
if (node is 2 and receivedata)
{
//直接将从1号节点处收到的Data分组转发给3号节点
}
//如果该tsource函数是在3号节点上执行,且已经收到了2号节点转发来的Data分组
else if (node is 3 and ack)
{
//产生ACK分组
//将该ACK分组回送给1号节点
}
来人啦
答
pkt = (PKT_PTR) malloc(sizeof(PKT));
pkt->type = DATA;
pkt->seq_no = seq_no ++;
pkt->source = 1;
pkt->dest = 2;
pkt->size = 10;
sendm(sink,0,pkt); line_busy = 1;
receivedata= 0;
pkt = (PKT_PTR) malloc(sizeof(PKT));
pkt->type = ACK;
pkt->seq_no = seq_no ++;
pkt->source = 3;
pkt->dest = 1;
pkt->size = 10;
sendm(sink,0,pkt);
line_busy = 1;
ack=0;