Next Topic

Previous Topic

Book Contents

Sample Script: TLuaICMP

--Description: Trace route example
icmp = TLuaICMP()

iPacketSize = 32 --packet size in bytes, excluding the header
bNoFragment = false --Set to true to inhibit fragmentation of packet sent
iMaxHops = 255  --Max number of hops in route

--Begin trace
bok = icmp:BeginTrace(iPacketSize,bNoFragment,iMaxHops)
if bok ~= true then
	SetExitStatus("Trace failed!",false);
end

--Print the result
iCount = 1;
Result = TLuaICMPTraceResult()
while icmp:NextTraceResult(Result) do
	print("Hop: "..iCount)
	print(Result.m_Name)
	print(Result.m_iRoundTripTimeMs)
	iCount = iCount + 1
end

--Clean up resources
icmp:EndTrace()
SetExitStatus("Trace ok!",true);