- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
实验六数据包的捕获及分析.doc
实验6 数据包的捕获及分析
一、实验时间及学时:2011-10-17 2学时
二、实验目的
1、掌握数据包捕获的基本方法。
2、掌握数据包的分拆及分析的方法
三、实验平台:
Window XP
VC6.0
四、实验类型:验证性实验
五、实验内容
1.利用Libpcap或Winpcap实现对数据包的捕获。
2.将数据包按协议进行分析
六、实验过程
1、安装Winpcap4.02.
2、解压wpdpack库文件,并将其LIB和INCLUDE文件夹中的所有文件复制到VC安装目录中相应的文件夹中。
3、通过上机调试下列程序,熟悉并掌握winpcap基本函数的应用及编程步骤。
#include pcap.h
#includestdio.h
/* prototype of the packet handler */
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data);
typedef struct ip_address
{
u_char byte1;
u_char byte2;
u_char byte3;
u_char byte4;
}ip_address;
typedef struct ip_header{
u_char ver_ihl;
u_char tos;
u_short tlen;
u_short identification;
u_short flags_fo;
u_char ttl;
u_char proto;
u_short crc;
ip_address saddr;
ip_address daddr;
u_int op_pad;
}ip_header;
typedef struct udp_header{
u_short sport;
u_short dport;
u_short len;
u_short crc;
}udp_header;
/* Callback function invoked by libpcap for every incoming packet */
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
{
struct tm *ltime;
char timestr[16];
ip_header *ih;
udp_header *uh;
u_int ip_len;
u_short sport,dport;
/* convert the timestamp to readable format */
ltime=localtime(header-ts.tv_sec);
strftime( timestr, sizeof timestr, %H:%M:%S, ltime);
printf(%s,%.6d len:%d, timestr, header-ts.tv_usec, header-len);
ih=(ip_header*)(pkt_data +14);
ip_len=(ih-ver_ihl0xf)*4;
uh=(udp_header*)((u_char)ih+ip_len);
sport=ntohs(uh-sport);
dport=ntohs(uh-dport);
printf(%d.%d.%d.%d.%d-%d.%d.%d.%d.%d\n,
ih-saddr.byte1,
ih-saddr.byte2,
ih-saddr.byte3,
ih-saddr.byte4,
sport,
ih-daddr.byte1,
ih-daddr.byte2,
ih-daddr.byte3,
ih-daddr.byte4,
dport);
}
int main()
{
pcap_if_t *alldevs;
pcap_if_t *d;
int inum;
int i=0;
pcap_t *adhandle;
char errbuf[PCAP_ERRBUF_SIZE];
u_int netmask;
char packet_filter[]=ip and udp;
struct bpf_program fcode;
/* Retrieve the device list */
if(pcap_findallde
您可能关注的文档
最近下载
- 光伏电站运行常见故障及技术解决方案.pdf VIP
- 军队文职考试《公共科目》试题与参考答案(2024年).docx VIP
- 生成式AI在小学英语课堂中的应用:教师教学决策优化研究教学研究课题报告.docx
- 初二物理导学案-全一册.pdf VIP
- 邮政企业快递企业安全生产重大事故隐患判定标准解读.pdf VIP
- 人民大2023学术规范和论文写作PPT第2章 选:论文选题与研究设计.pptx VIP
- 2025年中国食品级碳酸氢钠数据监测报告.docx
- 能源与动力工程研究教授——程林同志事迹材料— .doc VIP
- 高中物理竞赛-话题5:多质点在动态多边形顶点的相遇问题和多解问题.doc VIP
- 《提升基层干部管理能力》课件.ppt VIP
文档评论(0)