net.sourceforge.jpcap.simulator
Class HeaderGenerator

java.lang.Object
  extended bynet.sourceforge.jpcap.simulator.HeaderGenerator
All Implemented Interfaces:
ARPFields, EthernetFields, ICMPFields, IPFields, TCPFields, UDPFields

public class HeaderGenerator
extends java.lang.Object
implements EthernetFields, ARPFields, IPFields, TCPFields, UDPFields, ICMPFields

This class generates random protocol headers.


Field Summary
 
Fields inherited from interface net.sourceforge.jpcap.net.EthernetFields
ETH_CODE_LEN, ETH_CODE_POS, ETH_DST_POS, ETH_HEADER_LEN, ETH_SRC_POS
 
Fields inherited from interface net.sourceforge.jpcap.net.ARPFields
ARP_ADDR_SIZE_LEN, ARP_ADDR_TYPE_LEN, ARP_ETH_ADDR_CODE, ARP_HEADER_LEN, ARP_HW_LEN_POS, ARP_HW_TYPE_POS, ARP_IP_ADDR_CODE, ARP_OP_LEN, ARP_OP_POS, ARP_OP_REP_CODE, ARP_OP_REQ_CODE, ARP_PR_LEN_POS, ARP_PR_TYPE_POS, ARP_S_HW_ADDR_POS, ARP_S_PR_ADDR_POS, ARP_T_HW_ADDR_POS, ARP_T_PR_ADDR_POS
 
Fields inherited from interface net.sourceforge.jpcap.net.IPFields
IP_CODE_LEN, IP_CODE_POS, IP_CSUM_LEN, IP_CSUM_POS, IP_DST_POS, IP_FRAG_LEN, IP_FRAG_POS, IP_HEADER_LEN, IP_ID_LEN, IP_ID_POS, IP_LEN_LEN, IP_LEN_POS, IP_SRC_POS, IP_TOS_LEN, IP_TOS_POS, IP_TTL_LEN, IP_TTL_POS, IP_VER_LEN, IP_VER_POS
 
Fields inherited from interface net.sourceforge.jpcap.net.TCPFields
TCP_ACK_LEN, TCP_ACK_MASK, TCP_ACK_POS, TCP_CSUM_LEN, TCP_CSUM_POS, TCP_DP_POS, TCP_FIN_MASK, TCP_FLAG_LEN, TCP_FLAG_POS, TCP_HEADER_LEN, TCP_PORT_LEN, TCP_PSH_MASK, TCP_RST_MASK, TCP_SEQ_LEN, TCP_SEQ_POS, TCP_SP_POS, TCP_SYN_MASK, TCP_URG_LEN, TCP_URG_MASK, TCP_URG_POS, TCP_WIN_LEN, TCP_WIN_POS
 
Fields inherited from interface net.sourceforge.jpcap.net.UDPFields
UDP_CSUM_LEN, UDP_CSUM_POS, UDP_DP_POS, UDP_HEADER_LEN, UDP_LEN_LEN, UDP_LEN_POS, UDP_PORT_LEN, UDP_SP_POS
 
Fields inherited from interface net.sourceforge.jpcap.net.ICMPFields
ICMP_CODE_LEN, ICMP_CODE_POS, ICMP_CSUM_LEN, ICMP_CSUM_POS, ICMP_HEADER_LEN, ICMP_SUBC_LEN, ICMP_SUBC_POS
 
Constructor Summary
HeaderGenerator()
           
 
Method Summary
static byte[] generateRandomARPHeader()
          Generate a pseudo-random ARP header.
static byte[] generateRandomEthernetHeader()
          Generate a pseudo-random ethernet header.
static byte[] generateRandomICMPHeader()
          Generate a pseudo-random ICMP header.
static byte[] generateRandomIPHeader()
          Generate a pseudo-random IP header.
static byte[] generateRandomTCPHeader()
          Generate a pseudo-random TCP header.
static byte[] generateRandomUDPHeader()
          Generate a pseudo-random TCP header.
static int randomEthernetProtocol()
          Generate a pseudo-random ethernet protocol code.
static int randomICMPType()
          Generate a pseudo-random ICMP protocol code (message type).
static int randomIPProtocol()
          Generate a pseudo-random IP protocol code.
static int randomPort()
          Generate a pseudo-random IP port.
static int randomPrivilegedPort()
          Generate a pseudo-random well-known IP port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeaderGenerator

public HeaderGenerator()
Method Detail

randomEthernetProtocol

public static int randomEthernetProtocol()
Generate a pseudo-random ethernet protocol code.


randomIPProtocol

public static int randomIPProtocol()
Generate a pseudo-random IP protocol code.


randomPort

public static int randomPort()
Generate a pseudo-random IP port.


randomPrivilegedPort

public static int randomPrivilegedPort()
Generate a pseudo-random well-known IP port.


randomICMPType

public static int randomICMPType()
Generate a pseudo-random ICMP protocol code (message type).


generateRandomEthernetHeader

public static byte[] generateRandomEthernetHeader()
Generate a pseudo-random ethernet header.


generateRandomARPHeader

public static byte[] generateRandomARPHeader()
Generate a pseudo-random ARP header.


generateRandomIPHeader

public static byte[] generateRandomIPHeader()
Generate a pseudo-random IP header.


generateRandomUDPHeader

public static byte[] generateRandomUDPHeader()
Generate a pseudo-random TCP header.


generateRandomTCPHeader

public static byte[] generateRandomTCPHeader()
Generate a pseudo-random TCP header.


generateRandomICMPHeader

public static byte[] generateRandomICMPHeader()
Generate a pseudo-random ICMP header.