SCTP¶
- class os_ken.lib.packet.sctp.cause_cookie_while_shutdown(length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Cookie Received While Shutting Down (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_invalid_param(length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Invalid Mandatory Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_invalid_stream_id(value=0, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Invalid Stream Identifier (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
stream id.
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_missing_param(types=None, num=0, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Missing Mandatory Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
types
a list of missing params.
num
Number of missing params. (0 means automatically-calculate when encoding)
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_no_userdata(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for No User Data (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
the TSN of the DATA chunk received with no user data field.
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_out_of_resource(length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Out of Resource (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_protocol_violation(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Protocol Violation (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
Additional Information.
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_restart_with_new_addr(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Restart of an Association with New Addresses (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
New Address TLVs.
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_stale_cookie(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Stale Cookie Error (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
Measure of Staleness.
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_unrecognized_chunk(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Unrecognized Chunk Type (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
Unrecognized Chunk.
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_unrecognized_param(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Unrecognized Parameters (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
Unrecognized Parameter.
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_unresolvable_addr(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Unresolvable Address (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
Unresolvable Address. one of follows:
os_ken.lib.packet.sctp.param_host_addr,
os_ken.lib.packet.sctp.param_ipv4, or
os_ken.lib.packet.sctp.param_ipv6.
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.cause_user_initiated_abort(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for User-Initiated Abort (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_abort
os_ken.lib.packet.sctp.chunk_error
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
Upper Layer Abort Reason.
length
length of this cause containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.chunk_abort(tflag=0, length=0, causes=None)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Abort Association (ABORT) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
tflag
'0' means the Verification tag is normal. '1' means the Verification tag is copy of the sender.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
causes
a list of derived classes of os_ken.lib.packet.sctp.causes.
- class os_ken.lib.packet.sctp.chunk_cookie_ack(flags=0, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Cookie Acknowledgement (COOKIE ACK) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.chunk_cookie_echo(flags=0, length=0, cookie=None)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Cookie Echo (COOKIE ECHO) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
cookie
cookie data.
- class os_ken.lib.packet.sctp.chunk_cwr(flags=0, length=0, low_tsn=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for CWR chunk (RFC 4960 Appendix A.).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
low_tsn
the lowest TSN.
- class os_ken.lib.packet.sctp.chunk_data(unordered=0, begin=0, end=0, length=0, tsn=0, sid=0, seq=0, payload_id=0, payload_data=None)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Payload Data (DATA) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
unordered
if set to '1', the receiver ignores the sequence number.
begin
if set to '1', this chunk is the first fragment.
end
if set to '1', this chunk is the last fragment.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
tsn
Transmission Sequence Number.
sid
stream id.
seq
the sequence number.
payload_id
application specified protocol id. '0' means that no application id is identified.
payload_data
user data.
- class os_ken.lib.packet.sctp.chunk_ecn_echo(flags=0, length=0, low_tsn=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for ECN-Echo chunk (RFC 4960 Appendix A.).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
low_tsn
the lowest TSN.
- class os_ken.lib.packet.sctp.chunk_error(flags=0, length=0, causes=None)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Operation Error (ERROR) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
causes
a list of derived classes of os_ken.lib.packet.sctp.causes.
- class os_ken.lib.packet.sctp.chunk_heartbeat(flags=0, length=0, info=None)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Heartbeat Request (HEARTBEAT) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
info
os_ken.lib.packet.sctp.param_heartbeat.
- class os_ken.lib.packet.sctp.chunk_heartbeat_ack(flags=0, length=0, info=None)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Heartbeat Acknowledgement (HEARTBEAT ACK) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
info
os_ken.lib.packet.sctp.param_heartbeat.
- class os_ken.lib.packet.sctp.chunk_init(flags=0, length=0, init_tag=0, a_rwnd=0, os=0, mis=0, i_tsn=0, params=None)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Initiation (INIT) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
init_tag
the tag that be used as Verification Tag.
a_rwnd
Advertised Receiver Window Credit.
os
number of outbound streams.
mis
number of inbound streams.
i_tsn
Transmission Sequence Number that the sender will use.
params
Optional/Variable-Length Parameters.
a list of derived classes of os_ken.lib.packet.sctp.param.
- class os_ken.lib.packet.sctp.chunk_init_ack(flags=0, length=0, init_tag=0, a_rwnd=0, os=0, mis=0, i_tsn=0, params=None)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Initiation Acknowledgement (INIT ACK) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
init_tag
the tag that be used as Verification Tag.
a_rwnd
Advertised Receiver Window Credit.
os
number of outbound streams.
mis
number of inbound streams.
i_tsn
Transmission Sequence Number that the sender will use.
params
Optional/Variable-Length Parameters.
a list of derived classes of os_ken.lib.packet.sctp.param.
- class os_ken.lib.packet.sctp.chunk_sack(flags=0, length=0, tsn_ack=0, a_rwnd=0, gapack_num=0, duptsn_num=0, gapacks=None, duptsns=None)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Selective Acknowledgement (SACK) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
tsn_ack
TSN of the last DATA chunk received in sequence before a gap.
a_rwnd
Advertised Receiver Window Credit.
gapack_num
number of Gap Ack blocks.
duptsn_num
number of duplicate TSNs.
gapacks
a list of Gap Ack blocks. one block is made of a list with the start offset and the end offset from tsn_ack. e.g.) gapacks = [[2, 3], [10, 12], [19, 21]]
duptsns
a list of duplicate TSN.
- class os_ken.lib.packet.sctp.chunk_shutdown(flags=0, length=0, tsn_ack=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Shutdown Association (SHUTDOWN) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
tsn_ack
TSN of the last DATA chunk received in sequence before a gap.
- class os_ken.lib.packet.sctp.chunk_shutdown_ack(flags=0, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Shutdown Acknowledgement (SHUTDOWN ACK) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
flags
set to '0'. this field will be ignored.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.chunk_shutdown_complete(tflag=0, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Shutdown Complete (SHUTDOWN COMPLETE) chunk (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.sctp
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
tflag
'0' means the Verification tag is normal. '1' means the Verification tag is copy of the sender.
length
length of this chunk containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.param_cookie_preserve(value=0, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Cookie Preservative Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_init
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
Suggested Cookie Life-Span Increment (msec).
length
length of this param containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.param_ecn(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for ECN Parameter (RFC 4960 Appendix A.).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_init
os_ken.lib.packet.sctp.chunk_init_ack
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
set to None.
length
length of this param containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.param_heartbeat(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Heartbeat Info Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_heartbeat
os_ken.lib.packet.sctp.chunk_heartbeat_ack
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
the sender-specific heartbeat information.
length
length of this param containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.param_host_addr(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Host Name Address Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_init
os_ken.lib.packet.sctp.chunk_init_ack
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
a host name that ends with null terminator.
length
length of this param containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.param_ipv4(value='127.0.0.1', length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for IPv4 Address Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_init
os_ken.lib.packet.sctp.chunk_init_ack
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
IPv4 address of the sending endpoint.
length
length of this param containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.param_ipv6(value='::1', length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for IPv6 Address Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_init
os_ken.lib.packet.sctp.chunk_init_ack
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
IPv6 address of the sending endpoint.
length
length of this param containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.param_state_cookie(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for State Cookie Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_init_ack
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
the state cookie. see Section 5.1.3 in RFC 4960.
length
length of this param containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.param_supported_addr(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Supported Address Types Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_init
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
a list of parameter types. odd cases pad with 0x0000.
length
length of this param containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.param_unrecognized_param(value=None, length=0)¶
Stream Control Transmission Protocol (SCTP) sub encoder/decoder class for Unrecognized Parameter (RFC 4960).
This class is used with the following.
os_ken.lib.packet.sctp.chunk_init_ack
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
value
the unrecognized parameter in the INIT chunk.
length
length of this param containing this header. (0 means automatically-calculate when encoding)
- class os_ken.lib.packet.sctp.sctp(src_port=1, dst_port=1, vtag=0, csum=0, chunks=None)¶
Stream Control Transmission Protocol (SCTP) header encoder/decoder class (RFC 4960).
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
src_port
Source Port
dst_port
Destination Port
vtag
Verification Tag
csum
Checksum (0 means automatically-calculate when encoding)
chunks
a list of derived classes of os_ken.lib.packet.sctp.chunk.
- classmethod parser(buf)¶
Decode a protocol header.
This method is used only when decoding a packet.
Decode a protocol header at offset 0 in bytearray buf. Returns the following three objects.
An object to describe the decoded header.
A packet_base.PacketBase subclass appropriate for the rest of the packet. None when the rest of the packet should be considered as raw payload.
The rest of packet.
- serialize(payload, prev)¶
Encode a protocol header.
This method is used only when encoding a packet.
Encode a protocol header. Returns a bytearray which contains the header.
payload is the rest of the packet which will immediately follow this header.
prev is a packet_base.PacketBase subclass for the outer protocol header. prev is None if the current header is the outer-most. For example, prev is ipv4 or ipv6 for tcp.serialize.