PING实验报告.doc_第1页
PING实验报告.doc_第2页
PING实验报告.doc_第3页
PING实验报告.doc_第4页
PING实验报告.doc_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

icmpping 20120428 23 _pingping123pingwindowsping.ping *.*.*.*ip4reply from *.*.*.*request timeout ping1pingping pingping icmpicmpicmpicmpicmpipipicmp()ipicmpipicmp8bit8bit16bit 16biticmppingicmp0icmp8icmppingiptcp/ip, ip(ip datagram). , , ip.icmptcp/ipicmp(internet control message protocol), : echoecho replyping icmp2rawsocketpingicmpipipicmprawsocketsocketsocketbind.31 ipicmp2 windowsping. 1 ipicmp2 rawsocket3ping4socket ws2_32.lib5 ping61ipicmpipicmp/iptypedef struct iphdr unsigned int h_len : 4 ; /unsigned int version : 4 ; /unsigned char tos ; /unsigned short total_len ; /unsigned short ident ; /unsigned short frag_and_flags ; /unsigned char ttl ; /unsigned char proto ; /unsigned short checksum ;/ unsigned int sourceip ;/ ipunsigned int destip ;/ ip;/icmptypedef struct icmphdrbyte i_type ; /byte i_code ; /ushort i_cksum ; /ushort i_id ; /ushort i_seq ; /ulong timestamp ; /;2.wsadata wsadata ;socket sockraw ;struct sockaddr_in dest,from ;struct hostent*hp ;int bread,datasize=32,packnum=6;int fromlen=sizeof(from);int timeout=1000 ;int statistic=0 ;int ts=0;char*dest_ip ;char*icmp_data ;char*recvbuf ;unsigned int addr=0 ;ushort seq_no=0 ;int temp;31void fill_icmp_data(char*icmp_data,int datasize,int ts); /icmpvoid fill_icmp_data(char*icmp_data,int datasize,int ts)icmpheader*icmp_hdr ;char*datapart ;icmp_hdr=(icmpheader*)icmp_data ;icmp_hdr->i_type=icmp_echo ;icmp_hdr->i_code=0 ;icmp_hdr->i_id=(ushort)getcurrentprocessid();icmp_hdr->i_cksum=0 ;icmp_hdr->i_seq=0 ;icmp_hdr->timestamp=ts;datapart=icmp_data+sizeof(icmpheader);memset(datapart,e,datasize-sizeof(icmpheader);2ushort checksum(ushort*buffer,int size);/icmpushort checksum(ushort*buffer,int size)unsigned long cksum=0 ;while(size>1)cksum+=*buffer+;size-=sizeof(ushort);if(size)cksum+=*(uchar*)buffer ;cksum=(cksum>>16)+(cksum&0xffff);cksum+=(cksum>>16);return(ushort)(cksum);3int decode_resp(char*buf,int bytes,struct sockaddr_in*from); /int decode_resp(char*buf,int bytes,struct sockaddr_in*from) ipheader*iphdr ;icmpheader*icmphdr ;unsigned short iphdrlen ;iphdr=(ipheader*)buf ;iphdrlen=(iphdr->h_len)*4 ;if(bytes<iphdrlen+icmp_min)cout<<too few bytes from <<inet_ntoa(from->sin_addr)<<endl; pingwindows ping 2013627 11.1 11.2 1 12.1 rawsocket12.2 2 23.1 ping 23.2 53.3 6 84.184.294.3134.4 ping14 155.1165.2161. 1pingpingicmpicmpicmpipicmpip1. 2 c ping1pingpingicmp2-r3-n4datasize52.1 rawsocketpingicmpipipicmprawsocketicmptcp/ipipipicmppingicmpicmp icmpwindows xpinterneticmpsocketsocketbindlisten2. 22.2.1ipicmp3-iphdr-icmphdr-ipotionhdripicm pip2.2.2windowsping2.2.3ping .ip4reply from .request timeout ping3.1 pingping()socketicmpicmpicmp ping3.112ping12 windows pingping192.168.31.1273 arp /a arp arp /d (arp /a)arp/ano arp entries foundping iparp /sip arp /sipmacpingpingpingpingicmpicmpicmpipicmpippingpingtcp/ip1rawsocketpingicmpipipicmprawsocketsocketsocketbind3. 4. 1ipicmp5. 2windowsping6. 3ping .ip4reply from .request timeout ping.3.1 4 ping.3.1.1 3.1.23.1.33.1.47. 22.2iniping()getargments()(user help )pingpingpingping2.2 8. 3getargments()-r-ndatasize()-r-nr-r ipdatasize, datasize ip9. 4ping()ping()icmpicmpicmpicmp3-iphdr-icmphdr-ipotionhdripicm pip10. 1iptypedef struct _iphdrunsigned int h_len:4;unsigned int version:4;unsigned char tos;unsigned short total_len;unsigned short ident;unsigned short frag_flags;unsigned char ttl;unsigned chor proto;unsigned short checksum;unsigned int sourceip;unsigned int destip; ipheader;h-len:4 : ip32bit4bit 60ip20version:4: ipipv4.top: total Clen: ipident: frag-flags: ttl: proto: tcpudpchecksum: sourceip: ipdestip: ip11. 2typedef struct Cicmphdrbyte i_type;byte i_code :ushort i_cksum;ushort i_id;ushort i_seq;ulong timestamp; icmpheader;i_

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论