Class: PacketGen::Header::SCTP
- Defined in:
- lib/packetgen/header/sctp.rb,
lib/packetgen/header/sctp.rb,
lib/packetgen/header/sctp/chunk.rb,
lib/packetgen/header/sctp/chunk.rb,
lib/packetgen/header/sctp/error.rb,
lib/packetgen/header/sctp/padded32.rb,
lib/packetgen/header/sctp/parameter.rb
Overview
SCTP header (RFC 9260)
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port Number | Destination Port Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Verification Tag |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Chunk #1 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Chunk #n |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
A SCTP header is composed of:
-
#sport, source port number (
BinStruct::Int16
), -
#dport, destination port number (
BinStruct::Int16
), -
#verification_tag (
BinStruct::Int32
), -
#checksum (
BinStruct::Int32le
), -
#chunks, list of chunks (ArrayOfChunk).
Defined Under Namespace
Modules: Padded32 Classes: AbortChunk, ArrayOfChunk, ArrayOfError, ArrayOfParameter, BaseChunk, CookieAckChunk, CookieEchoChunk, CookiePreservativeParameter, CookieReceivedWhileShuttingDownError, DataChunk, ECNParameter, Error, ErrorChunk, HeartbeatAckChunk, HeartbeatChunk, HeartbeatInfo, HostnameParameter, IPv4Parameter, IPv6Parameter, InitAckChunk, InitChunk, InvalidMandatoryParameterError, InvalidStreamIdError, MissingMandatoryParameterError, NoUserDataError, NoValueError, OutOfResourceError, Parameter, ProtocolViolationError, RestartAssociationWithNewAddressError, SackChunk, ShutdownAckChunk, ShutdownChunk, ShutdownCompleteChunk, StaleCookieError, StateCookieParameter, SupportedAddrTypesParameter, UnknownChunk, UnrecognizedChunkTypeError, UnrecognizedParameter, UnrecognizedParametersError, UnresolvableAddressError, UserInitiatedAbortError
Constant Summary collapse
- IP_PROTOCOL =
IP protocol number for SCTP
132
- UDP_PORT =
Port number for SCTP over TCP (RFC 6951)
9899
- HearbeatInfo =
BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum, length_class: BinStruct::Int16, attr_in_length: 'TLV')
Instance Attribute Summary collapse
-
#checksum ⇒ Integer
32-bit TCP checksum.
-
#chunks ⇒ ArrayOfChunk
List of chunks this packet transports.
-
#dport ⇒ Integer
16-bit TCP destination port.
-
#sport ⇒ Integer
16-bit TCP source port.
-
#verification_tag ⇒ Integer
32-bit verification tag.
Instance Method Summary collapse
-
#calc_checksum ⇒ Integer
Compute SCTP checksum and set #checksum attribute.
-
#calc_length ⇒ void
Compute SCTP chunk lengths.
- #inspect ⇒ String
Methods inherited from Base
bind, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, #ll_header
Methods included from PacketGen::Headerable
#added_to_packet, included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read, #to_s
Constructor Details
This class inherits a constructor from PacketGen::Header::Base
Instance Attribute Details
#checksum ⇒ Integer
32-bit TCP checksum. This is a CRC32C checkum, computed on SCTP header and all its chunks.
70 |
# File 'lib/packetgen/header/sctp.rb', line 70 define_attr :checksum, BinStruct::Int32le |
#chunks ⇒ ArrayOfChunk
List of chunks this packet transports
74 |
# File 'lib/packetgen/header/sctp.rb', line 74 define_attr :chunks, ArrayOfChunk |
#dport ⇒ Integer
16-bit TCP destination port
62 |
# File 'lib/packetgen/header/sctp.rb', line 62 define_attr :dport, BinStruct::Int16 |
#sport ⇒ Integer
16-bit TCP source port
58 |
# File 'lib/packetgen/header/sctp.rb', line 58 define_attr :sport, BinStruct::Int16 |
#verification_tag ⇒ Integer
32-bit verification tag
66 |
# File 'lib/packetgen/header/sctp.rb', line 66 define_attr :verification_tag, BinStruct::Int32 |
Instance Method Details
#calc_checksum ⇒ Integer
Compute SCTP checksum and set #checksum attribute.
78 79 80 81 82 83 |
# File 'lib/packetgen/header/sctp.rb', line 78 def calc_checksum self.checksum = 0 crc32c = Digest::CRC32c.new crc32c << to_s self.checksum = crc32c.checksum end |
#calc_length ⇒ void
This method returns an undefined value.
Compute SCTP chunk lengths
87 88 89 |
# File 'lib/packetgen/header/sctp.rb', line 87 def calc_length self.chunks.each(&:calc_length) end |
#inspect ⇒ String
92 93 94 95 96 97 98 |
# File 'lib/packetgen/header/sctp.rb', line 92 def inspect super do |attr| next unless attr == :chunks chunks.map(&:inspect).join end end |