From 89e524660ddb6ea0503dcaf7b66589f83f10cb5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A4gele?= Date: Fri, 12 Apr 2019 10:59:42 +0200 Subject: [PATCH 1/6] add new TimeFlow fields to protobuf and compile --- pb/flow.pb.go | 146 +++++++++++++++++++++++++++++--------------------- pb/flow.proto | 10 ++-- 2 files changed, 93 insertions(+), 63 deletions(-) diff --git a/pb/flow.pb.go b/pb/flow.pb.go index 7ea551b..cb98374 100644 --- a/pb/flow.pb.go +++ b/pb/flow.pb.go @@ -1,11 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: flow.proto +// source: pb/flow.proto package flowprotob -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -16,7 +18,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type FlowMessage_FlowType int32 @@ -33,6 +35,7 @@ var FlowMessage_FlowType_name = map[int32]string{ 10: "IPFIX", 5: "SFLOW", } + var FlowMessage_FlowType_value = map[string]int32{ "FLOWUNKNOWN": 0, "NFV9": 9, @@ -43,8 +46,9 @@ var FlowMessage_FlowType_value = map[string]int32{ func (x FlowMessage_FlowType) String() string { return proto.EnumName(FlowMessage_FlowType_name, int32(x)) } + func (FlowMessage_FlowType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_flow_afe3427e2abb0c00, []int{0, 0} + return fileDescriptor_0beab9b6746e934c, []int{0, 0} } // To be deprecated @@ -61,6 +65,7 @@ var FlowMessage_IPType_name = map[int32]string{ 4: "IPv4", 6: "IPv6", } + var FlowMessage_IPType_value = map[string]int32{ "IPUNKNOWN": 0, "IPv4": 4, @@ -70,8 +75,9 @@ var FlowMessage_IPType_value = map[string]int32{ func (x FlowMessage_IPType) String() string { return proto.EnumName(FlowMessage_IPType_name, int32(x)) } + func (FlowMessage_IPType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_flow_afe3427e2abb0c00, []int{0, 1} + return fileDescriptor_0beab9b6746e934c, []int{0, 1} } type FlowMessage struct { @@ -79,7 +85,7 @@ type FlowMessage struct { TimeRecvd uint64 `protobuf:"varint,2,opt,name=TimeRecvd,proto3" json:"TimeRecvd,omitempty"` SamplingRate uint64 `protobuf:"varint,3,opt,name=SamplingRate,proto3" json:"SamplingRate,omitempty"` SequenceNum uint32 `protobuf:"varint,4,opt,name=SequenceNum,proto3" json:"SequenceNum,omitempty"` - // Found inside packet + // Found inside packet (To be deprecated in favor of TimeFlowEnd) TimeFlow uint64 `protobuf:"varint,5,opt,name=TimeFlow,proto3" json:"TimeFlow,omitempty"` // Source/destination addresses SrcIP []byte `protobuf:"bytes,6,opt,name=SrcIP,proto3" json:"SrcIP,omitempty"` @@ -124,9 +130,12 @@ type FlowMessage struct { SrcVlan uint32 `protobuf:"varint,33,opt,name=SrcVlan,proto3" json:"SrcVlan,omitempty"` DstVlan uint32 `protobuf:"varint,34,opt,name=DstVlan,proto3" json:"DstVlan,omitempty"` // Fragments (IPv4/IPv6) - FragmentId uint32 `protobuf:"varint,35,opt,name=FragmentId,proto3" json:"FragmentId,omitempty"` - FragmentOffset uint32 `protobuf:"varint,36,opt,name=FragmentOffset,proto3" json:"FragmentOffset,omitempty"` - IPv6FlowLabel uint32 `protobuf:"varint,37,opt,name=IPv6FlowLabel,proto3" json:"IPv6FlowLabel,omitempty"` + FragmentId uint32 `protobuf:"varint,35,opt,name=FragmentId,proto3" json:"FragmentId,omitempty"` + FragmentOffset uint32 `protobuf:"varint,36,opt,name=FragmentOffset,proto3" json:"FragmentOffset,omitempty"` + IPv6FlowLabel uint32 `protobuf:"varint,37,opt,name=IPv6FlowLabel,proto3" json:"IPv6FlowLabel,omitempty"` + // time information, found inside packets + TimeFlowStart uint64 `protobuf:"varint,40,opt,name=TimeFlowStart,proto3" json:"TimeFlowStart,omitempty"` + TimeFlowEnd uint64 `protobuf:"varint,41,opt,name=TimeFlowEnd,proto3" json:"TimeFlowEnd,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -136,16 +145,17 @@ func (m *FlowMessage) Reset() { *m = FlowMessage{} } func (m *FlowMessage) String() string { return proto.CompactTextString(m) } func (*FlowMessage) ProtoMessage() {} func (*FlowMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_flow_afe3427e2abb0c00, []int{0} + return fileDescriptor_0beab9b6746e934c, []int{0} } + func (m *FlowMessage) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FlowMessage.Unmarshal(m, b) } func (m *FlowMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_FlowMessage.Marshal(b, m, deterministic) } -func (dst *FlowMessage) XXX_Merge(src proto.Message) { - xxx_messageInfo_FlowMessage.Merge(dst, src) +func (m *FlowMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_FlowMessage.Merge(m, src) } func (m *FlowMessage) XXX_Size() int { return xxx_messageInfo_FlowMessage.Size(m) @@ -415,55 +425,71 @@ func (m *FlowMessage) GetIPv6FlowLabel() uint32 { return 0 } +func (m *FlowMessage) GetTimeFlowStart() uint64 { + if m != nil { + return m.TimeFlowStart + } + return 0 +} + +func (m *FlowMessage) GetTimeFlowEnd() uint64 { + if m != nil { + return m.TimeFlowEnd + } + return 0 +} + func init() { - proto.RegisterType((*FlowMessage)(nil), "flowprotob.FlowMessage") proto.RegisterEnum("flowprotob.FlowMessage_FlowType", FlowMessage_FlowType_name, FlowMessage_FlowType_value) proto.RegisterEnum("flowprotob.FlowMessage_IPType", FlowMessage_IPType_name, FlowMessage_IPType_value) + proto.RegisterType((*FlowMessage)(nil), "flowprotob.FlowMessage") } -func init() { proto.RegisterFile("flow.proto", fileDescriptor_flow_afe3427e2abb0c00) } - -var fileDescriptor_flow_afe3427e2abb0c00 = []byte{ - // 645 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xe1, 0x6f, 0xd2, 0x50, - 0x10, 0xc0, 0x45, 0x19, 0x83, 0xc7, 0xd8, 0xea, 0x73, 0xce, 0x73, 0x4e, 0xac, 0x38, 0x0d, 0x71, - 0x09, 0x1f, 0x74, 0x59, 0x62, 0xf4, 0x0b, 0xdb, 0x6c, 0x6c, 0x64, 0x5d, 0xd3, 0xe2, 0xe6, 0xd7, - 0xd2, 0xbe, 0x36, 0xc4, 0xd2, 0x62, 0xfb, 0x60, 0xee, 0x8f, 0xf1, 0x7f, 0x35, 0x77, 0xaf, 0x2d, - 0x4c, 0xe3, 0xb7, 0xf7, 0xfb, 0xdd, 0xf5, 0x5e, 0xef, 0xca, 0xc1, 0x58, 0x18, 0xa7, 0x37, 0x83, - 0x79, 0x96, 0xca, 0x94, 0xd3, 0x99, 0x8e, 0x93, 0xde, 0xef, 0x16, 0x6b, 0x1b, 0x71, 0x7a, 0x73, - 0x21, 0xf2, 0xdc, 0x8b, 0x04, 0x3f, 0x66, 0xf5, 0xf1, 0xed, 0x5c, 0x40, 0x4d, 0xaf, 0xf5, 0xb7, - 0xdf, 0xe9, 0x83, 0x55, 0xea, 0x60, 0x2d, 0x8d, 0xce, 0x98, 0xe7, 0x50, 0x36, 0x3f, 0x60, 0xad, - 0xf1, 0x74, 0x26, 0x1c, 0xe1, 0x2f, 0x03, 0xb8, 0xaf, 0xd7, 0xfa, 0x75, 0x67, 0x25, 0x78, 0x8f, - 0x6d, 0xb9, 0xde, 0x6c, 0x1e, 0x4f, 0x93, 0xc8, 0xf1, 0xa4, 0x80, 0x07, 0x94, 0x70, 0xc7, 0x71, - 0x9d, 0xb5, 0x5d, 0xf1, 0x73, 0x21, 0x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d, 0xb9, 0x99, 0x6f, - 0xa7, 0x99, 0x84, 0xc7, 0xe4, 0x4b, 0xc4, 0xc8, 0x79, 0x2e, 0x29, 0xb2, 0xa7, 0x22, 0x05, 0x62, - 0x25, 0xd3, 0x1e, 0xa7, 0x39, 0x3c, 0x51, 0x95, 0x08, 0xf8, 0x5b, 0xa6, 0x19, 0x69, 0x76, 0xe3, - 0x65, 0xc1, 0x34, 0x89, 0x5c, 0xe9, 0xc9, 0x45, 0x0e, 0x40, 0x09, 0xff, 0xf8, 0xa2, 0xc2, 0x78, - 0x04, 0x4f, 0xab, 0x0a, 0xe3, 0x11, 0xfd, 0x6e, 0xce, 0x6c, 0x23, 0xf6, 0xa2, 0x1c, 0xf6, 0x29, - 0x50, 0x71, 0x31, 0x99, 0x0b, 0xcf, 0x87, 0x67, 0xf4, 0xd9, 0x0a, 0x2a, 0x26, 0x83, 0xfe, 0x40, - 0x79, 0x45, 0xe8, 0xaf, 0x62, 0x2f, 0x31, 0x03, 0x78, 0xae, 0x26, 0xa6, 0x08, 0x6f, 0xfe, 0x2c, - 0x71, 0x6d, 0xba, 0xea, 0x66, 0x02, 0xbc, 0xd9, 0xf4, 0x67, 0x73, 0xda, 0xa7, 0x17, 0xea, 0xe6, - 0x92, 0xcb, 0xd8, 0x59, 0x1a, 0x08, 0xd0, 0x57, 0x31, 0xe4, 0x62, 0x7a, 0x58, 0x1a, 0x5e, 0x56, - 0xd3, 0x43, 0x2c, 0xa6, 0x47, 0x91, 0x5e, 0x35, 0x3d, 0x8a, 0x74, 0x19, 0x33, 0x32, 0x2f, 0x9a, - 0x89, 0x44, 0x9a, 0x01, 0xbc, 0xa2, 0xe0, 0x9a, 0xe1, 0x6f, 0xd8, 0x76, 0x49, 0x97, 0x61, 0x98, - 0x0b, 0x09, 0x87, 0x94, 0xf3, 0x97, 0xe5, 0x87, 0xac, 0x63, 0xda, 0xcb, 0x13, 0x5c, 0x82, 0x91, - 0x37, 0x11, 0x31, 0xbc, 0xa6, 0xb4, 0xbb, 0xb2, 0xf7, 0x91, 0x35, 0xcb, 0x7f, 0x00, 0xbe, 0xc3, - 0xda, 0xc6, 0xe8, 0xf2, 0xfa, 0x9b, 0xf5, 0xd5, 0xba, 0xbc, 0xb6, 0xb4, 0x7b, 0xbc, 0xc9, 0xea, - 0x96, 0x71, 0xf5, 0x41, 0x6b, 0xf1, 0x16, 0x7e, 0x10, 0xc3, 0xfc, 0xae, 0x31, 0x3c, 0xba, 0x98, - 0xa6, 0x6d, 0xf4, 0x8e, 0x58, 0x43, 0xed, 0x15, 0xef, 0xe0, 0x2a, 0xde, 0x79, 0xd0, 0xb4, 0x97, - 0xc7, 0x5a, 0xbd, 0x38, 0x9d, 0x68, 0x8d, 0xd3, 0x23, 0xb6, 0xef, 0xa7, 0xb3, 0x81, 0x1f, 0xa7, - 0x8b, 0x20, 0x8c, 0xbd, 0x4c, 0x0c, 0x12, 0x21, 0x69, 0x5d, 0xbd, 0x28, 0x3a, 0xed, 0xac, 0x2d, - 0xab, 0x3d, 0x99, 0x34, 0x68, 0x85, 0xdf, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x5c, 0x7b, - 0x89, 0xed, 0x04, 0x00, 0x00, +func init() { proto.RegisterFile("pb/flow.proto", fileDescriptor_0beab9b6746e934c) } + +var fileDescriptor_0beab9b6746e934c = []byte{ + // 675 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xdf, 0x6e, 0xd3, 0x4a, + 0x10, 0xc6, 0x4f, 0x0e, 0x69, 0x9a, 0x6c, 0x9a, 0xd6, 0x2c, 0xa5, 0x0c, 0xa5, 0x84, 0x10, 0x0a, + 0x0a, 0x54, 0x0a, 0x12, 0x54, 0x95, 0x10, 0xdc, 0xa4, 0x7f, 0x22, 0x2c, 0xd2, 0xd4, 0xb2, 0x43, + 0xcb, 0xed, 0xc6, 0x5e, 0x5b, 0x11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x6c, 0xdf, 0xfc, 0x66, 0x30, 0x0c, 0x1d, 0x2c, 0x33, 0x36, + 0xda, 0x47, 0xac, 0xa2, 0xf7, 0x93, 0x37, 0x70, 0xa5, 0xd7, 0x0e, 0x9a, 0xd6, 0xe2, 0xd8, 0x28, + 0x67, 0xd1, 0x89, 0x51, 0x39, 0x3d, 0x62, 0xfb, 0x6e, 0x3c, 0xed, 0xba, 0x61, 0x3c, 0xf7, 0xfc, + 0x50, 0x24, 0xb2, 0x1b, 0x49, 0x45, 0x6b, 0x2f, 0x82, 0xe0, 0xb4, 0xb1, 0xb2, 0xf4, 0xd6, 0x78, + 0x5c, 0xa1, 0x5f, 0xc1, 0xfb, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x0c, 0xcf, 0xae, 0x38, + 0x05, 0x00, 0x00, } diff --git a/pb/flow.proto b/pb/flow.proto index e87e513..eeba858 100644 --- a/pb/flow.proto +++ b/pb/flow.proto @@ -18,11 +18,11 @@ message FlowMessage { uint64 SamplingRate = 3; uint32 SequenceNum = 4; - // Found inside packet + // Found inside packet (To be deprecated in favor of TimeFlowEnd) uint64 TimeFlow = 5; // Source/destination addresses - bytes SrcIP = 6; + bytes SrcIP = 6; bytes DstIP = 7; // To be deprecated @@ -89,4 +89,8 @@ message FlowMessage { uint32 FragmentOffset = 36; uint32 IPv6FlowLabel = 37; -} \ No newline at end of file + + // time information, found inside packets + uint64 TimeFlowStart = 40; + uint64 TimeFlowEnd = 41; +} From 2196ba5de994a978c6cbaa9fc0c6d5340e2505dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A4gele?= Date: Fri, 12 Apr 2019 11:11:20 +0200 Subject: [PATCH 2/6] add required handling in producer for new time fields --- producer/producer_nf.go | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/producer/producer_nf.go b/producer/producer_nf.go index 4d31a96..2bc40ea 100644 --- a/producer/producer_nf.go +++ b/producer/producer_nf.go @@ -271,26 +271,50 @@ func ConvertNetFlowDataSet(version uint16, baseTime uint32, uptime uint32, recor if version == 9 { // NetFlow v9 time works with a differential based on router's uptime switch df.Type { + case netflow.NFV9_FIELD_FIRST_SWITCHED: + var timeFirstSwitched uint32 + DecodeUNumber(v, &timeFirstSwitched) + timeDiff := (uptime - timeFirstSwitched) / 1000 + flowMessage.TimeFlowStart = uint64(baseTime - timeDiff) case netflow.NFV9_FIELD_LAST_SWITCHED: var timeLastSwitched uint32 DecodeUNumber(v, &timeLastSwitched) timeDiff := (uptime - timeLastSwitched) / 1000 - flowMessage.TimeFlow = uint64(baseTime - timeDiff) + timeFlowEnd := uint64(baseTime - timeDiff) + flowMessage.TimeFlow = timeFlowEnd // deprecate this + flowMessage.TimeFlowEnd = timeFlowEnd } } else if version == 10 { switch df.Type { + case netflow.IPFIX_FIELD_flowStartSeconds: + DecodeUNumber(v, &time) + flowMessage.TimeFlowStart = time + case netflow.IPFIX_FIELD_flowStartMilliseconds: + DecodeUNumber(v, &time) + flowMessage.TimeFlowStart = time / 1000 + case netflow.IPFIX_FIELD_flowStartMicroseconds: + DecodeUNumber(v, &time) + flowMessage.TimeFlowStart = time / 1000000 + case netflow.IPFIX_FIELD_flowStartNanoseconds: + DecodeUNumber(v, &time) + flowMessage.TimeFlowStart = time / 1000000000 + case netflow.IPFIX_FIELD_flowEndSeconds: DecodeUNumber(v, &time) - flowMessage.TimeFlow = time + flowMessage.TimeFlow = time // deprecate this + flowMessage.TimeFlowEnd = time case netflow.IPFIX_FIELD_flowEndMilliseconds: DecodeUNumber(v, &time) - flowMessage.TimeFlow = time / 1000 + flowMessage.TimeFlow = time / 1000 // deprecate this + flowMessage.TimeFlowEnd = time / 1000 case netflow.IPFIX_FIELD_flowEndMicroseconds: DecodeUNumber(v, &time) - flowMessage.TimeFlow = time / 1000000 + flowMessage.TimeFlow = time / 1000000 // deprecate this + flowMessage.TimeFlowEnd = time / 1000000 case netflow.IPFIX_FIELD_flowEndNanoseconds: DecodeUNumber(v, &time) - flowMessage.TimeFlow = time / 1000000000 + flowMessage.TimeFlow = time / 1000000000 // deprecate this + flowMessage.TimeFlowEnd = time / 1000000000 } } } From c3f9225b004c3bdebfcf4fe7d918b153020fb202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A4gele?= Date: Fri, 12 Apr 2019 11:15:09 +0200 Subject: [PATCH 3/6] update readme accordingly --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 828382f..e415f84 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ The format is the following: | ----- | ----------- | | FlowType | Indicates the protocol (IPFIX, NetFlow v9, sFlow v5) | | TimeRecvd | Timestamp the packet was received by the collector | -| TimeFlow | Timestamp of the packet (same as TimeRecvd in sFlow, in NetFlow it's the uptime of the router minus LAST_SWITCHED field, in IPFIX it's flowEnd* field) | +| TimeFlow | Timestamp of the packet (same as TimeRecvd in sFlow, in NetFlow it's the uptime of the router minus LAST_SWITCHED field, in IPFIX it's flowEnd* field), meant to be replaced by TimeFlowEnd | | SamplingRate | Sampling rate of the flow, used to extrapolate the number of bytes and packets | | SequenceNum | Sequence number of the packet | | SrcIP | Source IP (sequence of bytes, can be IPv4 or IPv6) | @@ -172,6 +172,8 @@ The format is the following: | FragmentId | IP Fragment Identifier | | FragmentOffset | IP Fragment Offset | | IPv6FlowLabel | IPv6 Flow Label | +| TimeFlowStart | Start Timestamp of the flow (same as TimeRecvd in sFlow, in NetFlow it's the uptime of the router minus FIRST_SWITCHED field, in IPFIX it's flowStart* field) | +| TimeFlowEnd | End Timestamp of the flow (same as TimeRecvd in sFlow, in NetFlow it's the uptime of the router minus LAST_SWITCHED field, in IPFIX it's flowEnd* field) | ### Implementation notes From 22b8675dd97b00172b7cd904c0466c0081a331b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A4gele?= Date: Fri, 12 Apr 2019 11:23:38 +0200 Subject: [PATCH 4/6] make sflow use the new time fields, do not use TimeFlow internally anymore --- goflow.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/goflow.go b/goflow.go index 95e3f29..e99ab24 100644 --- a/goflow.go +++ b/goflow.go @@ -268,7 +268,7 @@ func (s *state) decodeNetFlow(msg interface{}) error { for _, fmsg := range flowMessageSet { fmsg.TimeRecvd = uint64(time.Now().UTC().Unix()) fmsg.RouterAddr = routerAddr - timeDiff := fmsg.TimeRecvd - fmsg.TimeFlow + timeDiff := fmsg.TimeRecvd - fmsg.TimeFlowEnd NetFlowTimeStatsSum.With( prometheus.Labels{ "router": key, @@ -361,7 +361,7 @@ func (s *state) decodeNetFlow(msg interface{}) error { for _, fmsg := range flowMessageSet { fmsg.TimeRecvd = uint64(time.Now().UTC().Unix()) fmsg.RouterAddr = routerAddr - timeDiff := fmsg.TimeRecvd - fmsg.TimeFlow + timeDiff := fmsg.TimeRecvd - fmsg.TimeFlowEnd NetFlowTimeStatsSum.With( prometheus.Labels{ "router": key, @@ -384,17 +384,17 @@ func (s *state) decodeNetFlow(msg interface{}) error { } func FlowMessageToString(fmsg *flowmessage.FlowMessage) string { - s := fmt.Sprintf("Type:%v TimeRecvd:%v SamplingRate:%v SequenceNum:%v TimeFlow:%v " + - "SrcIP:%v DstIP:%v IPversion:%v Bytes:%v Packets:%v RouterAddr:%v NextHop:%v NextHopAS:%v " + - "SrcAS:%v DstAS:%v SrcNet:%v DstNet:%v SrcIf:%v DstIf:%v Proto:%v " + - "SrcPort:%v DstPort:%v IPTos:%v ForwardingStatus:%v IPTTL:%v TCPFlags:%v " + - "SrcMac:%v DstMac:%v VlanId:%v Etype:%v IcmpType:%v IcmpCode:%v " + - "SrcVlan:%v DstVlan:%v IPv6FlowLabel:%v", - fmsg.Type, fmsg.TimeRecvd, fmsg.SamplingRate, fmsg.SequenceNum, fmsg.TimeFlow, - net.IP(fmsg.SrcIP), net.IP(fmsg.DstIP), fmsg.IPversion, fmsg.Bytes, fmsg.Packets, net.IP(fmsg.RouterAddr), net.IP(fmsg.NextHop), fmsg.NextHopAS, - fmsg.SrcAS, fmsg.DstAS, fmsg.SrcNet, fmsg.DstNet, fmsg.SrcIf, fmsg.DstIf, fmsg.Proto, - fmsg.SrcPort, fmsg.DstPort, fmsg.IPTos, fmsg.ForwardingStatus, fmsg.IPTTL, fmsg.TCPFlags, - fmsg.SrcMac, fmsg.DstMac, fmsg.VlanId, fmsg.Etype, fmsg.IcmpType, fmsg.IcmpCode, + s := fmt.Sprintf("Type:%v TimeRecvd:%v SamplingRate:%v SequenceNum:%v TimeFlowStart:%v "+ + "TimeFlowEnd:%v SrcIP:%v DstIP:%v IPversion:%v Bytes:%v Packets:%v RouterAddr:%v "+ + "NextHop:%v NextHopAS:%v SrcAS:%v DstAS:%v SrcNet:%v DstNet:%v SrcIf:%v DstIf:%v "+ + "Proto:%v SrcPort:%v DstPort:%v IPTos:%v ForwardingStatus:%v IPTTL:%v TCPFlags:%v "+ + "SrcMac:%v DstMac:%v VlanId:%v Etype:%v IcmpType:%v IcmpCode:%v "+ + "SrcVlan:%v DstVlan:%v IPv6FlowLabel:%v", + fmsg.Type, fmsg.TimeRecvd, fmsg.SamplingRate, fmsg.SequenceNum, fmsg.TimeFlowStart, fmsg.TimeFlowEnd, + net.IP(fmsg.SrcIP), net.IP(fmsg.DstIP), fmsg.IPversion, fmsg.Bytes, fmsg.Packets, net.IP(fmsg.RouterAddr), net.IP(fmsg.NextHop), fmsg.NextHopAS, + fmsg.SrcAS, fmsg.DstAS, fmsg.SrcNet, fmsg.DstNet, fmsg.SrcIf, fmsg.DstIf, fmsg.Proto, + fmsg.SrcPort, fmsg.DstPort, fmsg.IPTos, fmsg.ForwardingStatus, fmsg.IPTTL, fmsg.TCPFlags, + fmsg.SrcMac, fmsg.DstMac, fmsg.VlanId, fmsg.Etype, fmsg.IcmpType, fmsg.IcmpCode, fmsg.SrcVlan, fmsg.DstVlan, fmsg.IPv6FlowLabel) return s } @@ -603,7 +603,9 @@ func (s *state) decodeSflow(msg interface{}) error { ts := uint64(time.Now().UTC().Unix()) for _, fmsg := range flowMessageSet { fmsg.TimeRecvd = ts - fmsg.TimeFlow = ts + fmsg.TimeFlow = ts // deprecate this + fmsg.TimeFlowStart = ts + fmsg.TimeFlowEnd = ts } s.produceFlow(flowMessageSet) From 92b41af80fded2c78e0811d486dde5660dd9126b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A4gele?= Date: Fri, 12 Apr 2019 13:35:48 +0200 Subject: [PATCH 5/6] remove redundant bytes for protobuf messages generated from sflow --- goflow.go | 1 - 1 file changed, 1 deletion(-) diff --git a/goflow.go b/goflow.go index e99ab24..894c330 100644 --- a/goflow.go +++ b/goflow.go @@ -604,7 +604,6 @@ func (s *state) decodeSflow(msg interface{}) error { for _, fmsg := range flowMessageSet { fmsg.TimeRecvd = ts fmsg.TimeFlow = ts // deprecate this - fmsg.TimeFlowStart = ts fmsg.TimeFlowEnd = ts } From 91411f0a3da96671c8052a935c55f91f5892e855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A4gele?= Date: Fri, 12 Apr 2019 13:38:43 +0200 Subject: [PATCH 6/6] modify readme according to slflow changes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e415f84..bd65efa 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ The format is the following: | FragmentId | IP Fragment Identifier | | FragmentOffset | IP Fragment Offset | | IPv6FlowLabel | IPv6 Flow Label | -| TimeFlowStart | Start Timestamp of the flow (same as TimeRecvd in sFlow, in NetFlow it's the uptime of the router minus FIRST_SWITCHED field, in IPFIX it's flowStart* field) | +| TimeFlowStart | Start Timestamp of the flow (this field is empty for sFlow, in NetFlow it's the uptime of the router minus FIRST_SWITCHED field, in IPFIX it's flowStart* field) | | TimeFlowEnd | End Timestamp of the flow (same as TimeRecvd in sFlow, in NetFlow it's the uptime of the router minus LAST_SWITCHED field, in IPFIX it's flowEnd* field) | ### Implementation notes