jpcap
Class JpcapSender

java.lang.Object
  |
  +--jpcap.JpcapSender

public class JpcapSender
extends java.lang.Object

This class is used to send a packet.


Method Summary
 void close()
          Closes the interface.
static JpcapSender openDevice(java.lang.String device)
          Initializes a network interface for sending a packet, and returns an instance of this class.
 void sendPacket(IPPacket packet)
          Sends a packet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

openDevice

public static JpcapSender openDevice(java.lang.String device)
                              throws java.io.IOException
Initializes a network interface for sending a packet, and returns an instance of this class.

Parameters:
device - Interface for sending a packet
Returns:
intstance of this class (JpcapSender)
Throws:
IOException - Raised when initialization of the interface failed

sendPacket

public void sendPacket(IPPacket packet)
Sends a packet.

On UNIX, only IP packet is supported. For ICMP, only echo packet is supported (to prohibit DOS attack).

ON WINDOWS, you may be able to send non-IP packet, too. However, on Windows, you must also set the Datalink layer header (e.g. Ethernet header).

Parameters:
packet - Packet to be sent

close

public void close()
Closes the interface.