當前位置:首頁 » 操作系統 » ping源碼

ping源碼

發布時間: 2022-02-04 03:30:45

① 易語言 埠ping顯延遲 持續ping 源碼 如圖

這個實現應該不難 (我沒做過)
就是請求訪問網站,然後有個等待時間,那個就是ping
你也可以試一下系統自帶cmd 輸入:ping www..com回車
然後會顯示一些信息 包括延遲
實時顯示有點難度 畢竟請求訪問時本身就存在著延遲
易語言的話你可以用一個時鍾
時鍾裡面的代碼大概就是如同CMD一樣ping你輸入的網站,然後返回延遲的時間,就是你想要的ping值
(不太懂這方面,有說錯的地方見諒)

② 求 並發ping 實現的源碼程序!!!

cmd中ping+IP地址是用來向對方主機發送默認大小為32位元組的數據,一般是用來看你電腦能不能連到這個IP,或者說看你的延遲,貌似沒有對別的電腦實現遠程式控制制的功能……

③ 如何得到本機ping命令源代碼

一個按扭,一個文本,運行結果到C盤的1.TXT里看看privatesubcommand1_Click()Shell"Cmd.exe/cping"&text1.text&">C:\1.txt",vbHideendsub

④ ping查網速的代碼是多少

ping 的是網路延遲 也就是你要訪 問的目標網站與你的電腦對接的延遲, 一般的咱都ping的是網關,聯通的 221.6.4.66 221.6.4.67 還有ping自己的路由器 192.168.1.1或者192.168.0.1
後面的-t是取消時間限制 如果不加-t 那麼你的ping結果只顯示5秒鍾左右就自動關掉了

⑤ ping編寫的代碼ping功能

DimpidAsLong
pid=Shell("cmd.exe/CPing"&Text1.Text&">c: .txt",vbHide)
'提示
Text2.Text="正在執行Ping"&Text1.Text&"..."
'等待Shell執行結束
DimhProcAsLong
hProc=OpenProcess(PROCESS_QUERY_INFORMATION,0,pid)
DimExitCodeAsLong
Do
CallGetExitCodeProcess(hProc,ExitCode)
DoEvents
LoopWhileExitCode=STILL_ALIVE
'清空,准備顯示結果
Text2.Text=""

'打開C: .txt文件
Open"c: .txt"ForInputAs#1
DimstrLineAsString
DoUntilEOF(1)
LineInput#1,strLine
'顯示執行結果
Text2.Text=Text2.Text&strLine&vbNewLine
Loop

'關閉文件
Close#1
'刪除C: .txt
OnErrorResumeNext
Kill"c: .txt"

⑥ ping攻擊代碼

=^0^=死亡之Ping =^0^=
Ping是一個測試網路是否接通的指令,基本使用方法如下:
首先開啟DOS,方法是:
Windows 95/98 開始→程式集→MS-DOS 模式
Windows NT/2000 開始→程式集→命令提示字元
Windows ME 開始→程式集→附屬應用程式→MS-DOS 模式
Windows XP 開始→程式集→附屬應用程式→命令提示字元

然後輸入:
Ping www.xxx.com (xxx為自選伺服器)
表示測試本機與xxx網站的連結。
結果如下(只列出部分):
Pinging www.xxx.com[---.---.---.--] with 32 bytes of data:
Reply from ---.---.---.--: bytes=32 time=168ms TTL=--
Reply from ---.---.---.--: bytes=32 time=167ms TTL=--
Reply from ---.---.---.--: bytes=32 time=167ms TTL=--
Reply from ---.---.---.--: bytes=32 time=168ms TTL=--

Pinging statistics for ---.---.---.--
Packets: sent=4 , Recieved=4 , Lost=0 (0% Lost)
........

Pinging www.xxx.com[---.---.---.--]<--伺服器端IP,為四組數字
with 32 bytes of data:<--資料包大小
現在請輸入Ping -l 20000 -s 4 www.xxx.com 表示使用20000位元組的資料包傳送4次到www.xxx.com。

在此筆者解釋一下死亡之Ping的運作原理。根據IP規定(RFC-791),大於65535位元組(即64KB)的封包,是不合符標準的。對於一些舊式的作業系統,例如Unix、Windows 3.1、Mac、Netware等,它們並不懂得檢查及阻擋這些封包。系統默認了所有封包也是合法的。由於緩沖區大小隻是65535位元組,於是便會發生緩沖區溢出的錯誤(即是緩沖區大小並不足夠接收封包)。系統便會即是當機。

這是一種DoS(Denial of Service)的攻擊。攻擊並不是為了竊取電腦上的資料,只是要令別人的電腦癱瘓而己。而威力更強的DDoS(Distributed Denial of Service)則是多人一起使用DoS攻擊同一目標。

本文介紹的炸機方式效率很低,而且失敗機會高,只適用於舊式以及沒防範攻擊的電腦,所以黑客們也很少使用它。另外若您安裝了Windows NT/2000 Service Pack 1或以上,作業系統限制了Ping的封包的大小上限為8000位元組,亦即是說不能使用這種炸機方式攻擊別人。

⑦ 這個易語言ping源碼 誰能給下 謝謝啦 就是把IP地址輸入 下面返回 PING的值。 代碼不知道怎麼寫。

.版本 2
.如果 (編輯框1.內容 ≠ 「」)
運行 (「cmd /c ping 」 + 編輯框1.內容 + 「-t」 + 「 >c:\ping.txt」, 真, #隱藏窗口)
編輯框2.內容 = 到文本 (讀入文件 (「c:\ping.txt」))
刪除文件 (「c:\ping.txt」)
.否則
.如果結束
是用CMD的保存文件。讀取CMD的保存文件。原理就是這樣

linux源碼里有ping源碼嗎

要看你是看tcp/ip協議棧的代碼還是用戶態的代碼,我猜你是要看ping 這個程序的代碼
rpm -qf `which ping`
找到ping屬於哪個軟體包,下載軟體包的源代碼就可以看了

⑨ 求windows下ping程序c源代碼,模擬的ping也行,能編譯通過就行,網上很多通不過

#pragma pack(4)
#define WIN32_LEAN_AND_MEAN
#include
#include
#include
#define ICMP_ECHO 8
#define ICMP_ECHOREPLY 0
#define ICMP_MIN 8 // minimum 8 byte icmp packet (just header)
/* The IP header */
typedef struct iphdr {
unsigned int h_len:4; // length of the header
unsigned int version:4; // Version of IP
unsigned char tos; // Type of service
unsigned short total_len; // total length of the packet
unsigned short ident; // unique identifier
unsigned short frag_and_flags; // flags
unsigned char ttl;
unsigned char proto; // protocol (TCP, UDP etc)
unsigned short checksum; // IP checksum
unsigned int sourceIP;
unsigned int destIP;
}IpHeader;
//
// ICMP header
//
typedef struct _ihdr {
BYTE i_type;
BYTE i_code; /* type sub code */
USHORT i_cksum;
USHORT i_id;
USHORT i_seq;
/* This is not the std header, but we reserve space for time */
ULONG timestamp;
}IcmpHeader;
#define STATUS_FAILED 0xFFFF
#define DEF_PACKET_SIZE 32
#define MAX_PACKET 1024
#define xmalloc(s) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(s))
#define xfree(p) HeapFree (GetProcessHeap(),0,(p))
void fill_icmp_data(char *, int);
USHORT checksum(USHORT *, int);
void decode_resp(char *,int ,struct sockaddr_in *);
void Usage(char *progname){
fprintf(stderr,"Usage: ");
fprintf(stderr,"%s [data_size] ",progname);
fprintf(stderr,"datasize can be up to 1Kb ");
ExitProcess(STATUS_FAILED);
}
int main(int argc, char **argv){
WSADATA wsaData;
SOCKET sockRaw;
struct sockaddr_in dest,from;
struct hostent * hp;
int bread,datasize;
int fromlen = sizeof(from);
int timeout = 1000;
char *dest_ip;
char *icmp_data;
char *recvbuf;
unsigned int addr=0;
USHORT seq_no = 0;
if (WSAStartup(MAKEWORD(2,1),&wsaData) != 0){
fprintf(stderr,"WSAStartup failed: %d ",GetLastError());
ExitProcess(STATUS_FAILED);
}
if (argc <2 ) {
Usage(argv[0]);
}
sockRaw = WSASocket (AF_INET,
SOCK_RAW,
IPPROTO_ICMP,
NULL, 0,0);
if (sockRaw == INVALID_SOCKET) {
fprintf(stderr,"WSASocket() failed: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
bread = setsockopt(sockRaw,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,
sizeof(timeout));
if(bread == SOCKET_ERROR) {
fprintf(stderr,"failed to set recv timeout: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
timeout = 1000;
bread = setsockopt(sockRaw,SOL_SOCKET,SO_SNDTIMEO,(char*)&timeout,
sizeof(timeout));
if(bread == SOCKET_ERROR) {
fprintf(stderr,"failed to set send timeout: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
memset(&dest,0,sizeof(dest));
hp = gethostbyname(argv[1]);
if (!hp){
addr = inet_addr(argv[1]);
}
if ((!hp) && (addr == INADDR_NONE) ) {
fprintf(stderr,"Unable to resolve %s ",argv[1]);
ExitProcess(STATUS_FAILED);
}
if (hp != NULL)
memcpy(&(dest.sin_addr),hp->h_addr,hp->h_length);
else
dest.sin_addr.s_addr = addr;
if (hp)
dest.sin_family = hp->h_addrtype;
else
dest.sin_family = AF_INET;
dest_ip = inet_ntoa(dest.sin_addr);
if (argc >2) {
datasize = atoi(argv[2]);
if (datasize == 0)
datasize = DEF_PACKET_SIZE;
}
else
datasize = DEF_PACKET_SIZE;
datasize += sizeof(IcmpHeader);
icmp_data = xmalloc(MAX_PACKET);
recvbuf = xmalloc(MAX_PACKET);
if (!icmp_data) {
fprintf(stderr,"HeapAlloc failed %d ",GetLastError());
ExitProcess(STATUS_FAILED);
}
memset(icmp_data,0,MAX_PACKET);
fill_icmp_data(icmp_data,datasize);
while(1) {
int bwrote;
((IcmpHeader*)icmp_data)->i_cksum = 0;
((IcmpHeader*)icmp_data)->timestamp = GetTickCount();
((IcmpHeader*)icmp_data)->i_seq = seq_no++;
((IcmpHeader*)icmp_data)->i_cksum = checksum((USHORT*)icmp_data,
datasize);
bwrote = sendto(sockRaw,icmp_data,datasize,0,(struct sockaddr*)&dest,
sizeof(dest));
if (bwrote == SOCKET_ERROR){
if (WSAGetLastError() == WSAETIMEDOUT) {
printf("timed out ");
continue;
}
fprintf(stderr,"sendto failed: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
if (bwrote < datasize ) {
fprintf(stdout,"Wrote %d bytes ",bwrote);
}
bread = recvfrom(sockRaw,recvbuf,MAX_PACKET,0,(struct sockaddr*)&from,
&fromlen);
if (bread == SOCKET_ERROR){
if (WSAGetLastError() == WSAETIMEDOUT) {
printf("timed out ");
continue;
}
fprintf(stderr,"recvfrom failed: %d ",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
decode_resp(recvbuf,bread,&from);
Sleep(1000);
}
return 0;
}
/*
The response is an IP packet. We must decode the IP header to locate
the ICMP data
*/
void 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 ; // number of 32-bit words *4 = bytes
if (bytes < iphdrlen + ICMP_MIN) {
printf("Too few bytes from %s ",inet_ntoa(from->sin_addr));
}
icmphdr = (IcmpHeader*)(buf + iphdrlen);
if (icmphdr->i_type != ICMP_ECHOREPLY) {
fprintf(stderr,"non-echo type %d recvd ",icmphdr->i_type);
return;
}
if (icmphdr->i_id != (USHORT)GetCurrentProcessId()) {
fprintf(stderr,"someone else's packet! ");
return ;
}
printf("%d bytes from %s:",bytes, inet_ntoa(from->sin_addr));
printf(" icmp_seq = %d. ",icmphdr->i_seq);
printf(" time: %d ms ",GetTickCount()-icmphdr->timestamp);
printf(" ");
}
USHORT 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);
}
/*
Helper function to fill in various stuff in our ICMP request.
*/
void fill_icmp_data(char * icmp_data, int datasize){
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;
datapart = icmp_data + sizeof(IcmpHeader);
//
// Place some junk in the buffer.
//
memset(datapart,'E', datasize - sizeof(IcmpHeader));
}

估計你也試過,網上搜到的。

⑩ 易語言ping ip源碼

運行 (「cmd /C 」 + 「ping www..com」 + 「 >」 + #引號 + 取運行目錄 () + 「\1.txt」, 真, 1)
編輯框1.內容 = 到文本 (讀入文件 (取運行目錄 () + 「\1.txt」))

熱點內容
火車軟卧無線密碼是多少 發布:2024-04-19 07:38:59 瀏覽:422
vb系統文件夾 發布:2024-04-19 07:29:58 瀏覽:739
qt怎麼添加文件夾 發布:2024-04-19 07:22:53 瀏覽:255
sql查詢表是否存在 發布:2024-04-19 06:11:48 瀏覽:622
T178Tccftp 發布:2024-04-19 06:11:35 瀏覽:185
電腦遠程訪問自己的伺服器 發布:2024-04-19 00:08:03 瀏覽:96
噸包演算法 發布:2024-04-19 00:02:13 瀏覽:328
win8解壓縮軟體官方下載 發布:2024-04-18 23:52:27 瀏覽:727
手機軟體在哪個文件夾 發布:2024-04-18 23:51:26 瀏覽:373
未加密魔獸地圖 發布:2024-04-18 23:39:13 瀏覽:947