ping就是对一个网址发送测试数据包,看对方网址是否有响应并统计响应时间,以此测试网络, 具体的含义如下:
Reply from 125.93.50.200 bytes=32 time=67ms TTL=50 //从125.93.50.200收到32字节回复,用时67ms(毫秒)
Reply from 125.93.50.200 bytes=32 time=64ms TTL=50。
Reply from 125.93.50.200 bytes=32 time=63ms TTL=50。
Reply from 125.93.50.200 bytes=32 time=68ms TTL=50。
Ping statistics for 125.93.50.200:。
Packets:Sent = 4,Received = 4,Lost = 0 <0% loss>, //发送4次,收到4此,丢失0次,丢包率0%。
Approxiamte round trip times in milli-seconds:。
Minimum = 63ms,Maximum = 68ms, Average = 65ms //最少耗时63ms,最大耗时68ms,平均耗时65ms。
扩展资料:
Ping是Windows、Unix和Linux系统下的一个命令。ping也属于一个通信协议,是TCP/IP协议的一部分。利用“ping”命令可以检查网络是否连通,可以很好地帮助我们分析和判定网络故障。应用格式:ping空格IP地址。该命令还可以加许多参数使用,具体是键入ping按回车即可看到详细说明。
ping是一个很常用的小工具,它主要用于确定网络的连通性问题 使用ping命令后,常见的出错信息通常分为3种:
1、unknown host:不知名主机,该远程主机的名字不能被域名服务器DNS转换成IP地址,故障原因可能是域名服务器有故障,或者目标主机的名字不正确,或者网络管理员的系统与远程主机之间的通信线路有故障。
2、Destination Host Unreachable:此错误信息表明执行命令的计算机没能将信息发送到对方那里。大多数情况是自己一方的计算机LAN连接线掉线,或者由于IP设置不对,而无法进行正常通信。
3、Request time out:表示在规定时间内因某种原因没有返回ping命令的应答,这种情况很可能是对方的计算机没有运行,或者中间线路不通致使信息没有到达对方那里。大多数情况下是企业防火墙等阻挡了ping命令中使用的ICMP信息。
在这种情况下即便通信对象正在工作,也会有这种结果显示。(echo包顺利到达目的主机,且目的主机也向源主机返回echo-reply包,但是echo-reply包在半路上丢失,无法到达源主机。)
参考资料来源:百度百科-ping (网络诊断工具)
hundred 英 ['hʌndrəd] 美 ['hʌndrəd]
num. 百
n. 一百元
名词复数: hundred
词语用法
num. (数词)
hundred用作基数词表示“一百”时,其前既可用a也可用one,但用a比较普遍,在美式英语中经常省去a或one。但hundred用作修饰词表示“很多”时,前面一般用a。
例句
用作数词 (num.)
Put two noughts after a seven to make seven hundred.。
在7后面加两个零成为700。
扩展资料:
近义词的用法
century 英 ['sentʃəri] 美 ['sentʃəri]
n. 百年;世纪
adj. 百年的
形容词: centurylong 名词复数: centuries。
词语用法
n. (名词)
1、century的基本意思有二:一是“百年”,指“100年”这段时间,二是指从耶稣的诞辰之日算起的每个百年,即“世纪”。
2、“二十一世纪”应说the 21st century, century前需用序数词,并加定冠词the;“十九世纪五十年代”应说the fifties of the nineteenth century。
例句
用作名词 (n.)
This book was written centuries ago.。
这本书是几百年前写的。
(指一定数量中的人或物的)每, 每一; 各个的, 各自的。
There are new houses on each side of the street. 。
街道两边有新楼房。
E-student in our class has a dictionary. 。
我们班每位同学都有一本词典。
习惯用语
each and all 每人都, 个个, 全部; 人人; 全体。
each and every 每个。
each other互相, 彼此。
【词性及解释】
a. 每个, 每一
ad. 每个
pron. 每个, 个人, 各自【adj.】
每,各;各自的
Give an apple to each child. 。
给每个孩子一个苹果。
You may find that each child in the kindergarten gives a different answer to the question. 。
你会发现幼儿园里的每个孩子对这个问题的回答都不相同。
There is a line of trees on each side of the road. 。
马路两边各有一行树。
词性变化
【pron.】
每个;各个;各自
Each of his children goes to a different school. 。
他的每个孩子都在不同的学校里读书。
He said he would see each of us separately. 。
他说他将分别约见我们每一个人。
Each and every difference contains contradiction. 。
每一个差异中无不包含矛盾。
Each has his merits. 。
各有所长。
找到一个ping的代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">。
<html xmlns="http://www.w3.org/1999/xhtml">。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />。
<title>HTTP Ping</title>。
<style>
html {
height: 100%;
overflow: hidden;。
body {
background: #000;。
color: #C0C0C0;。
font-weight: bold;。
font-size: 14px;。
font-family: Lucida Console;。
height: 100%;
margin: 0 0 0 5px;。
#divInput {
height: 10%;
#divContent {
height: 90%;
overflow: auto;。
#txtTimeout {
width: 40px;
button {
margin-left: 10px;。
</style>
</head>
<body>
<div id="divInput"> <span>URL:</span>。
<input id="txtURL" type="text" />。
<span>Timeout:</span>。
<input id="txtTimeout" type="text" value="2000" />。
<input id="btnSwitch" type="button" value="Start" onclick="handleBtnClick()" />。
<hr/>。
</div>
<div id="divContent"></div>。
<script> 。
var intStartTime; 。
var objIMG = new Image(); 。
objIMG.onload = 。
objIMG.onerror = 。
function()
{
/*
* 有回应,取消超时计时 。
*/
clearTimeout(intTimerID); 。
if(!bolIsRunning || bolIsTimeout) 。
return; 。
var delay = new Date() - intStartTime; 。
println("Reply from " + 。
strURL + 。
" time" + 。
((delay<1)?("<1"):("="+delay)) + 。
"ms"); 。
arrDelays.push(delay); 。
/*
* 每次请求间隔限制在1秒以上 。
*/
setTimeout(ping, delay<1000?(1000-delay):1000); 。
}
function ping() 。
{
/*
* 发送请求
*/
intStartTime = +new Date(); 。
intSent++; 。
objIMG.src = strURL + "/" + intStartTime; 。
bolIsTimeout = false; 。
/*
* 超时计时
*/
intTimerID = setTimeout(timeout, intTimeout); 。
}
function timeout() 。
{
if(!bolIsRunning) 。
return; 。
bolIsTimeout = true; 。
objIMG.src = "X:\\"; 。
println("Request timed out."); 。
ping();
}
</script> 。
<script> 。
var $ = function(v){return document.getElementById(v)}; 。
var arrDelays = []; 。
var intSent; 。
var bolIsRunning = false; 。
var bolIsTimeout; 。
var strURL;
var intTimeout; 。
var intTimerID; 。
var objBtn = $("btnSwitch"); 。
var objContent = $("divContent"); 。
var objTxtURL = $("txtURL"); 。
objTxtURL.value = window.location.host; 。
function handleBtnClick() 。
{
if(bolIsRunning) 。
{
/*
* 停止 。
*/
var intRecv = arrDelays.length; 。
var intLost = intSent-intRecv; 。
var sum = 0; 。
for(var i=0; i<intRecv; i++) 。
sum += arrDelays[i]; 。
objBtn.value = "Start"; 。
bolIsRunning = false; 。
/*
* 统计结果 。
*/
println(" "); 。
println("Ping statistics for " + strURL + ":"); 。
println("Packets: Sent = " + 。
intSent + 。
", Received = " + 。
intRecv + 。
", Lost = " + 。
intLost + 。
" (" + 。
Math.floor(intLost / intSent * 100) + 。
"% loss),"); 。
if(intRecv == 0) 。
return; 。
println("Approximate round trip times in milli-seconds:"); 。
println("Minimum = " + 。
Math.min.apply(this, arrDelays) + 。
"ms, Maximum = " + 。
Math.max.apply(this, arrDelays) + 。
"ms, Average = " + 。
Math.floor(sum/intRecv) + 。
"ms"); 。
}
else
{
/*
* 开始 。
*/
strURL = objTxtURL.value; 。
if(strURL.length == 0) 。
return; 。
if(strURL.substring(0,7).toLowerCase() != "http://") 。
strURL = "http://" + strURL; 。
intTimeout = parseInt($("txtTimeout").value, 10); 。
if(isNaN(intTimeout)) 。
intTimeout = 2000; 。
if(intTimeout < 1000) 。
intTimeout = 1000; 。
objBtn.value = "Stop "; 。
bolIsRunning = true; 。
arrDelays = []; 。
intSent = 0; 。
cls(); 。
println("Pinging " + strURL + ":"); 。
println(" "); 。
ping(); 。
}
}
function println(str) 。
{
var objDIV = document.createElement("div"); 。
if(objDIV.innerText != null) 。
objDIV.innerText = str; 。
else
objDIV.textContent = str; 。
objContent.appendChild(objDIV); 。
objContent.scrollTop = objContent.scrollHeight; 。
}
function cls() 。
{
objContent.innerHTML = ""; 。
}
</script>。
</body>
</html>
用HOOK做,HOOK API函数,SOCKET函数里面的send和sendto2个函数,前者是TCP协议的发送函数,后者是UDP协议的发送函数,将这2个函数的入口地址,替换成自己的函数入口地址(例如MySend,MySendTo),这样所有你要发送的消息在调用send或者sendto的时候都不进入原来的函数,而去执行你的MySend等替换函数了.在你自己的函数中,你可以做你想要的修改.。
VS对战平台和浩方对战平台就是基于此原理,HOOK send函数,将原来的IPX协议包修改成TCP/UDP协议包.发送出去,对方收到数据包之后再还原成IPX协议包,然后由游戏处理. 。
以下代码转自网络:
#include <Winsock2.h>。
#include <stdio.h>。
#pragma argsused。
//自定义APIHOOK结构
typedef struct
FARPROC funcaddr;。
BYTE olddata[5];。
BYTE newdata[5];。
}HOOKSTRUCT;
HHOOK g_hHook;。
HINSTANCE g_hinstDll;。
HMODULE hModule ;。
HANDLE g_hForm; //接收信息窗口句柄。
DWORD dwIdOld, dwIdNew;。
//------------------------------------------------------------------------。
// 由于要截获两个库里面的函数,所以每个函数定义了两个HOOK结构。
// 在编程过程中因为没有考虑到这个问题,导致很多包没有截获到,。
// 后来想到了冰哥在模仿SOCKCAP的程序中每个函数截了两次才明白。
// 一个是wsock32.dll, 一个是ws2_32.dll。
//------------------------------------------------------------------------。
HOOKSTRUCT recvapi;。
HOOKSTRUCT recvapi1;。
HOOKSTRUCT sendapi;。
HOOKSTRUCT sendapi1;。
HOOKSTRUCT sendtoapi;。
HOOKSTRUCT sendtoapi1;。
HOOKSTRUCT WSASendapi;。
void HookOn();
void HookOff();。
BOOL Init();
extern "C" __declspec(dllexport) __stdcall。
BOOL InstallHook();。
extern "C" __declspec(dllexport) __stdcall。
BOOL UninstallHook();。
BOOL hookapi(char *dllname, char *procname, DWORD myfuncaddr, HOOKSTRUCT *hookfunc);。
int WINAPI Myrecv(SOCKET s, char FAR *buf, int len, int flags);。
int WINAPI Myrecv1(SOCKET s, char FAR *buf, int len, int flags);。
int WINAPI Mysend(SOCKET s, char FAR *buf, int len, int flags);。
int WINAPI Mysend1(SOCKET s, char FAR *buf, int len, int flags);。
int WINAPI Mysendto(SOCKET s, const char FAR * buf, int len,。
int flags, const struct sockaddr FAR * to, int tolen);。
int WINAPI Mysendto1(SOCKET s, const char FAR * buf, int len,。
int flags, const struct sockaddr FAR * to, int tolen);。
int WINAPI MyWSASend(。
SOCKET s,
LPWSABUF lpBuffers,。
DWORD dwBufferCount,。
LPDWORD lpNumberOfBytesSent,。
DWORD dwFlags,。
LPWSAOVERLAPPED lpOverlapped,。
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine。
);
void sndmsg(char *buf);。
//---------------------------------------------------------------------------。
// 入口函数
// 在一载入库时就进行API截获。
// 释放时还原
//---------------------------------------------------------------------------。
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)。
switch (reason)。
{
case DLL_PROCESS_ATTACH:。
g_hinstDll = hinst;。
g_hForm = FindWindow(NULL, "ZwelL");。
if(!Init())。
{
MessageBoxA(NULL,"Init","ERROR",MB_OK);。
return(false);。
}
break;。
case DLL_THREAD_ATTACH:。
break;。
case DLL_THREAD_DETACH:。
break;。
case DLL_PROCESS_DETACH:。
UninstallHook();。
break;。
}
return TRUE;。
//-----------------------------------------------------------------------。
BOOL Init()
hookapi("wsock32.dll", "recv", (DWORD)Myrecv, &recvapi);。
hookapi("ws2_32.dll", "recv", (DWORD)Myrecv1, &recvapi1);。
hookapi("wsock32.dll", "send", (DWORD)Mysend, &sendapi);。
hookapi("ws2_32.dll", "send", (DWORD)Mysend1, &sendapi1);。
hookapi("wsock32.dll", "sendto", (DWORD)Mysendto, &sendtoapi);。
hookapi("ws2_32.dll", "sendto", (DWORD)Mysendto1, &sendtoapi1);。
hookapi("wsock32.dll", "WSASend", (DWORD)MyWSASend, &WSASendapi);。
dwIdNew = GetCurrentProcessId(); // 得到所属进程的ID。
dwIdOld = dwIdNew;。
HookOn(); // 开始拦截。
return(true);。
//---------------------------------------------------------------------------。
LRESULT WINAPI Hook(int nCode, WPARAM wParam, LPARAM lParam)。
return(CallNextHookEx(g_hHook, nCode, wParam, lParam));。
//---------------------------------------------------------------------------。
extern "C" __declspec(dllexport) __stdcall。
BOOL InstallHook()。
g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)Hook, g_hinstDll, 0);。
if (!g_hHook)。
{
MessageBoxA(NULL, "SET ERROR", "ERROR", MB_OK);。
return(false);。
}
return(true);。
//---------------------------------------------------------------------------。
extern "C" __declspec(dllexport) __stdcall。
BOOL UninstallHook()。
HookOff();
if(g_hHook == NULL)。
return true;。
return(UnhookWindowsHookEx(g_hHook));。
//---------------------------------------------------------------------------。
// 根据输入结构截获API
//---------------------------------------------------------------------------。
BOOL hookapi(char *dllname, char *procname, DWORD myfuncaddr, HOOKSTRUCT *hookfunc)。
hModule = LoadLibrary(dllname);。
hookfunc->funcaddr = GetProcAddress(hModule, procname);。
if(hookfunc->funcaddr == NULL)。
return false;。
memcpy(hookfunc->olddata, hookfunc->funcaddr, 6);。
hookfunc->newdata[0] = 0xe9;。
DWORD jmpaddr = myfuncaddr - (DWORD)hookfunc->funcaddr - 5;。
memcpy(&hookfunc->newdata[1], &jmpaddr, 5);。
return true;。
//---------------------------------------------------------------------------。
void HookOnOne(HOOKSTRUCT *hookfunc)。
HANDLE hProc;。
dwIdOld = dwIdNew;。
hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, dwIdOld);。
VirtualProtectEx(hProc, hookfunc->funcaddr, 5, PAGE_READWRITE,&dwIdOld);。
WriteProcessMemory(hProc, hookfunc->funcaddr, hookfunc->newdata, 5, 0);。
VirtualProtectEx(hProc, hookfunc->funcaddr, 5, dwIdOld, &dwIdOld);。
//---------------------------------------------------------------------------。
void HookOn()
HookOnOne(&recvapi);。
HookOnOne(&sendapi);。
HookOnOne(&sendtoapi);。
HookOnOne(&recvapi1);。
HookOnOne(&sendapi1);。
HookOnOne(&sendtoapi1);。
HookOnOne(&WSASendapi);。
//---------------------------------------------------------------------------。
void HookOffOne(HOOKSTRUCT *hookfunc)。
HANDLE hProc;。
dwIdOld = dwIdNew;。
hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, dwIdOld);。
VirtualProtectEx(hProc, hookfunc->funcaddr,5, PAGE_READWRITE, &dwIdOld);。
WriteProcessMemory(hProc, hookfunc->funcaddr, hookfunc->olddata, 5, 0);。
VirtualProtectEx(hProc, hookfunc->funcaddr, 5, dwIdOld, &dwIdOld);。
//---------------------------------------------------------------------------。
void HookOff()
HookOffOne(&recvapi);。
HookOffOne(&sendapi);。
HookOffOne(&sendtoapi);。
HookOffOne(&recvapi1);。
HookOffOne(&sendapi1);。
HookOffOne(&sendtoapi1);。
HookOffOne(&WSASendapi);。
//---------------------------------------------------------------------------。
int WINAPI Myrecv(SOCKET s, char FAR *buf, int len, int flags)。
int nReturn;。
HookOffOne(&recvapi);。
nReturn = recv(s, buf, len, flags);。
HookOnOne(&recvapi);。
char *tmpbuf=new char[len+100];。
memset(tmpbuf, 0, sizeof(tmpbuf));。
sprintf(tmpbuf, "recv|%d|%d|%s",。
GetCurrentProcessId(),。
len,。
buf);。
sndmsg(tmpbuf);。
delete tmpbuf;。
return(nReturn);。
//---------------------------------------------------------------------------。
int WINAPI Myrecv1(SOCKET s, char FAR *buf, int len, int flags)。
int nReturn;。
HookOffOne(&recvapi1);。
nReturn = recv(s, buf, len, flags);。
HookOnOne(&recvapi1);。
char *tmpbuf=new char[len+100];。
memset(tmpbuf, 0, sizeof(tmpbuf));。
sprintf(tmpbuf, "recv1|%d|%d|%s",。
GetCurrentProcessId(),。
len,。
buf);。
sndmsg(tmpbuf);。
delete tmpbuf;。
return(nReturn);。
//---------------------------------------------------------------------------。
int WINAPI Mysend(SOCKET s, char FAR *buf, int len, int flags)。
int nReturn;。
HookOffOne(&sendapi);。
nReturn = send(s, buf, len, flags);。
HookOnOne(&sendapi);。
char *tmpbuf=new char[len+100];。
memset(tmpbuf, 0, sizeof(tmpbuf));。
sprintf(tmpbuf, "send|%d|%d|%s",。
GetCurrentProcessId(),。
len,。
buf);。
sndmsg(tmpbuf);。
delete tmpbuf;。
return(nReturn);。
//---------------------------------------------------------------------------。
int WINAPI Mysend1(SOCKET s, char FAR *buf, int len, int flags)。
int nReturn;。
HookOffOne(&sendapi1);。
nReturn = send(s, buf, len, flags);。
HookOnOne(&sendapi1);。
char *tmpbuf=new char[len+100];。
memset(tmpbuf, 0, sizeof(tmpbuf));。
sprintf(tmpbuf, "send1|%d|%d|%s",。
GetCurrentProcessId(),。
len,。
buf);。
sndmsg(tmpbuf);。
delete tmpbuf;。
return(nReturn);。
//--------------------------------------------------------------------------。
int WINAPI Mysendto(SOCKET s, const char FAR * buf, int len,。
int flags, const struct sockaddr FAR * to, int tolen)。
int nReturn;。
HookOffOne(&sendtoapi);。
nReturn = sendto(s, buf, len, flags, to, tolen);。
HookOnOne(&sendtoapi);。
char *tmpbuf=new char[len+100];。
memset(tmpbuf, 0, sizeof(tmpbuf));。
sprintf(tmpbuf, "sendto|%d|%d|%s",。
GetCurrentProcessId(),。
len,。
buf);。
sndmsg(tmpbuf);。
delete tmpbuf;。
return(nReturn); 。
//--------------------------------------------------------------------------。
int WINAPI Mysendto1(SOCKET s, const char FAR * buf, int len,。
int flags, const struct sockaddr FAR * to, int tolen)。
int nReturn;。
HookOffOne(&sendtoapi1);。
nReturn = sendto(s, buf, len, flags, to, tolen);。
HookOnOne(&sendtoapi1);。
char *tmpbuf=new char[len+100];。
memset(tmpbuf, 0, sizeof(tmpbuf));。
sprintf(tmpbuf, "sendto1|%d|%d|%s",。
GetCurrentProcessId(),。
len,。
buf);。
sndmsg(tmpbuf);。
delete tmpbuf;。
return(nReturn); 。
//----------------------------------------------------------------------------。
int WINAPI MyWSASend(。
SOCKET s,
LPWSABUF lpBuffers,。
DWORD dwBufferCount,。
LPDWORD lpNumberOfBytesSent,。
DWORD dwFlags,。
LPWSAOVERLAPPED lpOverlapped,。
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine。
int nReturn;。
HookOffOne(&WSASendapi);。
nReturn = WSASend(s, lpBuffers, dwBufferCount,。
lpNumberOfBytesSent, dwFlags, lpOverlapped, lpCompletionRoutine);。
HookOnOne(&WSASendapi);。
char *tmpbuf=new char[*lpNumberOfBytesSent+100];。
memset(tmpbuf, 0, sizeof(tmpbuf));。
sprintf(tmpbuf, "WSASend|%d|%d|%s",。
GetCurrentProcessId(),。
lpNumberOfBytesSent,。
lpBuffers->buf);。
sndmsg(tmpbuf);。
delete tmpbuf;。
return(nReturn); 。
//-----------------------------------------------------------------。
// 向窗口发送消息
// 考虑到简单性,用了COPYDATASTRUCT结构。
// 用内存映射应该会快一点
//-----------------------------------------------------------------。
void sndmsg(char *buf)。
COPYDATASTRUCT cds;。
cds.dwData=sizeof(COPYDATASTRUCT);。
cds.cbData=strlen(buf);。
cds.lpData=buf;。
SendMessage(g_hForm,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds);。