Class: PacketGen::Header::SCTP

Inherits:
Base
  • Object
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                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

A SCTP header is composed of:

Author:

  • Sylvain Daubert

  • LemonTree55

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin

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

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin

132
UDP_PORT =

Port number for SCTP over TCP (RFC 6951)

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin

9899
HearbeatInfo =

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin

BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
length_class: BinStruct::Int16,
attr_in_length: 'TLV')

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, #to_s

Constructor Details

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

Instance Attribute Details

#checksumInteger

32-bit TCP checksum. This is a CRC32C checkum, computed on SCTP header and all its chunks.

Returns:

  • (Integer)


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

define_attr :checksum, BinStruct::Int32le

#chunksArrayOfChunk

List of chunks this packet transports

Returns:



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

define_attr :chunks, ArrayOfChunk

#dportInteger

16-bit TCP destination port

Returns:

  • (Integer)


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

define_attr :dport, BinStruct::Int16

#sportInteger

16-bit TCP source port

Returns:

  • (Integer)


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

define_attr :sport, BinStruct::Int16

#verification_tagInteger

32-bit verification tag

Returns:

  • (Integer)


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

define_attr :verification_tag, BinStruct::Int32

Instance Method Details

#calc_checksumInteger

Compute SCTP checksum and set #checksum attribute.

Returns:

  • (Integer)

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin



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_lengthvoid

This method returns an undefined value.

Compute SCTP chunk lengths

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin



87
88
89
# File 'lib/packetgen/header/sctp.rb', line 87

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

#inspectString

Returns:

  • (String)

Since:

  • 3.4.0

  • 4.1.0 Remove ErrorMixin and ParameterMixin



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