菜鸟问题:如何更改IP包的生存时间?
IP协议的上层接口提供了形如:
SEND (src, dst, prot, TOS, TTL, BufPTR, len, Id, DF, opt => result)
where:
src = source address
dst = destination address
prot = protocol
TOS = type of service
TTL = time to live
BufPTR = buffer pointer
len = length of buffer
Id = Identifier
DF = Don't Fragment
opt = option data
result = response
OK = datagram sent ok
Error = error in arguments or local network error
的接口,我用套接字编程,这样才能该变TTL的值?
问题点数:40、回复次数:1Top
1 楼blueboyapi(阿皮)回复于 2001-04-10 17:19:00 得分 40
static int TTL = 0;
int nRespond;
TTL ++;
nRespond = setsockopt(sock,IPPROTO_IP, IP_TTL, (LPSTR)&TTL,
sizeof(int));
if(nRespond == SOCKET_ERROR)
{
printf("Set Socket TTL Option error\n");
closesocket(sock);
WSACleanup();
exit(1);
}Top




