1 / 5
文档名称:

实验七数据包的捕获及分析.docx

格式:docx   大小:85KB   页数:5页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

实验七数据包的捕获及分析.docx

上传人:pppccc8 2022/6/12 文件大小:85 KB

下载得到文件列表

实验七数据包的捕获及分析.docx

文档介绍

文档介绍:实验7数据包的捕获及分析
—、实验时间及学时:2013-06-06 2学时
二、 实验目的
1、 掌握数据包捕获的基本方法。
2、 掌握数据包的分拆及分析的方法
三、 实验平台:
Window XP
四、 实验类型pen_live( , 〃 name of the device
65535, // portion of the packet to capture.
// 65536 grants that the whole packet will be captured on all the MACs.
1, // promiscuous mode (nonzero means
promiscuous)
1000, // read timeout
errbuf // error buffer
))==NULL)
(
fprintf(stderr, "\nUnable to open the adapter. %s is not supported by WinPcap\n", d->name);
/* Free the device list */ pcap_freealldevs(alldevs); return -1;
if(pcap_datalink(adhandle) !=DLT_EN10MB)
fprintf(stderr,"\nThis program works only on Ethernet networks.\n");
pcap_freealldevs(alldevs);
return -1;
}
if(d->addresses !=NULL)
netmask=((struct
sockaddr_in*)(d->addresses->netmask))->;
else
netmask=Oxffffff;
if(pcap_compile(adhandle, ,packet_filter, 1,netmask)vO)
(
fprintf(stderr, "\nUnable compile.\n");
pcap_freealldevs(alldevs);
return -1;
}
if(pcap_setfilter( ,&fcode)<0)
{
fprintf(stderr, "\nError filter.\nn);
pcap_freealldevs(alldevs);
return -1;
}
printf("\nlistening on %s...\n”,d->description);
/* At this point, we don't need any more the device list. Free it */ pcap_freealldevs(alldevs);
/* start the capture */
pcap_loop(adhandle, 0, , NULL);
pcap_close(adhandle);
return 0;
}
/* Callback function invoked by libpcap for every incoming packet