public final class MACPacketImpl extends AbstractPacket implements MACPacket
| Constructor and Description |
|---|
MACPacketImpl(Protocol protocol,
PCapPacket parent,
Buffer headers,
Buffer payload)
Construct a new
MACPacket based on the supplied headers. |
| Modifier and Type | Method and Description |
|---|---|
MACPacket |
clone() |
static MACPacketImpl |
create(PCapPacket parent,
Buffer headers)
Creates a new
MACPacketImpl and it assumes ethernet II and it
does not check whether or not the ethertype is a known type. |
long |
getArrivalTime()
The arrival time of this packet in microseconds relative to epoch
(midnight UTC of January 1, 1970).
|
java.lang.String |
getDestinationMacAddress() |
IPPacket |
getNextPacket()
Get the next frame, or null if there is none.
|
Protocol |
getNextProtocol() |
java.lang.String |
getSourceMacAddress() |
void |
setDestinationMacAddress(java.lang.String macAddress) |
void |
setSourceMacAddress(java.lang.String macAddress)
Set the MAC address of this
MACPacket. |
static java.lang.String |
toHexString(Buffer buffer,
int start,
int length) |
java.lang.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(java.io.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 MACPacketImpl(Protocol protocol, PCapPacket parent, Buffer headers, Buffer payload)
MACPacket based on the supplied headers.public static MACPacketImpl create(PCapPacket parent, Buffer headers)
MACPacketImpl and it assumes ethernet II and it
does not check whether or not the ethertype is a known type. This method
should only be used by the internal packet creating functions such as the
TransportPacketFactoryImpl or the framers.parent - headers - public final java.lang.String getSourceMacAddress()
getSourceMacAddress in interface MACPacketpublic static java.lang.String toHexString(Buffer buffer, int start, int length) throws java.io.IOException
java.io.IOExceptionpublic final java.lang.String getDestinationMacAddress()
getDestinationMacAddress in interface MACPacketpublic 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 java.lang.String toString()
toString in class java.lang.Objectpublic 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 void write(java.io.OutputStream out,
Buffer payload)
throws java.io.IOException
Packetpublic void setSourceMacAddress(java.lang.String macAddress)
MACPacket.setSourceMacAddress in interface MACPacketpublic void setDestinationMacAddress(java.lang.String macAddress)
setDestinationMacAddress in interface MACPacketpublic MACPacket clone()
public Protocol getNextProtocol() throws java.io.IOException
java.io.IOExceptionpublic IPPacket getNextPacket() throws java.io.IOException
PacketgetNextPacket in interface Packetjava.io.IOExceptionCopyright © 2018. All Rights Reserved.