MOTOBIT.COM - ASP upload, IIS utility ASP trace page

Sample for Simple DNS+Traceroute.Trace.OneStep | Changes | Purchase | Download

Examples

ASP trace page 
<%
Dim Trace, DNS
Set Trace = CreateObject("TCPIP.Trace")
Set DNS = CreateObject("TCPIP.DNS")

Dim I, IP, RoundTripTime, Status, TTL, TracedHost, bDNS, Checked, Hops, Bytes
TracedHost = Request("Host")
If TracedHost = "" And Instr(UCase(Request.ServerVariables("QUERY_STRING")), "HOST") = 0 Then TracedHost = Request.ServerVariables("QUERY_STRING")
If TracedHost = "" Then TracedHost = Request.ServerVariables("REMOTE_ADDR")

Response.Write "<html><head><title>" & "TraceRoute from " & TracedHost & "</title></head><body>"
bDNS = Request("DNS")
If bDNS = "N" Then Checked = " checked"
Hops = Request("Hops")
If IsNumeric(Hops) Then Hops = CLng(Hops) Else Hops = 0
If Hops = 0 Then Hops = 20
Bytes = Request("Bytes")
If IsNumeric(Bytes) Then Bytes = CLng(Bytes) Else Bytes = 0
If Bytes = 0 Then Bytes = 0
Timeout = Request("TimeOut")
If IsNumeric(Timeout) Then Timeout = CLng(Timeout) Else Timeout = 0
If Timeout = 0 Then Timeout = 5000


Response.Write "<center><form>Trace to : <input name=Host value=""" & TracedHost & """>"
Response.Write "<input Value=Trace type=Submit><br>"
Response.Write "Maximum hops : <input size=3 name=Hops value=""" & Hops & """> "
'  response.write "Packet bytes : <input size=5 name=Bytes value=""" & Bytes & """>"
Response.Write "TimeOut [ms] : <input size=5 name=TimeOut value=""" & Timeout & """>"
Response.Write "<input name=DNS value=N type=checkbox" & Checked & "> No DNS "

Response.Write "</form>"
Response.Write "<h2>TraceRoute from " & Request.ServerVariables("LOCAL_ADDR") & " (" & GetHost(Request.ServerVariables("LOCAL_ADDR")) & ") to " & TracedHost & "</h2>"
Response.Write "<pre>"
'  response.write "<hr size=0>"
Response.Write OneStep("", "IP", "Time", "TTL", "Status", "Host")
Trace.TimeOut = Timeout
Trace.PacketBytes = PacketBytes

For I = 1 To Hops
    On Error Resume Next
    IP = Trace.OneStep(I, TracedHost)
    If Err Then
      If Trace.Status = 11010 Then
        Desc = "*"
      Else
        Desc = Err.Description
        I = 100
      End If
      Response.Write OneStep(I + 1, IP, Desc, "", Trace.Status, GetHost(IP))
    Else
      Response.Write OneStep(I, IP, Trace.RoundTripTime, Trace.TTL, Trace.Status, GetHost(IP))
      If Trace.Status = 0 Then I = 100
    End If
    If Trace.Status = 0 Then I = 100
    On Error Goto 0
Next
Response.Write "</pre></center>"
Response.Write "<hr color=silver size=0><font size=1>ActiveX TraceRoute from <a href=http://www.motobit.com target=_top>PSTRUH Software</a></font>"
Response.Write "</body></html>"



Function GetHost(IP)
  If bDNS = "N" Then
    GetHost = "-"
  Else
    On Error Resume Next
      GetHost = DNS.GetHostByIP(IP)
      If Err Then GetHost = Err.Description
    On Error Goto 0
  End If
End Function

Function ToSize(Co, ByVal Size)
  Dim Kolik
  Kolik = Size - Len(Co)
  If Kolik < 0 Then Kolik = 0
  ToSize = String(Kolik, " ") & Co
End Function

Function ToSizeR(Co, ByVal Size)
  Dim Kolik
  Kolik = Size - Len(Co)
  If Kolik < 0 Then Kolik = 0
  ToSizeR = Co & String(Kolik, " ")
End Function

Function OneStep(Step, IP, RoundTripTime, TTL, Status, Host)
  Dim HTML
  ' HTML = HTML & "<pre>"
  HTML = HTML & "<hr size=0>"
  HTML = HTML & ToSize(Step, 3)
  HTML = HTML & ToSize(ToSizeR(IP, 15), 17)
  HTML = HTML & ToSize(RoundTripTime, 6)
  HTML = HTML & ToSize(TTL, 6)
  ' HTML = HTML & ToSize(Status,6)
  HTML = HTML & ToSize(Host, 50)
  ' HTML = HTML & "</pre>"
  ' HTML = HTML & "<br>"
  ' HTML = "<table border=0 cellpadding=0 cellspacing=0><tr align=right>"
  ' HTML = HTML & "<td width=30>" & Step & "</td>"
  ' HTML = HTML & "<td align=left width=150 nowrap> " & IP & "</td>"
  ' HTML = HTML & "<td nowrap width=150>" & RoundTripTime & " </td>"
  ' HTML = HTML & "<td nowrap width=80>" & TTL & " </td>"
  ' HTML = HTML & "<td nowrap width=80>" & Status & " </td>"
  ' HTML = HTML & "<td nowrap width=500>" & Host & " </td>"
  ' HTML = HTML & "</tr></table>" & vbcrlf
  OneStep = HTML
End Function


%>

Other links for the ASP trace page sample

Simple DNS+Traceroute.Trace

Provides TraceRoute (See asp or VB samples)

Simple DNS+Traceroute

      Object for simple IP adress and host name resolution, ASP and VB TraceRoute/ping.

© 1996 - 2009 Antonin Foller, Motobit Software | About, Contacts | e-mail: info@pstruh.cz