Class: PacketGen::Header::SCTP

Inherits:
Base show all
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                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Author:

  • Sylvain Daubert

Since:

  • 3.4.0

Defined Under Namespace

Modules: ErrorMixin, Padded32, ParameterMixin Classes: AbortChunk, ArrayOfChunk, ArrayOfError, ArrayOfParameter, BaseChunk, CookieAckChunk, CookieEchoChunk, CookiePreservativeParameter, CookieReceivedWhileShuttingDownError, DataChunk, ECNParameter, Error, ErrorChunk, HearbeatInfoParameter, HeartbeatAckChunk, HeartbeatChunk, HostnameParameter, IPv4Parameter, IPv6Parameter, InitAckChunk, InitChunk, InvalidMandatoryParameterError, InvalidStreamIdError, MissingMandatoryParameterError, NoUserDataError, 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

Since:

  • 3.4.0

132
UDP_PORT =

Port number for SCTP over TCP (RFC 6951)

Since:

  • 3.4.0

9899

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Methods inherited from Types::Fields

#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #initialize, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field

Constructor Details

This class inherits a constructor from PacketGen::Header::Base

Instance Attribute Details

#checksumInteger

32-bit TCP checksum

Returns:

  • (Integer)


61
# File 'lib/packetgen/header/sctp.rb', line 61

define_field :checksum, Types::Int32le

#chunksArrayOfChunk

List of chunks this packet transports

Returns:



65
# File 'lib/packetgen/header/sctp.rb', line 65

define_field :chunks, ArrayOfChunk

#dportInteger

16-bit TCP destination port

Returns:

  • (Integer)


53
# File 'lib/packetgen/header/sctp.rb', line 53

define_field :dport, Types::Int16

#sportInteger

16-bit TCP source port

Returns:

  • (Integer)


49
# File 'lib/packetgen/header/sctp.rb', line 49

define_field :sport, Types::Int16

#verification_tagInteger

32-bit verification tag

Returns:

  • (Integer)


57
# File 'lib/packetgen/header/sctp.rb', line 57

define_field :verification_tag, Types::Int32

Instance Method Details

#calc_checksumObject

Compute SCTP checksum

Since:

  • 3.4.0



68
69
70
71
72
73
# File 'lib/packetgen/header/sctp.rb', line 68

def calc_checksum
  self.checksum = 0
  crc32c = Digest::CRC32c.new
  crc32c << to_s
  self.checksum = crc32c.checksum
end

#calc_lengthObject

Compute SCTP chunks length

Since:

  • 3.4.0



76
77
78
# File 'lib/packetgen/header/sctp.rb', line 76

def calc_length
  self.chunks.each(&:calc_length)
end

#inspectString

Returns:

  • (String)

Since:

  • 3.4.0



81
82
83
84
85
86
87
# File 'lib/packetgen/header/sctp.rb', line 81

def inspect
  super do |attr|
    next unless attr == :chunks

    chunks.map(&:inspect).join
  end
end