新手上路
- 积分
- 21
- 金钱
- 21
- 注册时间
- 2016-10-19
- 在线时间
- 3 小时
|
在进ENCJ2860实验室,如何让设备主动去ping一个指定的网络。enc28j60作为服务器192.168.1.26,将电脑作为客户端192.168.1.14
要求enc28j60每个一秒主动发送一次ping回应请求发送给客户端。
现在,自己通过直接写的方式进行,但是用Wireshark软件进行抓包,总是出现错误的信息。Expert Info (Error/Protocol): IPv4 total length exceeds packet length (46 bytes)
下面是代码:
//定时发送
while(ICMP_CNT%200==0)
{
BUF->type = 0x0800;
icmp_process();
uip_arp_out();
tapdev_send();
}
//icmp数据填充
icmp_process(void)
{
BUF->vhl = 0x45;
BUF->tos =0x00;
BUF->len[0]=0x00;
BUF->len[1]=0x3c;
BUF->ipid[0]=0x03;
BUF->ipid[1]=0x16;
BUF->ipoffset[0]=0x00;
BUF->ipoffset[1]=0x00;
BUF->ttl=0x40;
BUF->proto=0x01;
uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
uip_ipaddr(BUF->destipaddr, 192,168,1,14);
BUF->icmpchksum=uip_ipchksum();
BUF->type=0x08;
BUF->icode=0x00;
BUF->id=0x0001;
BUF->seqno=0x0027;
for(i=0;i<0x77-0x60;i++)
uip_buf[i+28+ UIP_LLH_LEN]=0x61+i;
for(i=0x77-0x60;i<32;i++)
uip_buf[i+28 + UIP_LLH_LEN]=0x61+i-0x77+0x60;
++uip_stat.icmp.sent;
++uip_stat.ip.sent;
uip_flags = 0;
}
|
|