Documentation
¶
Overview ¶
Package encoding provides encoding and decoding of IPv6 Addresses used by RFC 9433 (Segment Routing over IPv6 for the Mobile User Plane).
Index ¶
- type ArgsMobSession
- func (a *ArgsMobSession) Marshal() ([]byte, error)
- func (a *ArgsMobSession) MarshalLen() int
- func (a *ArgsMobSession) MarshalTo(b []byte) error
- func (a *ArgsMobSession) PDUSessionID() uint32
- func (a *ArgsMobSession) QFI() uint8
- func (a *ArgsMobSession) R() bool
- func (a *ArgsMobSession) U() bool
- func (a *ArgsMobSession) UnmarshalBinary(b []byte) error
- type MGTP4IPv6Dst
- func (m *MGTP4IPv6Dst) ArgsMobSession() *ArgsMobSession
- func (m *MGTP4IPv6Dst) IPv4() netip.Addr
- func (m *MGTP4IPv6Dst) Marshal() ([]byte, error)
- func (m *MGTP4IPv6Dst) MarshalLen() int
- func (m *MGTP4IPv6Dst) MarshalTo(b []byte) error
- func (m *MGTP4IPv6Dst) PDUSessionID() uint32
- func (m *MGTP4IPv6Dst) Prefix() netip.Prefix
- func (m *MGTP4IPv6Dst) QFI() uint8
- func (m *MGTP4IPv6Dst) R() bool
- func (m *MGTP4IPv6Dst) U() bool
- type MGTP4IPv6Src
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgsMobSession ¶
type ArgsMobSession struct {
// contains filtered or unexported fields
}
Args.Mob.Session as defined in RFC 9433, section 6.1:
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 2 3 4 5 6 7 8 9 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | QFI |R|U| PDU Session ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 8: Args.Mob.Session Format
func NewArgsMobSession ¶
func NewArgsMobSession(qfi uint8, r bool, u bool, pduSessionID uint32) *ArgsMobSession
NewArgsMobSession creates an ArgsMobSession.
func ParseArgsMobSession ¶
func ParseArgsMobSession(b []byte) (*ArgsMobSession, error)
ParseArgsMobSession parses given byte sequence as an ArgsMobSession.
func (*ArgsMobSession) Marshal ¶
func (a *ArgsMobSession) Marshal() ([]byte, error)
Marshal returns the byte sequence generated from ArgsMobSession.
func (*ArgsMobSession) MarshalLen ¶
func (a *ArgsMobSession) MarshalLen() int
MarshalLen returns the serial length of ArgsMobSession.
func (*ArgsMobSession) MarshalTo ¶
func (a *ArgsMobSession) MarshalTo(b []byte) error
MarshalTo puts the byte sequence in the byte array given as b.
func (*ArgsMobSession) PDUSessionID ¶
func (a *ArgsMobSession) PDUSessionID() uint32
PDUSessionID returns the PDU Session Identifier for this ArgsMobSession. The GTP-U equivalent is TEID.
func (*ArgsMobSession) QFI ¶
func (a *ArgsMobSession) QFI() uint8
QFI returns the Qos Flow Identifier for this ArgsMobSession.
func (*ArgsMobSession) R ¶
func (a *ArgsMobSession) R() bool
R returns the Reflective QoS Indication for this ArgsMobSession.
func (*ArgsMobSession) U ¶
func (a *ArgsMobSession) U() bool
U returns the U bit for this ArgsMobSession.
func (*ArgsMobSession) UnmarshalBinary ¶
func (a *ArgsMobSession) UnmarshalBinary(b []byte) error
UnmarshalBinary sets the values retrieved from byte sequence in an ArgsMobSession.
type MGTP4IPv6Dst ¶
type MGTP4IPv6Dst struct {
// contains filtered or unexported fields
}
RFC 9433, section 6.6 (End.M.GTP4.E): The End.M.GTP.E SID in S has the following format:
0 127
+-----------------------+-------+----------------+---------+
| SRGW-IPv6-LOC-FUNC |IPv4DA |Args.Mob.Session|0 Padded |
+-----------------------+-------+----------------+---------+
128-a-b-c a b c
Figure 9: End.M.GTP4.E SID Encoding
Example ¶
package main
import (
"net/netip"
"github.com/nextmn/rfc9433/encoding"
)
func main() {
dst := encoding.NewMGTP4IPv6Dst(netip.MustParsePrefix("3fff::/20"), netip.MustParseAddr("203.0.113.1").As4(), encoding.NewArgsMobSession(0, false, false, 1))
dst.Marshal()
}
func NewMGTP4IPv6Dst ¶
func NewMGTP4IPv6Dst(prefix netip.Prefix, ipv4 [4]byte, a *ArgsMobSession) *MGTP4IPv6Dst
NewMGTP4IPv6Dst creates a new MGTP4IPv6Dst.
func ParseMGTP4IPv6Dst ¶
func ParseMGTP4IPv6Dst(ipv6Addr [16]byte, prefixLength uint) (*MGTP4IPv6Dst, error)
ParseMGTP4IPv6Dst parses a given byte sequence into a MGTP4IPv6Dst according to the given prefixLength.
func (*MGTP4IPv6Dst) ArgsMobSession ¶
func (m *MGTP4IPv6Dst) ArgsMobSession() *ArgsMobSession
ArgsMobSession returns the ArgsMobSession encoded in the MGTP4IPv6Dst.
func (*MGTP4IPv6Dst) IPv4 ¶
func (m *MGTP4IPv6Dst) IPv4() netip.Addr
IPv4 returns the IPv4 Address encoded in the MGTP4IPv6Dst.
func (*MGTP4IPv6Dst) Marshal ¶
func (m *MGTP4IPv6Dst) Marshal() ([]byte, error)
Marshal returns the byte sequence generated from MGTP4IPv6Dst.
func (*MGTP4IPv6Dst) MarshalLen ¶
func (m *MGTP4IPv6Dst) MarshalLen() int
MarshalLen returns the serial length of MGTP4IPv6Dst.
func (*MGTP4IPv6Dst) MarshalTo ¶
func (m *MGTP4IPv6Dst) MarshalTo(b []byte) error
MarshalTo puts the byte sequence in the byte array given as b. warning: no caching is done, this result will be recomputed at each call
func (*MGTP4IPv6Dst) PDUSessionID ¶
func (m *MGTP4IPv6Dst) PDUSessionID() uint32
PDUSessionID returns the PDUSessionID for this MGTP4IPv6Dst's ArgsMobSession.
func (*MGTP4IPv6Dst) Prefix ¶
func (m *MGTP4IPv6Dst) Prefix() netip.Prefix
Prefix returns the IPv6 Prefix for this MGTP4IPv6Dst.
func (*MGTP4IPv6Dst) QFI ¶
func (m *MGTP4IPv6Dst) QFI() uint8
QFI returns the QFI encoded in the MGTP4IPv6Dst's ArgsMobSession.
func (*MGTP4IPv6Dst) R ¶
func (m *MGTP4IPv6Dst) R() bool
R returns the R bit encoded in the MGTP4IPv6Dst's ArgsMobSession.
func (*MGTP4IPv6Dst) U ¶
func (m *MGTP4IPv6Dst) U() bool
U returns the U bit encoded in the MGTP4IPv6Dst's ArgsMobSession.
type MGTP4IPv6Src ¶
type MGTP4IPv6Src struct {
// contains filtered or unexported fields
}
RFC 9433, section 6.6 (End.M.GTP4.E): The IPv6 Source Address has the following format:
0 127
+----------------------+--------+--------------------------+
| Source UPF Prefix |IPv4 SA | any bit pattern(ignored) |
+----------------------+--------+--------------------------+
128-a-b a b
Figure 10: IPv6 SA Encoding for End.M.GTP4.E
With NextMN implementation, we choose to deviate from the RFC because RFC's proposal doesn't allow to retrieve the IPv4 SA without knowing the prefix length, which may be different for 2 packets issued from 2 different headends.
To allow the endpoint to be stateless, we need to know the prefix. We propose to encode it on the 7 last bits of the IPv6 SA.
The other option would have been to directly put the IPv4 SA at the end of the IPv6 SA (bytes 12 to 15), but this would imply matching on /128 if the IPv4 SA is used for source routing purpose, and thus breaking compatibility with future new patterns.
We also introduce a new field that will carry the source UDP port to be used in the newly created GTP4 packet.
This field is intended to help load balancing, as specified in TS 129.281, section 4.4.2.0:
"For the GTP-U messages described below (other than the Echo Response message, see clause 4.4.2.2), the UDP Source Port or the Flow Label field (see IETF RFC 6437) should be set dynamically by the sending GTP-U entity to help balancing the load in the transport network".
Since the headend has a better view than End.M.GTP4.E on the origin of the flows, and can be helped by the control plane, it makes sense to generate the source port number on headend side, and to carry it during transit through SR domain.
Note: even with this proposal, the remaining space (73 bits) is bigger than what remains for LOC+FUNC in the SID (56 bits).
0 127
+----------------------+-----------+-----------------+--------------------------+---------------+
| Source UPF Prefix | IPv4 SA | UDP Source Port | any bit pattern(ignored) | Prefix length |
+----------------------+-----------+-----------------+--------------------------+---------------+
128-a-(b1+b2+b3) a (32 bits) b1 (16 bits) b2 b3 (7 bits)
IPv6 SA Encoding for End.M.GTP4.E in NextMN
Example ¶
package main
import (
"net/netip"
"github.com/nextmn/rfc9433/encoding"
)
func main() {
src := encoding.NewMGTP4IPv6Src(netip.MustParsePrefix("3fff::/20"), netip.MustParseAddr("203.0.113.1").As4(), 1337)
src.Marshal()
}
func NewMGTP4IPv6Src ¶
func NewMGTP4IPv6Src(prefix netip.Prefix, ipv4 [4]byte, udpPortNumber uint16) *MGTP4IPv6Src
NewMGTP4IPv6Src creates a new MGTP4IPv6Src
func ParseMGTP4IPv6Src ¶
func ParseMGTP4IPv6Src(addr [16]byte, prefixLen uint) (*MGTP4IPv6Src, error)
ParseMGTP4IPv6SrcNextMN parses a given IPv6 source address without any specific bit pattern into a MGTP4IPv6Src
func ParseMGTP4IPv6SrcNextMN ¶
func ParseMGTP4IPv6SrcNextMN(addr [16]byte) (*MGTP4IPv6Src, error)
ParseMGTP4IPv6SrcNextMN parses a given IPv6 source address with NextMN bit pattern into a MGTP4IPv6Src
func (*MGTP4IPv6Src) IPv4 ¶
func (m *MGTP4IPv6Src) IPv4() netip.Addr
IPv4 returns the IPv4 Address encoded in the MGTP4IPv6Src.
func (*MGTP4IPv6Src) Marshal ¶
func (m *MGTP4IPv6Src) Marshal() ([]byte, error)
Marshal returns the byte sequence generated from MGTP4IPv6Src.
func (*MGTP4IPv6Src) MarshalLen ¶
func (m *MGTP4IPv6Src) MarshalLen() int
MarshalLen returns the serial length of MGTP4IPv6Src.
func (*MGTP4IPv6Src) MarshalTo ¶
func (m *MGTP4IPv6Src) MarshalTo(b []byte) error
MarshalTo puts the byte sequence in the byte array given as b. warning: no caching is done, this result will be recomputed at each call
func (*MGTP4IPv6Src) UDPPortNumber ¶
func (m *MGTP4IPv6Src) UDPPortNumber() uint16
UDPPortNumber returns the UDP Port Number encoded in the MGTP4IPv6Src (0 if not set).