verinec.importer.analysis.traceroute
Class TRJPcap

java.lang.Object
  extended by verinec.importer.analysis.traceroute.TRJPcap

public class TRJPcap
extends Object

This class employs the JPcap library to send and receive ICMP packages to do a traceroute. As we are not interested in performance measurements of the network connections, packets are only sent once if a response comes back. Fixme: The packets for traces are always sent from the "default" interface. This will only work if there is no more than one active network interface on the machine.

Author:
martial.seifriz at unifr.ch

Nested Class Summary
private static class TRJPcap.TRJPcapObject
          This class provides a traceroute and encapsulates the algorithm.
 
Field Summary
private static jpcap.JpcapCaptor captor
          the package captor
private static jpcap.NetworkInterface device
          the package sender
private static Logger log
           
static short MAX_RETRIES
          number of tries for an unreachable host ie. timeout
private static jpcap.JpcapSender sender
          the package sender
private static InetAddress thisHostIP
          the ip adress of this host
private static boolean[] usedIDs
          This array saves the used ids.
 
Constructor Summary
private TRJPcap()
          The constructor is private, the factory method getTRObject() must be used to get an instance.
 
Method Summary
static jpcap.NetworkInterface getDefaultNetworkInterface()
          Try to find out the standart device of the system.
protected static jpcap.JpcapCaptor getNewCaptor()
          Creation and return of a new captor instance.
static ATraceRoute getTRObject()
          this method generates a new TRJPcapObject and handels the device, sender and captor.
private static void init()
          The initialization of the sender and the device.
private static void printNetworkInterfaces()
          Show all networkinterfaces which are found on the system
protected static void releaseID(byte id)
          Release an id.
protected static byte requestID()
          Fetch a unused id, which can be used as indentifier.
private static void testAccessRights()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_RETRIES

public static final short MAX_RETRIES
number of tries for an unreachable host ie. timeout

See Also:
Constant Field Values

sender

private static jpcap.JpcapSender sender
the package sender


captor

private static jpcap.JpcapCaptor captor
the package captor


device

private static jpcap.NetworkInterface device
the package sender


thisHostIP

private static InetAddress thisHostIP
the ip adress of this host


log

private static Logger log

usedIDs

private static boolean[] usedIDs
This array saves the used ids. This is needed to identify the icmp packages of each traceroute instances and to guarantee correctnes. The index of this array is used by the traceroutes in the icmp identifier field.

Constructor Detail

TRJPcap

private TRJPcap()
The constructor is private, the factory method getTRObject() must be used to get an instance.

Method Detail

getTRObject

public static ATraceRoute getTRObject()
                               throws TraceRouteException
this method generates a new TRJPcapObject and handels the device, sender and captor. The problem is, that only one sender can be opened by using the RAWSocket of a device.

Returns:
a TRJPcapObject which is able to do a traceroute
Throws:
TraceRouteException

init

private static void init()
                  throws TraceRouteException
The initialization of the sender and the device.

Throws:
TraceRouteException

testAccessRights

private static void testAccessRights()
                              throws TraceRouteException
Throws:
TraceRouteException

printNetworkInterfaces

private static void printNetworkInterfaces()
Show all networkinterfaces which are found on the system


getDefaultNetworkInterface

public static jpcap.NetworkInterface getDefaultNetworkInterface()
Try to find out the standart device of the system. Fixme: Instead, traceroute should use the interface where the target IP was sniffed.

Returns:
the default network interface

getNewCaptor

protected static jpcap.JpcapCaptor getNewCaptor()
                                         throws IOException
Creation and return of a new captor instance. fixme: why so complicated? and we should filter for the id of this trace in the captor. see http://www.winpcaporg/docs/man/html/group__language.html

Returns:
The generated captor.
Throws:
IOException

requestID

protected static byte requestID()
                         throws TraceRouteException
Fetch a unused id, which can be used as indentifier.

Returns:
An unsed id
Throws:
TraceRouteException

releaseID

protected static void releaseID(byte id)
Release an id. After a release, an id can be reused by a nother traceroute.

Parameters:
id - The id to release.

Copyright © 2005 Verinec, DIUF