Documentation
¶
Overview ¶
Package nfdump provides an API for nfdump files
Package nfdump provides an API for nfdump files
Index ¶
- Constants
- type DataBlock
- type DataBlockHeader
- type EXXlateip
- type EXasRouting
- type EXbgpNextHop
- type EXcntFlow
- type EXflowMisc
- type EXgenericFlow
- type EXinPayload
- type EXip
- type EXipNextHop
- type EXipReceived
- type EXnselXlatePort
- type EXsamplerInfo
- type EXvLan
- type Exporter
- type ExporterInfoRecord
- type FlowRecordV3
- func (flowRecord *FlowRecordV3) AsRouting() *EXasRouting
- func (flowRecord *FlowRecordV3) BgpNextHop() *EXbgpNextHop
- func (flowRecord *FlowRecordV3) CntFlow() *EXcntFlow
- func (flowRecord *FlowRecordV3) FlowMisc() *EXflowMisc
- func (flowRecord *FlowRecordV3) GenericFlow() *EXgenericFlow
- func (flowRecord *FlowRecordV3) GetSamplerInfo(nfFile *NfFile)
- func (flowRecord *FlowRecordV3) IP() *EXip
- func (flowRecord *FlowRecordV3) IpNextHop() *EXipNextHop
- func (flowRecord *FlowRecordV3) IpReceived() *EXipReceived
- func (flowRecord *FlowRecordV3) IsIPv4() bool
- func (flowRecord *FlowRecordV3) IsIPv6() bool
- func (flowRecord *FlowRecordV3) Payload() EXinPayload
- func (flowRecord *FlowRecordV3) SamplerInfo(nfFile *NfFile) (int, int)
- func (flowRecord *FlowRecordV3) Sampling() *EXsamplerInfo
- func (flowRecord *FlowRecordV3) String() string
- func (flowRecord *FlowRecordV3) VLan() *EXvLan
- func (flowRecord *FlowRecordV3) XlateIP() *EXXlateip
- func (flowRecord *FlowRecordV3) XlatePort() *EXnselXlatePort
- type NfFile
- func (nfFile *NfFile) AllRecords() (chan *FlowRecordV3, error)
- func (nfFile *NfFile) Close() error
- func (nfFile *NfFile) GetExporterList() []Exporter
- func (nfFile *NfFile) Ident() string
- func (nfFile *NfFile) Open(fileName string) error
- func (nfFile *NfFile) ReadDataBlocks() (chan DataBlock, error)
- func (nfFile *NfFile) Stat() StatRecord
- func (nfFile *NfFile) String() string
- type NfFileHeader
- type NfFileHeaderV1
- type Sampler
- type SamplerRecord
- type StatRecord
Constants ¶
const ( NUM_FLAGS = 4 FLAG_NOT_COMPRESSED = 0x0 // records are not compressed FLAG_LZO_COMPRESSED = 0x1 // records are LZO compressed FLAG_ANONYMIZED = 0x2 // flow data are anonimized FLAG_UNUSED = 0x4 // unused FLAG_BZ2_COMPRESSED = 0x8 // records are BZ2 compressed FLAG_LZ4_COMPRESSED = 0x10 // records are LZ4 compressed COMPRESSION_MASK = 0x19 // all compression bits )
const ( EXnull = uint(0x0) EXgenericFlowID = uint16(0x1) EXipv4FlowID = uint16(0x2) EXipv6FlowID = uint16(0x3) EXflowMiscID = uint16(0x4) EXcntFlowID = uint16(0x5) EXvLanID = uint16(0x6) EXasRoutingID = uint16(0x7) EXbgpNextHopV4ID = uint16(0x8) EXbgpNextHopV6ID = uint16(0x9) EXipNextHopV4ID = uint16(0xa) EXipNextHopV6ID = uint16(0xb) EXipReceivedV4ID = uint16(0xc) EXipReceivedV6ID = uint16(0xd) EXsamplerInfoID = uint16(0x12) EXinPayloadID = uint16(0x1d) EXnselXlateIPv4ID = uint16(0x14) EXnselXlateIPv6ID = uint16(0x15) EXnselXlatePortID = uint16(0x16) )
const ( V3_FLAG_EVENT = uint(0x1) V3_FLAG_SAMPLED = uint(0x2) V3_FLAG_ANON = uint(0x4) )
const ( V3Record = uint16(0xb) ExporterInfoRecordType = uint16(0x7) ExporterStatRecordType = uint16(0x8) SamplerLegacyRecordType = uint16(0x9) SamplerRecordType = uint16(0xf) )
const BUFFSIZE = 5 * 1048576
const BZ2_COMPRESSED = 2
const LZ4_COMPRESSED = 3
const LZO_COMPRESSED = 1
const MAXEXTENSIONS = uint16(0x27)
const MaxExporters = 256
const NOT_COMPRESSED = 0
const TYPE_IDENT = 0x8001
const TYPE_STAT = 0x8002
const ZSTD_COMPRESSED = 4
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataBlock ¶
type DataBlock struct { Header DataBlockHeader Data []byte }
type DataBlockHeader ¶
type EXasRouting ¶
type EXbgpNextHop ¶ added in v0.0.3
type EXflowMisc ¶
type EXgenericFlow ¶
type EXinPayload ¶ added in v0.0.4
type EXinPayload []byte
type EXipNextHop ¶ added in v0.0.3
type EXipReceived ¶ added in v0.0.3
type EXnselXlatePort ¶ added in v0.0.4
type EXsamplerInfo ¶ added in v0.0.4
type Exporter ¶ added in v0.0.4
type Exporter struct { IP net.IP // IP address SysId uint16 // internal assigned ID Version uint16 // netflow version Id uint32 // exporter ID/Domain ID/Observation Domain ID assigned by the device Packets uint64 // number of packets sent by this exporter Flows uint64 // number of flow records sent by this exporter SequenceFailures uint32 // number of sequence failures SamplerList []Sampler // contains filtered or unexported fields }
type ExporterInfoRecord ¶ added in v0.0.4
type FlowRecordV3 ¶
type FlowRecordV3 struct {
// contains filtered or unexported fields
}
func NewRecord ¶
func NewRecord(record []byte) (*FlowRecordV3, error)
Extract next flow record from []byte stream
func (*FlowRecordV3) AsRouting ¶
func (flowRecord *FlowRecordV3) AsRouting() *EXasRouting
Return asRouting extension
func (*FlowRecordV3) BgpNextHop ¶ added in v0.0.3
func (flowRecord *FlowRecordV3) BgpNextHop() *EXbgpNextHop
Return bgp next hop IPv4 or IPv6
func (*FlowRecordV3) CntFlow ¶
func (flowRecord *FlowRecordV3) CntFlow() *EXcntFlow
Return out counter extension
func (*FlowRecordV3) FlowMisc ¶
func (flowRecord *FlowRecordV3) FlowMisc() *EXflowMisc
Return misc extension
func (*FlowRecordV3) GenericFlow ¶
func (flowRecord *FlowRecordV3) GenericFlow() *EXgenericFlow
Return generic extension
func (*FlowRecordV3) GetSamplerInfo ¶ added in v0.0.4
func (flowRecord *FlowRecordV3) GetSamplerInfo(nfFile *NfFile)
func (*FlowRecordV3) IP ¶
func (flowRecord *FlowRecordV3) IP() *EXip
Return IP extension IPv4 or IPv6
func (*FlowRecordV3) IpNextHop ¶ added in v0.0.3
func (flowRecord *FlowRecordV3) IpNextHop() *EXipNextHop
Return IP next hop IPv4 or IPv6
func (*FlowRecordV3) IpReceived ¶ added in v0.0.3
func (flowRecord *FlowRecordV3) IpReceived() *EXipReceived
Return IP received IPv4 or IPv6
func (*FlowRecordV3) IsIPv4 ¶ added in v0.0.3
func (flowRecord *FlowRecordV3) IsIPv4() bool
Return true, if record is a IPv4 flow
func (*FlowRecordV3) IsIPv6 ¶ added in v0.0.3
func (flowRecord *FlowRecordV3) IsIPv6() bool
Return true, if record is a IPv4 flow
func (*FlowRecordV3) Payload ¶ added in v0.0.4
func (flowRecord *FlowRecordV3) Payload() EXinPayload
Return payload
func (*FlowRecordV3) SamplerInfo ¶ added in v0.0.4
func (flowRecord *FlowRecordV3) SamplerInfo(nfFile *NfFile) (int, int)
get sampler info for flow record
func (*FlowRecordV3) Sampling ¶ added in v0.0.4
func (flowRecord *FlowRecordV3) Sampling() *EXsamplerInfo
Return bgp next hop IPv4 or IPv6
func (*FlowRecordV3) String ¶
func (flowRecord *FlowRecordV3) String() string
Return string for %v Printf()
func (*FlowRecordV3) XlateIP ¶ added in v0.0.4
func (flowRecord *FlowRecordV3) XlateIP() *EXXlateip
Return IP extension IPv4 or IPv6
func (*FlowRecordV3) XlatePort ¶ added in v0.0.4
func (flowRecord *FlowRecordV3) XlatePort() *EXnselXlatePort
Return asRouting extension
type NfFile ¶
type NfFile struct { Header NfFileHeader StatRecord StatRecord ExporterList []Exporter // contains filtered or unexported fields }
func (*NfFile) AllRecords ¶
func (nfFile *NfFile) AllRecords() (chan *FlowRecordV3, error)
AllRecord takes an NfFile object and returns a channel of FlowRecordV3 it reads and uncompresses the data blocks with ReadDataBlocks Iterating over the channel reads all flow records
func (*NfFile) GetExporterList ¶ added in v0.0.4
Get exporter list
func (*NfFile) ReadDataBlocks ¶
ReadDataBlocks iterates over the underlaying file and decompresses the data blocks A channel with all uncompressed data blocks is returned.
func (*NfFile) Stat ¶
func (nfFile *NfFile) Stat() StatRecord
Stat returns the stat record of the current NfFile object
type NfFileHeader ¶
type NfFileHeader struct { Magic uint16 // magic 0xA50C to recognize nfdump file type and endian type Version uint16 // version of binary file layout. Valid: version 2 NfVersion uint32 // version of nfdump created this file Created uint64 // file creat time Compression uint8 // type of compression // NOT_COMPRESSED 0 // LZO_COMPRESSED 1 // BZ2_COMPRESSED 2 // LZ4_COMPRESSED 3 // ZSTD_COMPRESSED 4 Encryption uint8 // type of encryption // NOT_ENCRYPTED 0 AppendixBlocks uint16 // number of blocks to read from appendix Unused uint32 // unused. must be 0 OffAppendix uint64 // // offset in file for appendix blocks with additional data BlockSize uint32 // max block size of a data block NumBlocks uint32 // number of data blocks in file }
type NfFileHeaderV1 ¶
type SamplerRecord ¶ added in v0.0.4
type StatRecord ¶
type StatRecord struct { // overall stat Numflows uint64 Numbytes uint64 Numpackets uint64 // flow stat NumflowsTcp uint64 NumflowsUdp uint64 NumflowsIcmp uint64 NumflowsOther uint64 // bytes stat NumbytesTcp uint64 NumbytesUdp uint64 NumbytesIcmp uint64 NumbytesOther uint64 // packet stat NumpacketsTcp uint64 NumpacketsUdp uint64 NumpacketsIcmp uint64 NumpacketsOther uint64 // time window FirstSeen uint64 LastSeen uint64 // other SequenceFailure uint64 }