Package pcap.spi

Interface Service.LiveOptions

All Known Implementing Classes:
DefaultLiveOptions
Enclosing interface:
Service

public static interface Service.LiveOptions
Options for opening live capture handle by Service.live(Interface, LiveOptions).
Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get buffer size options.
    bufferSize(int bufferSize)
    Packets that arrive for a capture are stored in a buffer, so that they do not have to be read by the application as soon as they arrive.
    immediate(boolean immediate)
    In immediate mode, packets are always delivered as soon as they arrive, with no buffering.
    boolean
    Get immediate mode options.
    boolean
    Get promiscuous mode options.
    boolean
    Get radio frequency monitor mode options.
    promiscuous(boolean promiscuous)
    On broadcast LANs such as Ethernet, if the network isn't switched, or if the adapter is connected to a "mirror port" on a switch to which all packets passing through the switch are sent, a network adapter receives all packets on the LAN, including unicast or multicast packets not sent to a network address that the network adapter isn't configured to recognize.
    rfmon(boolean rfmon)
    On IEEE 802.11 wireless LANs, even if an adapter is in promiscuous mode, it will supply to the host only frames for the network with which it's associated.
    int
    Get snapshot length.
    snapshotLength(int snapshotLength)
    If, when capturing, you capture the entire contents of the packet, that requires more CPU time to copy the packet to your application, more disk and possibly network bandwidth to write the packet data to a file, and more disk space to save the packet.
    int
    Get read timeout options in millisecond.
    timeout(int timeout)
    If, when capturing, packets are delivered as soon as they arrive, the application capturing the packets will be woken up for each packet as it arrives, and might have to make one or more calls to the operating system to fetch each packet.
    Get timestamp precision options.
    Set timestamp precision options.
    Get timestamp type options.
    On some platforms, the time stamp given to packets on live captures can come from different sources that can have different resolutions or that can have different relationships to the time values for the current time supplied by routines on the native operating system.
  • Method Details

    • snapshotLength

      int snapshotLength()
      Get snapshot length.
      Returns:
      returns snapshot length.
      Since:
      1.0.0
    • snapshotLength

      Service.LiveOptions snapshotLength(int snapshotLength)
      If, when capturing, you capture the entire contents of the packet, that requires more CPU time to copy the packet to your application, more disk and possibly network bandwidth to write the packet data to a file, and more disk space to save the packet. If you don't need the entire contents of the packet - for example, if you are only interested in the TCP headers of packets - you can set the "snapshot length" for the capture to an appropriate value. If the snapshot length is less than the size of a packet that is captured, only the first snapshot length bytes of that packet will be captured and provided as packet data. A snapshot length of 65535 should be sufficient, on most if not all networks, to capture all the data available from the packet.
      Parameters:
      snapshotLength - shapshot length.
      Returns:
      returns this instance.
      Since:
      1.0.0
      See Also:
    • isPromiscuous

      boolean isPromiscuous()
      Get promiscuous mode options.
      Returns:
      returns true if in promiscuous mode, false otherwise.
      Since:
      1.0.0
    • promiscuous

      Service.LiveOptions promiscuous(boolean promiscuous)
      On broadcast LANs such as Ethernet, if the network isn't switched, or if the adapter is connected to a "mirror port" on a switch to which all packets passing through the switch are sent, a network adapter receives all packets on the LAN, including unicast or multicast packets not sent to a network address that the network adapter isn't configured to recognize. Normally, the adapter will discard those packets; however, many network adapters support "promiscuous mode", which is a mode in which all packets, even if they are not sent to an address that the adapter recognizes, are provided to the host. This is useful for passively capturing traffic between two or more other hosts for analysis. Note that even if an application does not set promiscuous mode, the adapter could well be in promiscuous mode for some other reason. For now, this doesn't work on the "any" device; if an argument of "any" is supplied, the setting of promiscuous mode is ignored.
      Parameters:
      promiscuous - promiscuous mode.
      Returns:
      returns this instance.
      Since:
      1.0.0
      See Also:
    • isRfmon

      boolean isRfmon()
      Get radio frequency monitor mode options.
      Returns:
      returns true if in rfmon, false otherwise.
      Since:
      1.0.0
    • rfmon

      Service.LiveOptions rfmon(boolean rfmon)
      On IEEE 802.11 wireless LANs, even if an adapter is in promiscuous mode, it will supply to the host only frames for the network with which it's associated. It might also supply only data frames, not management or control frames, and might not provide the 802.11 header or radio information pseudo-header for those frames. In "monitor mode", sometimes also called "rfmon mode" (for "Radio Frequency MONitor"), the adapter will supply all frames that it receives, with 802.11 headers, and might supply a pseudo-header with radio information about the frame as well. Note that in monitor mode the adapter might disassociate from the network with which it's associated, so that you will not be able to use any wireless networks with that adapter. This could prevent accessing files on a network server, or resolving host names or network addresses, if you are capturing in monitor mode and are not connected to another network with another adapter.
      Parameters:
      rfmon - true for rfmon, false non non rfmon.
      Returns:
      returns this instance.
      Since:
      1.0.0
      See Also:
    • timeout

      int timeout()
      Get read timeout options in millisecond.
      Returns:
      returns read timeout in millisecond.
      Since:
      1.0.0
    • timeout

      Service.LiveOptions timeout(int timeout)
      If, when capturing, packets are delivered as soon as they arrive, the application capturing the packets will be woken up for each packet as it arrives, and might have to make one or more calls to the operating system to fetch each packet. If, instead, packets are not delivered as soon as they arrive, but are delivered after a short delay (called a "packet buffer timeout"), more than one packet can be accumulated before the packets are delivered, so that a single wakeup would be done for multiple packets, and each set of calls made to the operating system would supply multiple packets, rather than a single packet. This reduces the per-packet CPU overhead if packets are arriving at a high rate, increasing the number of packets per second that can be captured. The packet buffer timeout is required so that an application won't wait for the operating system's capture buffer to fill up before packets are delivered; if packets are arriving slowly, that wait could take an arbitrarily long period of time. Not all platforms support a packet buffer timeout; on platforms that don't, the packet buffer timeout is ignored. A zero value for the timeout, on platforms that support a packet buffer timeout, will cause a read to wait forever to allow enough packets to arrive, with no timeout. A negative value is invalid; the result of setting the timeout to a negative value is unpredictable. NOTE: the packet buffer timeout cannot be used to cause calls that read packets to return within a limited period of time, because, on some platforms, the packet buffer timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the packet buffer timeout should NOT be used, for example, in an interactive application to allow the packet capture loop to "poll" for user input periodically, as there's no guarantee that a call reading packets will return after the timeout expires even if no packets have arrived.
      Parameters:
      timeout - read timeout in millisecond .
      Returns:
      returns this instance.
      Since:
      1.0.0
      See Also:
    • timestampType

      Timestamp.Type timestampType()
      Get timestamp type options.
      Returns:
      returns Timestamp.Type options.
      Since:
      1.0.0
    • timestampType

      Service.LiveOptions timestampType(Timestamp.Type timestampType)
      On some platforms, the time stamp given to packets on live captures can come from different sources that can have different resolutions or that can have different relationships to the time values for the current time supplied by routines on the native operating system.
      Parameters:
      timestampType - timestamp type.
      Returns:
      returns this instance.
      Since:
      1.0.0
      See Also:
    • isImmediate

      boolean isImmediate()
      Get immediate mode options.
      Returns:
      returns true if in immediate mode, false otherwise.
      Since:
      1.0.0
    • immediate

      Service.LiveOptions immediate(boolean immediate)
      In immediate mode, packets are always delivered as soon as they arrive, with no buffering.
      Parameters:
      immediate - true for immediate mode, false otherwise.
      Returns:
      returns this instance.
      Since:
      1.0.0
    • bufferSize

      int bufferSize()
      Get buffer size options.
      Returns:
      returns buffer size options.
      Since:
      1.0.0
    • bufferSize

      Service.LiveOptions bufferSize(int bufferSize)
      Packets that arrive for a capture are stored in a buffer, so that they do not have to be read by the application as soon as they arrive. On some platforms, the buffer's size can be set; a size that's too small could mean that, if too many packets are being captured and the snapshot length doesn't limit the amount of data that's buffered, packets could be dropped if the buffer fills up before the application can read packets from it, while a size that's too large could use more non-pageable operating system memory than is necessary to prevent packets from being dropped.
      Parameters:
      bufferSize - buffer size.
      Returns:
      returns this instance.
      Since:
      1.0.0
      See Also:
    • timestampPrecision

      Timestamp.Precision timestampPrecision()
      Get timestamp precision options.
      Returns:
      returns Timestamp.Precision options.
      Since:
      1.0.0
    • timestampPrecision

      Service.LiveOptions timestampPrecision(Timestamp.Precision timestampPrecision)
      Set timestamp precision options.
      Parameters:
      timestampPrecision - timestamp precision.
      Returns:
      returns this instance.
      Since:
      1.0.0