public final class PCapPacketImpl extends AbstractPacket implements PCapPacket
| Constructor and Description |
|---|
PCapPacketImpl(PcapGlobalHeader pcapGlobalHeader,
PcapRecordHeader header,
Buffer payload)
Constructor which uses the PCAP file's global header to support more than just Ethernet link layers
|
PCapPacketImpl(PcapRecordHeader header,
Buffer payload)
Constructor which assumes an Ethernet link layer.
|
| Modifier and Type | Method and Description |
|---|---|
PCapPacket |
clone() |
long |
getArrivalTime()
The arrival time of this packet in microseconds relative to epoch
(midnight UTC of January 1, 1970).
|
long |
getCapturedLength()
Get the actual length of what is contained in this frame.
|
Packet |
getNextPacket()
Get the next frame, or null if there is none.
|
long |
getTotalLength()
Get the total length of the data.
|
String |
toString() |
void |
verify()
Calling this method will force the packet to completely parse its data
and check so that all the information conforms to whatever rules this
packet needs to follow.
|
void |
write(OutputStream out,
Buffer payload)
Writes this packet to the
OutputStream with the supplied payload. |
checkParent, getName, getPacket, getParentPacket, getPayload, getProtocol, hasProtocol, writeequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetName, getPacket, getParentPacket, getPayload, getProtocol, hasProtocol, writepublic PCapPacketImpl(PcapRecordHeader header, Buffer payload)
public PCapPacketImpl(PcapGlobalHeader pcapGlobalHeader, PcapRecordHeader header, Buffer payload)
public long getArrivalTime()
SimpleDateFormat but it can
only handle milliseconds precision (you will have to write your own date
formatter if you want microseconds).
Here is a snippet illustrating how to turn the arrival time of the packet
into a human readable date
Packet p = ...;
SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS");
Date date = new Date(p.getArrivalTime() / 1000);
System.out.println("Arrival time: " + formatter.format(date));
Note how an integer devision is performed on the arrival time to
"cut off" the microseconds from the time stampgetArrivalTime in interface Packetpublic long getTotalLength()
PCapPacketgetTotalLength in interface PCapPacketpublic long getCapturedLength()
PCapPacketgetCapturedLength in interface PCapPacketpublic void verify()
IPPacket, hardly does anything
in this method but more complex protocols such as SIP (once again), HTTP
etc can spend quite some time verifying everything, which is why you
don't want to do it unless you really have to.
In general, yajpcap has the philosophy of
"assume that everything is ok until things blow up and then deal with it"verify in interface Packetverify in class AbstractPacketpublic void write(OutputStream out, Buffer payload) throws IOException
PacketOutputStream with the supplied payload.
You can use this method to e.g. write a raw UDPPacket to the
stream with this payload. Note, if the UDPPacket already had a
payload it will be ignored so use this method with care.write in interface PacketIOExceptionpublic PCapPacket clone()
clone in interface Packetclone in interface PCapPacketclone in class AbstractPacketpublic Packet getNextPacket() throws IOException, PacketParseException
PacketgetNextPacket in interface PacketIOExceptionPacketParseException - if the next packet can't be parsed by the
framerCopyright © 2021. All Rights Reserved.