xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 8KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-10
  • 語言: C/C++
  • 標簽: winsockping??

資源簡介

我的作業(yè) 需要寫作業(yè)的可以參考

資源截圖

代碼片段和文件信息

/*
?*?Renkai_ping.cpp
?*
?*??Created?on:?2012-5-19
?*??????Author:?renkai
?*/
#include?
#include?
#include?
#include?“winsock2.h“
#include?“stdlib.h“
#include?“stdio.h“
#include?
using?namespace?std;

#define?ICMP_ECHO?8
#define?ICMP_ECHOREPLY?0
#define?ICMP_MIN?8???????//Minimum?8-byte?ICMP?packet
//IP首部數(shù)據結構
typedef?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;?//協(xié)議
??unsigned?short?checksum;?//?首部校驗和
??unsigned?int?sourceIP;?//?源站IP
??unsigned?int?destIP;?//?目的站IP
}?IpHeader;

//ICMP首部數(shù)據結構
typedef?struct?icmphdr
{
??BYTE?i_type;?//類型
??BYTE?i_code;?//代碼
??USHORT?i_cksum;?//首部校驗和
??USHORT?i_id;?//標識
??USHORT?i_seq;?//序列號
??ULONG?timestamp;?//時間戳
}?IcmpHeader;

#define?STATUS_FAILED?0xFFFF
#define?DEF_PACKET_SIZE????32???//默認發(fā)送包的長度
#define?DEF_PACKET_NUMBER??6???//默認發(fā)送包的數(shù)量
#define?MAX_PACKET?1024???????//最大ICMP發(fā)送包的長度
void
fill_icmp_data(char*?int?int);?//填充ICMP報頭
USHORT
checksum(USHORT*?int);?//計算ICMP首部校驗和
int
decode_resp(char*?int?struct?sockaddr_in*);?//解析收到的數(shù)據包

int?main(int?argcchar*?argv[])
{
??if?(argc?==?1)
????{
??????cout?<??????cout?<??????cout?<??????????<??????return?-1;
????}

??USHORT?seq_no=0;
??int?ts=0statistic=0;
??int?breaddatasize=32packnum=6;
??setbuf(stdoutNULL);
??WORD?wVersionRequested;
??WSADATA?wsaData;
??int?timeout=1000;
??//處理參數(shù)
??for?(int?j?=?1;?j?????{
??????int?temp;
??????temp?=?strcmp(argv[j]?“-n“);
??????if?(temp?==?0)
????????{
??????????j++;
??????????packnum?=?atoi(argv[j]);
??????????cout?<??????????continue;
????????}

??????temp?=?strcmp(argv[j]?“-l“);
??????if?(temp?==?0)
????????{
??????????j++;
??????????datasize?=?atoi(argv[j]);
??????????cout?<??????????continue;
????????}

??????temp?=?strcmp(argv[j]?“-w“);
??????if?(temp?==?0)
????????{
??????????j++;
??????????timeout?=?atoi(argv[j]);
??????????cout?<??????????continue;
????????}

??????temp?=?strcmp(argv[j]?“-s“);
??????if?(temp?==?0)
????????{
??????????j++;
??????????ts?=?atoi(argv[j]);
??????????cout?<??????????continue;
????????}

????}

??if?(packnum?<=?0)
????{
??????cout?<??????return?-1;
????}

??if?(datasize??1024)
????{
??????cout?<??????return?-1;
????}

??if?(timeout??10000)
???

評論

共有 條評論

相關資源