Package org.onlab.packet
Class IPv4
- java.lang.Object
- 
- org.onlab.packet.BasePacket
- 
- org.onlab.packet.IP
- 
- org.onlab.packet.IPv4
 
 
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected shortchecksumprotected intdestinationAddressprotected bytediffServprotected byteflagsprotected shortfragmentOffsetprotected byteheaderLengthprotected shortidentificationprotected booleanisTruncatedprotected byte[]optionsprotected byteprotocolstatic java.util.Map<java.lang.Byte,Deserializer<? extends IPacket>>PROTOCOL_DESERIALIZER_MAPstatic bytePROTOCOL_ICMPstatic bytePROTOCOL_IGMPstatic bytePROTOCOL_PIMstatic bytePROTOCOL_TCPstatic bytePROTOCOL_UDPprotected intsourceAddressprotected shorttotalLengthprotected bytettlprotected byteversion- 
Fields inherited from class org.onlab.packet.BasePacketparent, payload
 
- 
 - 
Constructor SummaryConstructors Constructor Description IPv4()Default constructor that sets the version to 4.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Deserializer<IPv4>deserializer()Deserializer function for IPv4 packets.booleanequals(java.lang.Object obj)static java.lang.StringfromIPv4Address(int ipAddress)Accepts an IPv4 address and returns of string of the form xxx.xxx.xxx.xxx, e.g., 192.168.0.1.static java.lang.StringfromIPv4AddressCollection(java.util.Collection<java.lang.Integer> ipAddresses)Accepts a collection of IPv4 addresses as integers and returns a single String useful in toString method's containing collections of IP addresses.shortgetChecksum()intgetDestinationAddress()bytegetDiffServ()Gets the DiffServ octet (including the DSCP and ECN bits).bytegetDscp()Gets the DSCP value (6 bits).bytegetEcn()Gets the ECN value (2 bits).bytegetFlags()shortgetFragmentOffset()bytegetHeaderLength()shortgetIdentification()byte[]getOptions()bytegetProtocol()intgetSourceAddress()shortgetTotalLength()bytegetTtl()bytegetVersion()Gets IP version number.inthashCode()booleanisTruncated()voidresetChecksum()Reset any checksum as needed, and call resetChecksum on all parents.byte[]serialize()Serializes the packet.IPv4setChecksum(short checksum)IPv4setDestinationAddress(int destinationAddress)IPv4setDestinationAddress(java.lang.String destinationAddress)IPv4setDiffServ(byte diffServ)Sets the DiffServ octet (including the DSCP and ECN bits).IPv4setDscp(byte dscp)Sets the DSCP value (6 bits).IPv4setEcn(byte ecn)Sets the ECN value (2 bits).IPv4setFlags(byte flags)IPv4setFragmentOffset(short fragmentOffset)IPv4setIdentification(short identification)IPv4setOptions(byte[] options)IPv4setProtocol(byte protocol)IPv4setSourceAddress(int sourceAddress)IPv4setSourceAddress(java.lang.String sourceAddress)voidsetTruncated(boolean isTruncated)IPv4setTtl(byte ttl)IPv4setVersion(byte version)Sets IP version number.static inttoIPv4Address(byte[] ipAddress)Accepts an IPv4 address in a byte array and returns the corresponding 32-bit integer value.static inttoIPv4Address(java.lang.String ipAddress)Accepts an IPv4 address of the form xxx.xxx.xxx.xxx, ie 192.168.0.1 and returns the corresponding 32 bit integer.static byte[]toIPv4AddressBytes(int ipAddress)Accepts an IPv4 address in the form of an integer and returns the corresponding byte array.static byte[]toIPv4AddressBytes(java.lang.String ipAddress)Accepts an IPv4 address of the form xxx.xxx.xxx.xxx, ie 192.168.0.1 and returns the corresponding byte array.java.lang.StringtoString()- 
Methods inherited from class org.onlab.packet.BasePacketclone, getParent, getPayload, setParent, setPayload
 
- 
 
- 
- 
- 
Field Detail- 
PROTOCOL_ICMPpublic static final byte PROTOCOL_ICMP - See Also:
- Constant Field Values
 
 - 
PROTOCOL_IGMPpublic static final byte PROTOCOL_IGMP - See Also:
- Constant Field Values
 
 - 
PROTOCOL_TCPpublic static final byte PROTOCOL_TCP - See Also:
- Constant Field Values
 
 - 
PROTOCOL_UDPpublic static final byte PROTOCOL_UDP - See Also:
- Constant Field Values
 
 - 
PROTOCOL_PIMpublic static final byte PROTOCOL_PIM - See Also:
- Constant Field Values
 
 - 
PROTOCOL_DESERIALIZER_MAPpublic static final java.util.Map<java.lang.Byte,Deserializer<? extends IPacket>> PROTOCOL_DESERIALIZER_MAP 
 - 
versionprotected byte version 
 - 
headerLengthprotected byte headerLength 
 - 
diffServprotected byte diffServ 
 - 
totalLengthprotected short totalLength 
 - 
identificationprotected short identification 
 - 
flagsprotected byte flags 
 - 
fragmentOffsetprotected short fragmentOffset 
 - 
ttlprotected byte ttl 
 - 
protocolprotected byte protocol 
 - 
checksumprotected short checksum 
 - 
sourceAddressprotected int sourceAddress 
 - 
destinationAddressprotected int destinationAddress 
 - 
optionsprotected byte[] options 
 - 
isTruncatedprotected boolean isTruncated 
 
- 
 - 
Method Detail- 
getVersionpublic byte getVersion() Description copied from class:IPGets IP version number.- Specified by:
- getVersionin class- IP
- Returns:
- IP version number
 
 - 
setVersionpublic IPv4 setVersion(byte version) Description copied from class:IPSets IP version number.- Specified by:
- setVersionin class- IP
- Parameters:
- version- the version to set
- Returns:
- IP class
 
 - 
getHeaderLengthpublic byte getHeaderLength() - Returns:
- the headerLength
 
 - 
getDscppublic byte getDscp() Gets the DSCP value (6 bits).- Returns:
- the DSCP value (6 bits)
 
 - 
setDscppublic IPv4 setDscp(byte dscp) Sets the DSCP value (6 bits).- Parameters:
- dscp- the DSCP value (6 bits)
- Returns:
- this
 
 - 
getEcnpublic byte getEcn() Gets the ECN value (2 bits).- Returns:
- the ECN value (2 bits)
 
 - 
setEcnpublic IPv4 setEcn(byte ecn) Sets the ECN value (2 bits).- Parameters:
- ecn- the ECN value (2 bits)
- Returns:
- this
 
 - 
getDiffServpublic byte getDiffServ() Gets the DiffServ octet (including the DSCP and ECN bits).- Returns:
- the diffServ octet (including the DSCP and ECN bits)
 
 - 
setDiffServpublic IPv4 setDiffServ(byte diffServ) Sets the DiffServ octet (including the DSCP and ECN bits).- Parameters:
- diffServ- the diffServ octet to set (including the DSCP and ECN bits)
- Returns:
- this
 
 - 
getTotalLengthpublic short getTotalLength() - Returns:
- the totalLength
 
 - 
getIdentificationpublic short getIdentification() - Returns:
- the identification
 
 - 
isTruncatedpublic boolean isTruncated() 
 - 
setTruncatedpublic void setTruncated(boolean isTruncated) 
 - 
setIdentificationpublic IPv4 setIdentification(short identification) - Parameters:
- identification- the identification to set
- Returns:
- this
 
 - 
getFlagspublic byte getFlags() - Returns:
- the flags
 
 - 
setFlagspublic IPv4 setFlags(byte flags) - Parameters:
- flags- the flags to set
- Returns:
- this s
 
 - 
getFragmentOffsetpublic short getFragmentOffset() - Returns:
- the fragmentOffset
 
 - 
setFragmentOffsetpublic IPv4 setFragmentOffset(short fragmentOffset) - Parameters:
- fragmentOffset- the fragmentOffset to set
- Returns:
- this
 
 - 
getTtlpublic byte getTtl() - Returns:
- the ttl
 
 - 
setTtlpublic IPv4 setTtl(byte ttl) - Parameters:
- ttl- the ttl to set
- Returns:
- this
 
 - 
getProtocolpublic byte getProtocol() - Returns:
- the protocol
 
 - 
setProtocolpublic IPv4 setProtocol(byte protocol) - Parameters:
- protocol- the protocol to set
- Returns:
- this
 
 - 
getChecksumpublic short getChecksum() - Returns:
- the checksum
 
 - 
setChecksumpublic IPv4 setChecksum(short checksum) - Parameters:
- checksum- the checksum to set
- Returns:
- this
 
 - 
resetChecksumpublic void resetChecksum() Description copied from interface:IPacketReset any checksum as needed, and call resetChecksum on all parents.- Specified by:
- resetChecksumin interface- IPacket
- Overrides:
- resetChecksumin class- BasePacket
 
 - 
getSourceAddresspublic int getSourceAddress() - Returns:
- the sourceAddress
 
 - 
setSourceAddresspublic IPv4 setSourceAddress(int sourceAddress) - Parameters:
- sourceAddress- the sourceAddress to set
- Returns:
- this
 
 - 
setSourceAddresspublic IPv4 setSourceAddress(java.lang.String sourceAddress) - Parameters:
- sourceAddress- the sourceAddress to set
- Returns:
- this
 
 - 
getDestinationAddresspublic int getDestinationAddress() - Returns:
- the destinationAddress
 
 - 
setDestinationAddresspublic IPv4 setDestinationAddress(int destinationAddress) - Parameters:
- destinationAddress- the destinationAddress to set
- Returns:
- this
 
 - 
setDestinationAddresspublic IPv4 setDestinationAddress(java.lang.String destinationAddress) - Parameters:
- destinationAddress- the destinationAddress to set
- Returns:
- this
 
 - 
getOptionspublic byte[] getOptions() - Returns:
- the options
 
 - 
setOptionspublic IPv4 setOptions(byte[] options) - Parameters:
- options- the options to set
- Returns:
- this
 
 - 
serializepublic byte[] serialize() Serializes the packet. Will compute and set the following fields if they are set to specific values at the time serialize is called: -checksum : 0 -headerLength : 0 -totalLength : 0- Returns:
- a byte[] containing this packet and payloads
 
 - 
toIPv4Addresspublic static int toIPv4Address(java.lang.String ipAddress) Accepts an IPv4 address of the form xxx.xxx.xxx.xxx, ie 192.168.0.1 and returns the corresponding 32 bit integer.- Parameters:
- ipAddress- ip address in string form
- Returns:
- int ip address value
 
 - 
toIPv4Addresspublic static int toIPv4Address(byte[] ipAddress) Accepts an IPv4 address in a byte array and returns the corresponding 32-bit integer value.- Parameters:
- ipAddress- ip address in byte form
- Returns:
- int ip address value
 
 - 
fromIPv4Addresspublic static java.lang.String fromIPv4Address(int ipAddress) Accepts an IPv4 address and returns of string of the form xxx.xxx.xxx.xxx, e.g., 192.168.0.1.- Parameters:
- ipAddress- ip address in form
- Returns:
- string form of ip address
 
 - 
fromIPv4AddressCollectionpublic static java.lang.String fromIPv4AddressCollection(java.util.Collection<java.lang.Integer> ipAddresses) Accepts a collection of IPv4 addresses as integers and returns a single String useful in toString method's containing collections of IP addresses.- Parameters:
- ipAddresses- collection
- Returns:
- ip addresses in comma-separated string form
 
 - 
toIPv4AddressBytespublic static byte[] toIPv4AddressBytes(java.lang.String ipAddress) Accepts an IPv4 address of the form xxx.xxx.xxx.xxx, ie 192.168.0.1 and returns the corresponding byte array.- Parameters:
- ipAddress- The IP address in the form xx.xxx.xxx.xxx.
- Returns:
- The IP address separated into bytes
 
 - 
toIPv4AddressBytespublic static byte[] toIPv4AddressBytes(int ipAddress) Accepts an IPv4 address in the form of an integer and returns the corresponding byte array.- Parameters:
- ipAddress- The IP address as an integer.
- Returns:
- The IP address separated into bytes.
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- BasePacket
 
 - 
equalspublic boolean equals(java.lang.Object obj) - Overrides:
- equalsin class- BasePacket
 
 - 
deserializerpublic static Deserializer<IPv4> deserializer() Deserializer function for IPv4 packets.- Returns:
- deserializer function
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-