vrt

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 4 Imported by: 2

README

vrt

Build Status GoDoc GoReport

Install

go get github.com/littleairmada/vrt

Note: VRT uses Go Modules to manage dependencies.

What is VRT?

VRT is a basic VITA 49.0 Radio Transport (VRT) packet parsing library for Go applications.

It uses gopacket and can handle the basics of parsing VRT packets & serializing VRT structs into packets. It was originally developed to support a project using FlexRadio Amateur Radio transceivers.

It is not feature complete and currently supports:

  • decoding a VRT packet from a series of bytes
  • serializing a VRT packet struct into a byte array for processing by gopacket or another packet injection library

How to get the library

The library is split into several parts:

  • vrt: basic implementation of VRT packet parsing/serialization based on the VITA 49.0 specification
  • examples: example programs that use the vrt library to decode or encode VRT packets

You will probably only need vrt explicitly. The rest is pulled in automatically if necessary.

References

License

The project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LayerTypeVRT = gopacket.RegisterLayerType(4900, gopacket.LayerTypeMetadata{Name: "VRT", Decoder: gopacket.DecodeFunc(decodeVRT)})

LayerTypeVRT handles the VRT packet processing for gopacket

Functions

func ValidateVrtPacketSize

func ValidateVrtPacketSize(header Header, size uint32) (outputHeaderSize uint16, ouputMinimumWords uint32, err error)

ValidateVrtPacketSize calculates the minimum size of the VRT packet based on the VRT header and compares to the size of the VRT packet. VRT packets below the minimum size through an error. header.PacketSize is the number of 32 bit words per packet and should always equal size/4.

Types

type ClassID

type ClassID struct {
	OUI uint32 // 0xFC
	// PadBitCount	// 0x03
	PacketClassCode      uint16
	InformationClassCode uint16
}

ClassID makes it possible for a VRT Packet Stream receiver to determine the identity of both the Information Class used for the application and the Packet Class from which each received packet was made.

type Header struct {
	Type        VitaPacketType // F0
	C           bool           // 08
	T           bool           // 04
	TSI         TSI            // C0
	TSF         TSF            // 30
	PacketCount PacketCount    // 0F
	PacketSize  uint16
}

Header is the representation of a VRT packet's header.

type PacketCount

type PacketCount uint8

PacketCount contains a modulo-16 count of IF Data packets for an IF Data Packet Stream

type TSF

type TSF uint8

TSF is the Timestamp Fractional type

const (
	TSFNone        TSF = iota // 0
	TSFSampleCount            // 1
	TSFRealTime               // 2
	TSFFreeRunning            // 3
)

constants representing different Timestamp Fractional types

type TSI

type TSI uint8

TSI is the Timestamp Integer type

const (
	TSINone  TSI = iota // 0
	TSIUTC              // 1
	TSIGPS              // 2
	TSIOther            // 3
)

constants representing different Timestamp Integer types

type Trailer

type Trailer struct {
	CalibratedTimeEnable    bool
	ValidDataEnable         bool
	ReferenceLockEnable     bool
	AGCMGCEnable            bool
	DetectedSignalEnable    bool
	SpectralInversionEnable bool
	OverrangeEnable         bool
	SampleLossEnable        bool

	CalibratedTimeIndicator    bool
	ValidDataIndicator         bool
	ReferenceLockIndicator     bool
	AGCMGCIndicator            bool
	DetectedSignalIndicator    bool
	SpectralInversionIndicator bool
	OverrangeIndicator         bool
	SampleLossIndicator        bool

	AssociatedContextPacketCountEnable bool
	AssociatedContextPacketCount       byte // valid 0 - 127
}

Trailer is the representation of a VRT packet's trailer. This is optional and only appears when the Header.T is set to `true`. Will be fully implemented in a future version of this module.

type VRT

type VRT struct {
	layers.BaseLayer
	Header        Header
	StreamID      uint32
	ClassID       ClassID
	TimestampInt  uint32
	TimestampFrac uint64
	Payload       []byte
}

VRT (VITA Radio Transport) is a standard that defines a transport layer protocol designed to promote interoperability between RF (radio frequency) receivers and signal processing equipment across a wide range of applications.

func (*VRT) CanDecode

func (v *VRT) CanDecode() gopacket.LayerClass

CanDecode returns a set of layers that VRT objects can decode. As VRT objects can only decide the VRT layer, we can return just that layer. Apparently a single layer type implements LayerClass.

func (*VRT) DecodeFromBytes

func (v *VRT) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error

DecodeFromBytes analyses a byte slice and attempts to decode it as a VRT record of a UDP packet.

Upon succeeds, it loads the VRT object with information about the packet and returns nil. Upon failure, it returns an error (non nil).

func (VRT) LayerContents

func (v VRT) LayerContents() (data []byte)

LayerContents returns the VRT layer's contents as a byte array

func (*VRT) LayerPayload

func (v *VRT) LayerPayload() []byte

LayerPayload returns the VRT object's Payload VRT packets carry a data payload so the Payload byte slice is retured.

func (VRT) LayerType

func (v VRT) LayerType() gopacket.LayerType

LayerType returns gopacket.LayerTypeVRT

func (*VRT) NextLayerType

func (v *VRT) NextLayerType() gopacket.LayerType

NextLayerType specifies the next layer that GoPacket should attempt to analyse after this (VRT) layer. As VRT packets contain payload bytes, there is an additional layer to analyse.

func (*VRT) SerializeTo

func (v *VRT) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error

SerializeTo writes the serialized form of this layer into the SerializationBuffer, implementing gopacket.SerializableLayer. See the docs for gopacket.SerializableLayer for more info.

type VitaPacketType

type VitaPacketType uint8

VitaPacketType specifies the VRT Packet Type

const (
	IFData            VitaPacketType = iota // 0
	IFDataWithStream                        // 1
	ExtData                                 // 2
	ExtDataWithStream                       // 3
	IFContext                               // 4
	ExtContext                              // 5
)

constants representing different VRT packet types

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL