public abstract class TransportPacketImpl extends AbstractPacket implements TransportPacket
| Modifier | Constructor and Description |
|---|---|
protected |
TransportPacketImpl(IPPacket parent,
Protocol protocol,
Buffer headers,
Buffer payload) |
| Modifier and Type | Method and Description |
|---|---|
abstract TransportPacket |
clone() |
long |
getArrivalTime()
The arrival time of this packet in microseconds relative to epoch
(midnight UTC of January 1, 1970).
|
int |
getDestinationPort() |
Packet |
getNextPacket()
Get the next frame, or null if there is none.
|
IPPacket |
getParentPacket()
Almost all packets have a parent, which is the encapsulating protocol.
|
int |
getSourcePort() |
boolean |
isSCTP() |
boolean |
isTCP() |
boolean |
isUDP() |
void |
setDestinationPort(int port) |
void |
setSourcePort(int port) |
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.
|
checkParent, getName, getPacket, getPayload, getProtocol, hasProtocol, writeequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetHeaderLengthgetName, getPacket, getPayload, getProtocol, hasProtocol, write, writepublic boolean isUDP()
isUDP in interface TransportPacketpublic boolean isTCP()
isTCP in interface TransportPacketpublic boolean isSCTP()
isSCTP in interface TransportPacketpublic final int getSourcePort()
getSourcePort in interface TransportPacketpublic final void setSourcePort(int port)
setSourcePort in interface TransportPacketpublic final int getDestinationPort()
getDestinationPort in interface TransportPacketpublic final void setDestinationPort(int port)
setDestinationPort in interface TransportPacketpublic 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 final long getArrivalTime()
PacketSimpleDateFormat 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 abstract TransportPacket clone()
clone in interface Packetclone in interface TransportPacketclone in class AbstractPacketpublic Packet getNextPacket() throws IOException
PacketgetNextPacket in interface PacketIOExceptionpublic IPPacket getParentPacket()
PacketSipPacket is typically a
TransportPacket such as UDPPacket or a TCPPacket.
The parent of a TransportPacket is usually a IPPacket and
so on.getParentPacket in interface PacketgetParentPacket in interface TransportPacketgetParentPacket in class AbstractPacketCopyright © 2021. All Rights Reserved.