github.com/gopacket/gopacket@v1.1.0/layers/sflow_test.go (about) 1 // Copyright 2014 Google, Inc. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style license 4 // that can be found in the LICENSE file in the root of the source 5 // tree. 6 package layers 7 8 import ( 9 "net" 10 "reflect" 11 "testing" 12 13 "github.com/gopacket/gopacket" 14 ) 15 16 // Test packet collected from live network. See the test below for contents 17 var SFlowTestPacket1 = []byte{ 18 0x84, 0x2b, 0x2b, 0x16, 0x8b, 0x62, 0xf0, 0x50, 0x56, 0x85, 0x3a, 0xfd, 0x08, 0x00, 0x45, 0x00, 19 0x05, 0xbc, 0x9c, 0x04, 0x40, 0x00, 0xff, 0x11, 0xc7, 0x00, 0x0a, 0x01, 0xff, 0x0e, 0x0a, 0x01, 20 0x00, 0x1b, 0xc7, 0x57, 0x18, 0xc7, 0x05, 0xa8, 0x22, 0x3b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 21 0x00, 0x01, 0x0a, 0x01, 0xf8, 0x16, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x9d, 0xfb, 0x40, 0x49, 22 0xc6, 0xcd, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x26, 23 0x27, 0xe8, 0x00, 0x00, 0x02, 0x13, 0x00, 0x00, 0x3e, 0x80, 0x50, 0xbd, 0xe5, 0x80, 0x00, 0x00, 24 0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 25 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x00, 26 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x3c, 0x8a, 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6d, 27 0xf0, 0x40, 0x08, 0x00, 0x45, 0x00, 0x05, 0xc0, 0x6b, 0xaa, 0x40, 0x00, 0x40, 0x06, 0x8f, 0x41, 28 0x0a, 0x01, 0x0e, 0x16, 0x36, 0xf0, 0xeb, 0x45, 0x76, 0xfd, 0x00, 0x50, 0xca, 0x77, 0xef, 0x96, 29 0xfc, 0x28, 0x63, 0x40, 0x50, 0x10, 0x00, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 30 0xf4, 0x00, 0x00, 0x02, 0x77, 0x00, 0x00, 0x00, 0xfd, 0x3b, 0x8c, 0xe7, 0x04, 0x4a, 0x2d, 0xb2, 31 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x01, 0x48, 0xcc, 0x11, 0x0d, 0xe3, 0x00, 32 0x26, 0x85, 0x30, 0x00, 0x00, 0x07, 0x66, 0x00, 0x02, 0xd0, 0x8a, 0x00, 0x02, 0xce, 0xf0, 0x00, 33 0x29, 0x7e, 0x80, 0x00, 0x02, 0xd0, 0x98, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x26, 0x85, 0x30, 0x00, 34 0x00, 0x00, 0xf4, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 35 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 36 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x5e, 0x5c, 0x1e, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00, 37 0x07, 0xd0, 0xb1, 0x2f, 0xa2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00, 38 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 39 0x00, 0x01, 0x00, 0x00, 0x05, 0xee, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x3c, 0x8a, 40 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6f, 0xbe, 0xd8, 0x08, 0x00, 0x45, 0x00, 0x05, 0xdc, 41 0x9f, 0xfd, 0x40, 0x00, 0x40, 0x06, 0x6a, 0xfa, 0x0a, 0x01, 0x0e, 0x10, 0x0a, 0x01, 0x08, 0x13, 42 0x23, 0x84, 0xb7, 0x22, 0x8a, 0xc9, 0x50, 0xb5, 0x4e, 0x10, 0x2a, 0x87, 0x80, 0x10, 0x06, 0x01, 43 0x10, 0xa6, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0xef, 0x1f, 0xf4, 0x07, 0x99, 0x3a, 0xd8, 0x5b, 44 0x01, 0x46, 0x09, 0x00, 0x0c, 0x00, 0x0c, 0x3c, 0xac, 0x4a, 0x1b, 0x06, 0x04, 0x78, 0x78, 0x4e, 45 0xc2, 0x05, 0x46, 0x43, 0x06, 0x04, 0x78, 0x78, 0xee, 0x9c, 0x00, 0x41, 0xef, 0x05, 0x81, 0x32, 46 0x1b, 0x06, 0x04, 0x78, 0x78, 0x56, 0x72, 0x05, 0x4e, 0x92, 0x00, 0x96, 0x39, 0x00, 0xea, 0x3f, 47 0x01, 0x15, 0xa3, 0x08, 0x04, 0x42, 0x6a, 0x82, 0x87, 0x08, 0x05, 0xcc, 0x00, 0x04, 0x00, 0x00, 48 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x5a, 50 0xcd, 0xd0, 0x00, 0x00, 0x02, 0x55, 0x00, 0x00, 0x07, 0xd0, 0x95, 0x67, 0xe1, 0x30, 0x00, 0x00, 51 0x00, 0x00, 0x00, 0x00, 0x02, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 52 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x46, 0x00, 0x00, 53 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x3c, 0x8a, 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6f, 54 0x11, 0x28, 0x08, 0x00, 0x45, 0x00, 0x04, 0x34, 0xdb, 0x36, 0x40, 0x00, 0x40, 0x06, 0x38, 0xac, 55 0x0a, 0x01, 0x0e, 0x11, 0x0a, 0x01, 0x00, 0xcf, 0x23, 0x84, 0xa0, 0x3f, 0x3c, 0xce, 0xd5, 0x4a, 56 0x72, 0x0b, 0x5d, 0x1a, 0x80, 0x10, 0x06, 0x01, 0x8a, 0x50, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 57 0xef, 0x1f, 0xa2, 0xba, 0xe6, 0xfa, 0xae, 0xb3, 0xfe, 0xcf, 0x00, 0x19, 0xcf, 0x00, 0x00, 0x00, 58 0x00, 0x00, 0x01, 0xb9, 0x79, 0xdd, 0x42, 0x00, 0x00, 0x02, 0x84, 0x9b, 0xa9, 0x02, 0xe2, 0x00, 59 0x00, 0x00, 0x00, 0x00, 0x06, 0x32, 0x39, 0x35, 0x34, 0x33, 0x36, 0x00, 0x00, 0x02, 0x70, 0xcd, 60 0x16, 0x40, 0xa6, 0x98, 0x88, 0x24, 0x06, 0x50, 0xb0, 0xf4, 0xee, 0x03, 0xa6, 0xfa, 0x87, 0xaf, 61 0xc1, 0x99, 0x52, 0x0d, 0x07, 0xa8, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 62 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 63 0x00, 0x02, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x20, 0xf2, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 64 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 65 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x54, 0x0b, 0xe4, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 66 0x00, 0x03, 0x00, 0x01, 0x29, 0x82, 0x6d, 0xb0, 0x6c, 0x0b, 0xcb, 0x0d, 0xdd, 0x96, 0x00, 0x06, 67 0xa8, 0xc6, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 68 0x00, 0x00, 0x00, 0x00, 0x34, 0x02, 0x35, 0x58, 0x7c, 0x9e, 0x56, 0x64, 0x25, 0x71, 0x00, 0x70, 69 0x5a, 0xc4, 0x00, 0x09, 0x08, 0xf1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 70 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 74 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x5e, 0x5c, 0x1f, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00, 75 0x07, 0xd0, 0xb1, 0x2f, 0xaa, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00, 76 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 77 0x00, 0x01, 0x00, 0x00, 0x05, 0xee, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x3c, 0x8a, 78 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6f, 0xbe, 0xd8, 0x08, 0x00, 0x45, 0x00, 0x05, 0xdc, 79 0x0f, 0xba, 0x40, 0x00, 0x40, 0x06, 0xf4, 0x3f, 0x0a, 0x01, 0x0e, 0x10, 0x0a, 0x01, 0x0f, 0x11, 80 0x23, 0x84, 0xcd, 0xc0, 0xf4, 0x0e, 0x90, 0x23, 0xd7, 0x32, 0x8b, 0x31, 0x80, 0x10, 0x00, 0x1d, 81 0x6b, 0x12, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0xef, 0x1f, 0xf4, 0x28, 0xef, 0x1f, 0xec, 0x76, 82 0xaa, 0x25, 0x01, 0x04, 0xc0, 0xac, 0xfe, 0x25, 0x01, 0x8e, 0x25, 0x01, 0x16, 0xc7, 0x28, 0xfe, 83 0x7e, 0x70, 0xfe, 0x7e, 0x70, 0x52, 0x7e, 0x70, 0x15, 0x9b, 0xfe, 0x35, 0x01, 0xfe, 0x35, 0x01, 84 0x42, 0x35, 0x01, 0xfe, 0x95, 0x77, 0xfe, 0x95, 0x77, 0xfe, 0x95, 0x77, 0x52, 0x95, 0x77, 0x00, 85 0xd2, 0xfe, 0x70, 0x02, 0x92, 0x70, 0x02, 0x16, 0x60, 0x22, 0x00, 0x7e, 0xb2, 0x15, 0x00, 0x00, 86 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x5a, 88 0xcd, 0xd1, 0x00, 0x00, 0x02, 0x55, 0x00, 0x00, 0x07, 0xd0, 0x95, 0x67, 0xe9, 0x00, 0x00, 0x00, 89 0x00, 0x00, 0x00, 0x00, 0x02, 0x55, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 90 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0xee, 0x00, 0x00, 91 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0xb8, 0xca, 0x3a, 0x6f, 0xbe, 0xd8, 0xb8, 0xca, 0x3a, 0x6f, 92 0x11, 0x28, 0x08, 0x00, 0x45, 0x00, 0x05, 0xdc, 0xfe, 0x05, 0x40, 0x00, 0x40, 0x06, 0x06, 0xf4, 93 0x0a, 0x01, 0x0e, 0x11, 0x0a, 0x01, 0x0e, 0x10, 0x23, 0x84, 0xfa, 0x29, 0xae, 0xd4, 0x95, 0x03, 94 0x99, 0xb8, 0x77, 0xd0, 0x80, 0x10, 0x00, 0x1d, 0x6f, 0x4f, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 95 0xef, 0x1f, 0xa2, 0xcc, 0xef, 0x1f, 0xf4, 0x2c, 0xfe, 0xdb, 0x05, 0xa1, 0xdb, 0x04, 0x9e, 0xc0, 96 0xfe, 0x30, 0x08, 0xb2, 0x30, 0x08, 0xda, 0x2b, 0xbd, 0xfe, 0x2a, 0x01, 0xfe, 0x2a, 0x01, 0x21, 97 0x2a, 0x00, 0xb2, 0xfe, 0x57, 0xb0, 0xb6, 0x57, 0xb0, 0x14, 0x74, 0xf4, 0xf0, 0x4c, 0x05, 0x68, 98 0xfe, 0x54, 0x02, 0xfe, 0x54, 0x02, 0xd2, 0x54, 0x02, 0x00, 0xbe, 0xfe, 0x32, 0x0f, 0xb6, 0x32, 99 0x0f, 0x14, 0x2e, 0x16, 0xaf, 0x47, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 100 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 101 0x00, 0x01, 0x00, 0x00, 0x00, 0x94, 0x01, 0x5e, 0x5c, 0x20, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00, 102 0x07, 0xd0, 0xb1, 0x2f, 0xb2, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x57, 0x00, 0x00, 103 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 104 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x42, 0x3c, 0x8a, 105 0xb0, 0xe7, 0x54, 0x41, 0xb8, 0xca, 0x3a, 0x6f, 0xbe, 0xd8, 0x08, 0x00, 0x45, 0x00, 0x00, 0x34, 106 0xa8, 0x23, 0x40, 0x00, 0x40, 0x06, 0x61, 0x7f, 0x0a, 0x01, 0x0e, 0x10, 0x0a, 0x01, 0x0f, 0x10, 107 0x97, 0x91, 0x23, 0x84, 0x24, 0xfa, 0x91, 0xf7, 0xb4, 0xe8, 0xf3, 0x2d, 0x80, 0x10, 0x00, 0xab, 108 0x7b, 0x7d, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0xef, 0x1f, 0xf4, 0x36, 0xef, 0x1f, 0xdc, 0xde, 109 0x00, 0x00, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 111 } 112 113 // Test collected from the SFlow reference agent. Contains dummy data for several record types 114 // that wern't available on an actual network for sampling. 115 var SFlowTestPacket2 = []byte{ 116 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00, 117 0x04, 0x88, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11, 0x38, 0x63, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 118 0x00, 0x01, 0xdc, 0xb8, 0x18, 0xc7, 0x04, 0x74, 0x02, 0x88, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 119 0x00, 0x01, 0xc0, 0xa8, 0x5b, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0x3a, 0x00, 0x00, 120 0xcb, 0x20, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x54, 0x00, 0x02, 121 0x1f, 0x6e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x1f, 0x6e, 0x00, 0x00, 122 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 123 0x03, 0xed, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74, 124 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x6f, 125 0x72, 0x67, 0x00, 0x00, 0x00, 0x0f, 0x68, 0x6f, 0x73, 0x74, 0x31, 0x2e, 0x73, 0x66, 0x6c, 0x6f, 126 0x77, 0x2e, 0x6f, 0x72, 0x67, 0x06, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 127 0x00, 0x6a, 0x00, 0x00, 0x00, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x75, 0x73, 0x65, 128 0x72, 0xdc, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x10, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 129 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x75, 0x73, 0x65, 0x72, 0x00, 0x00, 0x03, 0xeb, 0x00, 0x00, 130 0x00, 0x64, 0x00, 0x00, 0x00, 0x01, 0x0d, 0x0c, 0x0b, 0x0a, 0x00, 0x00, 0xfd, 0xe9, 0x00, 0x00, 131 0x00, 0x7b, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 132 0x00, 0x03, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 0x03, 0x15, 0x00, 0x00, 133 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x2b, 0x67, 0x00, 0x00, 0x56, 0xce, 0x00, 0x00, 134 0x82, 0x35, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x09, 0x00, 0x00, 135 0x03, 0x78, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 136 0x00, 0x0d, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 137 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x42, 0x00, 0x0c, 138 0x29, 0x67, 0xa0, 0xe5, 0x00, 0x50, 0x56, 0xc0, 0x00, 0x09, 0x08, 0x00, 0x45, 0x10, 0x00, 0x34, 139 0x92, 0xc3, 0x40, 0x00, 0x40, 0x06, 0x70, 0x8d, 0xc0, 0xa8, 0x5b, 0x01, 0xc0, 0xa8, 0x5b, 0x11, 140 0xd3, 0xdd, 0x00, 0x16, 0xe3, 0x2e, 0x84, 0x77, 0x13, 0x6d, 0xc5, 0x53, 0x80, 0x10, 0x1f, 0xf7, 141 0xe7, 0x7d, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x2e, 0xc6, 0x70, 0x3a, 0x00, 0x0f, 0x84, 0x7a, 142 0xbc, 0xd2, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x90, 0x00, 0x02, 0x1f, 0x6f, 0x00, 0x00, 143 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x1f, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 144 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0xed, 0x00, 0x00, 145 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 146 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x6f, 0x72, 0x67, 0x00, 0x00, 147 0x00, 0x0f, 0x68, 0x6f, 0x73, 0x74, 0x31, 0x2e, 0x73, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x6f, 0x72, 148 0x67, 0x03, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 149 0x00, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x75, 0x73, 0x65, 0x72, 0x77, 0x00, 0x00, 150 0x00, 0x6a, 0x00, 0x00, 0x00, 0x10, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 151 0x6e, 0x20, 0x75, 0x73, 0x65, 0x72, 0x00, 0x00, 0x03, 0xeb, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 152 0x00, 0x01, 0x0d, 0x0c, 0x0b, 0x0a, 0x00, 0x00, 0xfd, 0xe9, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 153 0x03, 0xe7, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 154 0x00, 0x7b, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 0x03, 0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 155 0x00, 0x03, 0x00, 0x00, 0x2b, 0x67, 0x00, 0x00, 0x56, 0xce, 0x00, 0x00, 0x82, 0x35, 0x00, 0x00, 156 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x09, 0x00, 0x00, 0x03, 0x78, 0x00, 0x00, 157 0x03, 0xe7, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 158 0x01, 0xb0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 159 0x01, 0x86, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x50, 0x56, 0xc0, 0x00, 0x09, 160 0x00, 0x0c, 0x29, 0x67, 0xa0, 0xe5, 0x08, 0x00, 0x45, 0x10, 0x01, 0x74, 0xbb, 0xfa, 0x40, 0x00, 161 0x40, 0x06, 0x46, 0x16, 0xc0, 0xa8, 0x5b, 0x11, 0xc0, 0xa8, 0x5b, 0x01, 0x00, 0x16, 0xd3, 0xdd, 162 0x13, 0x6d, 0xc5, 0x53, 0xe3, 0x2e, 0x84, 0x77, 0x80, 0x18, 0x01, 0x10, 0x38, 0xca, 0x00, 0x00, 163 0x01, 0x01, 0x08, 0x0a, 0x00, 0x0f, 0x84, 0x7d, 0x2e, 0xc6, 0x70, 0x3a, 0xe3, 0x92, 0x97, 0x1a, 164 0x67, 0x3b, 0xac, 0xec, 0xfa, 0x43, 0x71, 0x5e, 0x36, 0xa1, 0x0a, 0xc6, 0x1a, 0x6a, 0xed, 0x08, 165 0xac, 0xf4, 0xbe, 0xd8, 0x36, 0x59, 0xf6, 0xe2, 0x3d, 0x34, 0x26, 0xf2, 0x42, 0xbd, 0x32, 0xd3, 166 0x37, 0x52, 0xb8, 0xf4, 0x38, 0xf0, 0xf4, 0xeb, 0x76, 0x3b, 0xda, 0x23, 0xf1, 0x92, 0x96, 0xca, 167 0xbb, 0x9c, 0x20, 0x0a, 0x38, 0x37, 0x6f, 0xd9, 0x26, 0xe6, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 168 0x01, 0x54, 0x00, 0x02, 0x1f, 0x70, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 169 0x1f, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 170 0x00, 0x04, 0x00, 0x00, 0x03, 0xed, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 171 0x00, 0x14, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x66, 0x6c, 172 0x6f, 0x77, 0x2e, 0x6f, 0x72, 0x67, 0x00, 0x00, 0x00, 0x0f, 0x68, 0x6f, 0x73, 0x74, 0x31, 0x2e, 173 0x73, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x6f, 0x72, 0x67, 0xff, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00, 174 0x00, 0x2c, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 175 0x20, 0x75, 0x73, 0x65, 0x72, 0x77, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x10, 0x64, 0x65, 176 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x75, 0x73, 0x65, 0x72, 0x00, 0x00, 177 0x03, 0xeb, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x01, 0x0d, 0x0c, 0x0b, 0x0a, 0x00, 0x00, 178 0xfd, 0xe9, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 179 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 180 0x03, 0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x2b, 0x67, 0x00, 0x00, 181 0x56, 0xce, 0x00, 0x00, 0x82, 0x35, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 182 0x03, 0x09, 0x00, 0x00, 0x03, 0x78, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 183 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 184 0x00, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 185 0x00, 0x42, 0x00, 0x0c, 0x29, 0x67, 0xa0, 0xe5, 0x00, 0x50, 0x56, 0xc0, 0x00, 0x09, 0x08, 0x00, 186 0x45, 0x10, 0x00, 0x34, 0x65, 0x7d, 0x40, 0x00, 0x40, 0x06, 0x9d, 0xd3, 0xc0, 0xa8, 0x5b, 0x01, 187 0xc0, 0xa8, 0x5b, 0x11, 0xd3, 0xdd, 0x00, 0x16, 0xe3, 0x2e, 0x84, 0x77, 0x13, 0x6d, 0xc6, 0x93, 188 0x80, 0x10, 0x1f, 0xec, 0xe6, 0x43, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x2e, 0xc6, 0x70, 0x3c, 189 0x00, 0x0f, 0x84, 0x7d, 0x00, 0x50, 190 } 191 192 // processor counter sample 193 var SFlowTestPacket3 = []byte{ 194 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 195 0x0a, 0x14, 0x04, 0x00, 0x00, 0x00, 0x00, 0x64, 196 0x00, 0x01, 0x78, 0xe0, 0x73, 0x03, 0x48, 0x78, 197 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 198 0x00, 0x00, 0x00, 0x34, 0x00, 0x01, 0x78, 0xe0, 199 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 200 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xe9, 201 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x05, 0xaa, 202 0x00, 0x00, 0x05, 0x5a, 0x00, 0x00, 0x05, 0x32, 203 0x00, 0x00, 0x00, 0x00, 0xe7, 0x8d, 0x70, 0x00, 204 0x00, 0x00, 0x00, 0x00, 0x55, 0xe7, 0x70, 0x00, 205 } 206 207 // expanded flow sample - extended switch flow record 208 var SFlowTestPacket4 = []byte{ 209 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 210 0xc0, 0xa8, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 211 0x00, 0x00, 0x02, 0x7e, 0x32, 0xe0, 0xe4, 0x7c, 212 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 213 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x01, 0x23, 214 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x01, 0x00, 215 0x00, 0x00, 0x03, 0x37, 0x00, 0x00, 0x56, 0x23, 216 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x04, 217 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xe9, 218 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 219 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 220 0xff, 0xff, 0xff, 0xff, 221 } 222 223 // expanded flow sample - extended router flow record 224 var SFlowTestPacket5 = []byte{ 225 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 226 0xc0, 0xa8, 0x01, 0x12, 0x00, 0x00, 0x00, 0x00, 227 0x00, 0x00, 0x02, 0x7e, 0x32, 0xe0, 0xe4, 0x7c, 228 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 229 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x01, 0x23, 230 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x01, 0x00, 231 0x00, 0x00, 0x03, 0x34, 0x00, 0x00, 0x56, 0x02, 232 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x04, 233 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xea, 234 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 235 0xc0, 0xa8, 0x01, 0x21, 0xff, 0xff, 0xff, 0xff, 236 0xff, 0xff, 0xff, 0x80, 237 } 238 239 // expanded flow sample - Ipv4 Tunnel Ingress record 240 var SFlowTestPacket6 = []byte{ 241 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01, 242 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x00, 0x01, 0xbd, 0x50, 243 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 244 0x00, 0x00, 0x00, 0x74, 0x02, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x01, 245 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 246 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 247 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f, 248 0xc0, 0xa8, 0x00, 0x54, 0xc0, 0xa8, 0x00, 0x53, 0x00, 0x00, 0x00, 0x00, 249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 250 } 251 252 // expanded flow sample - Ipv4 Tunnel Egress record 253 var SFlowTestPacket7 = []byte{ 254 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01, 255 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x42, 0x68, 256 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 257 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x00, 0x01, 258 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 259 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 260 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x00, 0x54, 262 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 263 0x00, 0x00, 0x00, 0x00, 264 } 265 266 // expanded flow sample - extended router flow record IPv6 next hop 267 var SFlowTestPacket8 = []byte{ 268 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 269 0xc0, 0xa8, 0x01, 0x12, 0x00, 0x00, 0x00, 0x00, 270 0x00, 0x00, 0x02, 0x7e, 0x32, 0xe0, 0xe4, 0x7c, 271 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 272 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x01, 0x23, 273 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x01, 0x00, 274 0x00, 0x00, 0x03, 0x34, 0x00, 0x00, 0x56, 0x02, 275 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x04, 276 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xea, 277 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 278 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 280 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 281 } 282 283 // Counter Sample - port name 284 var SFlowTestPacket9 = []byte{ 285 0x00, 0x00, 0x00, 0x05, 286 0x00, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb3, 0x6d, 287 0x0e, 0x04, 0xd2, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xd8, 288 0x00, 0x00, 0x5b, 0xe0, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 289 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 290 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 291 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 292 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00, 0x00, 0x0c, 293 0x00, 0x00, 0x62, 0xd3, 0x3c, 0xe7, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xed, 294 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x0e, 0x74, 0x61, 0x70, 0x64, 0x39, 0x38, 0x31, 0x35, 295 0x34, 0x66, 0x32, 0x2d, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x58, 296 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x54, 0x0b, 0xe4, 0x00, 297 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x49, 298 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 299 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x0b, 300 0x00, 0x00, 0x01, 0xd2, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 301 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 302 } 303 304 // Vlan counter samples 305 var SFlowTestPacket10 = []byte{ 306 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 307 0x0a, 0x14, 0x04, 0x00, 0x00, 0x00, 0x00, 0x64, 308 0x00, 0x01, 0x78, 0xe0, 0x73, 0x03, 0x48, 0x78, 309 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 310 0x00, 0x00, 0x00, 0x34, 0x00, 0x01, 0x78, 0xe0, 311 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 312 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 313 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0a, 314 0x00, 0x00, 0x00, 0x00, 0x01, 0x8c, 0x2c, 0xcc, 315 0x00, 0x00, 0x96, 0x83, 0x00, 0x02, 0x90, 0x16, 316 0x00, 0x01, 0xf6, 0x73, 0x00, 0x00, 0x00, 0x00, 317 } 318 319 // LACP counter samples 320 var SFlowTestPacket11 = []byte{ 321 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 322 0x7f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 323 0x00, 0x00, 0x38, 0xe5, 0x05, 0xae, 0x16, 0x18, 324 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 325 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x0d, 0x30, 326 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 327 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x38, 328 0x7e, 0x60, 0x69, 0x73, 0x8f, 0x42, 0x00, 0x06, 329 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x00, 330 0x00, 0x00, 0x00, 0x01, 0x05, 0x75, 0x00, 0x00, 331 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 332 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 333 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x95, 334 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 335 } 336 337 // Test packet collected from live network. - contains ethernet frame flow record 338 var SFlowEthernetFramePacket = []byte{ 339 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0xb9, 0x78, 0x16, 0xf6, 0x00, 0x01, 0x86, 0xa0, 340 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x32, 0x97, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 341 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xe8, 342 0x00, 0x01, 0xe8, 0x48, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 343 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 344 0x00, 0x25, 0x90, 0xa2, 0x53, 0x58, 0x00, 0x00, 0x00, 0x1d, 0xb5, 0xa2, 0x5f, 0xc0, 0x00, 0x00, 345 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x7e, 346 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xe8, 0x00, 0x01, 0xec, 0x30, 0x00, 0x00, 0x00, 0x00, 347 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 348 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 0x00, 0x25, 0x90, 0xa2, 0x53, 0x58, 0x00, 0x00, 349 0x7a, 0x7d, 0x48, 0x51, 0xaa, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 350 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xe8, 351 0x00, 0x01, 0xf0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 352 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 353 0x00, 0x25, 0x90, 0xa2, 0x53, 0x58, 0x00, 0x00, 0x7a, 0x7d, 0x48, 0x51, 0xaa, 0xc7, 0x00, 0x00, 354 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 355 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xe8, 0x00, 0x01, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 356 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 357 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 0x00, 0x25, 0x90, 0xa2, 0x53, 0x58, 0x00, 0x00, 358 0x7a, 0x7d, 0x48, 0x51, 0xaa, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 359 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xe8, 360 0x00, 0x01, 0xf7, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 361 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 362 0x00, 0x25, 0x90, 0xa2, 0x53, 0x58, 0x00, 0x00, 0x9e, 0x2b, 0xbb, 0x23, 0x50, 0xb5, 0x00, 0x00, 363 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x82, 364 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xe8, 0x00, 0x01, 0xfb, 0xd0, 0x00, 0x00, 0x00, 0x00, 365 0x00, 0x00, 0x00, 0x03, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 366 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 0x00, 0x1d, 0xb5, 0xa2, 0x5f, 0xc0, 0x00, 0x00, 367 0x00, 0x25, 0x90, 0xa2, 0x53, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 368 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xe8, 369 0x00, 0x01, 0xff, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 370 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 371 0x00, 0x25, 0x90, 0xa2, 0x53, 0x58, 0x00, 0x00, 0x9e, 0x2b, 0xbb, 0x23, 0x50, 0xb5, 0x00, 0x00, 372 0x00, 0x00, 0x00, 0x03, 373 } 374 375 // Openflow counter sample 376 var SFlowTestPacket12 = []byte{ 377 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 378 0x00, 0x01, 0xb3, 0x5a, 0x0e, 0x04, 0x12, 0xe0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 379 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x5b, 0xdb, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x04, 380 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 381 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 382 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 383 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x03, 0xec, 384 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x62, 0xd3, 0x3c, 0xe7, 0x6e, 0x49, 0x00, 0x00, 0xff, 0xfe, 385 0x00, 0x00, 0x03, 0xed, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x62, 0x72, 0x2d, 0x69, 386 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x0b, 387 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x05, 0xf5, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x00, 388 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 389 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 390 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 391 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 392 0x00, 0x00, 0x00, 0x00, 393 } 394 395 // AppResources and Ovsdb counter samples 396 var SFlowTestPacket13 = []byte{ 397 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 398 0x00, 0x01, 0xb3, 0x5f, 0x0e, 0x04, 0x51, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 399 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x5b, 0xdd, 0x02, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x02, 400 0x00, 0x00, 0x08, 0x9b, 0x00, 0x00, 0x00, 0x28, 0x00, 0x0b, 0x15, 0x2d, 0x00, 0x0a, 0x37, 0x39, 401 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 402 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 403 0x00, 0x00, 0x08, 0x9f, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x03, 0xf7, 0x00, 0x00, 0x01, 0x48, 404 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 405 } 406 407 func TestDecodeUDPSFlow(t *testing.T) { 408 p := gopacket.NewPacket(SFlowTestPacket1, LayerTypeEthernet, gopacket.Default) 409 if p.ErrorLayer() != nil { 410 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 411 } 412 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeSFlow}, t) 413 if got, ok := p.TransportLayer().(*UDP); ok { 414 want := &UDP{ 415 BaseLayer: BaseLayer{SFlowTestPacket1[34:42], SFlowTestPacket1[42:]}, 416 sPort: []byte{199, 87}, 417 dPort: []byte{24, 199}, 418 SrcPort: 51031, 419 DstPort: 6343, 420 Checksum: 8763, 421 Length: 1448, 422 } 423 if !reflect.DeepEqual(want, got) { 424 t.Errorf("UDP layer mismatch, \nwant %#v\ngot %#v\n", want, got) 425 } 426 } else { 427 t.Error("Transport layer packet not UDP") 428 } 429 } 430 431 func TestDecodeSFlowDatagram(t *testing.T) { 432 p := gopacket.NewPacket(SFlowTestPacket1, LayerTypeEthernet, gopacket.Default) 433 if p.ErrorLayer() != nil { 434 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 435 } 436 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeSFlow}, t) 437 if got, ok := p.ApplicationLayer().(*SFlowDatagram); ok { 438 want := &SFlowDatagram{ 439 DatagramVersion: uint32(5), 440 AgentAddress: []byte{0xa, 0x1, 0xf8, 0x16}, 441 SubAgentID: uint32(17), 442 SequenceNumber: uint32(40443), 443 AgentUptime: uint32(1078576845), 444 SampleCount: uint32(7), 445 FlowSamples: []SFlowFlowSample{ 446 SFlowFlowSample{ 447 EnterpriseID: 0x0, 448 Format: 0x1, 449 SampleLength: 0xd0, 450 SequenceNumber: 0x2627e8, 451 SourceIDClass: 0x0, 452 SourceIDIndex: 0x213, 453 SamplingRate: 0x3e80, 454 SamplePool: 0x50bde580, 455 Dropped: 0x0, 456 InputInterface: 0x213, 457 OutputInterface: 0x0, 458 RecordCount: 0x2, 459 Records: []SFlowRecord{ 460 SFlowRawPacketFlowRecord{ 461 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 462 EnterpriseID: 0x0, 463 Format: 0x1, 464 FlowDataLength: 0x90, 465 }, 466 HeaderProtocol: 0x1, 467 FrameLength: 0x5d2, 468 PayloadRemoved: 0x4, 469 HeaderLength: 0x80, 470 Header: gopacket.NewPacket(SFlowTestPacket1[134:262], LayerTypeEthernet, gopacket.Default), 471 }, 472 SFlowExtendedSwitchFlowRecord{ 473 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 474 EnterpriseID: 0x0, 475 Format: 0x3e9, 476 FlowDataLength: 0x10, 477 }, 478 IncomingVLAN: 0x202, 479 IncomingVLANPriority: 0x0, 480 OutgoingVLAN: 0x0, 481 OutgoingVLANPriority: 0x0, 482 }, 483 }, 484 }, 485 SFlowFlowSample{ 486 EnterpriseID: 0x0, 487 Format: 0x1, 488 SampleLength: 0xd0, 489 SequenceNumber: 0x15e5c1e, 490 SourceIDClass: 0x0, 491 SourceIDIndex: 0x257, 492 SamplingRate: 0x7d0, 493 SamplePool: 0xb12fa290, 494 Dropped: 0x0, 495 InputInterface: 0x257, 496 OutputInterface: 0x0, 497 RecordCount: 0x2, 498 Records: []SFlowRecord{ 499 SFlowRawPacketFlowRecord{ 500 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 501 EnterpriseID: 0x0, 502 Format: 0x1, 503 FlowDataLength: 0x90, 504 }, 505 HeaderProtocol: 0x1, 506 FrameLength: 0x5ee, 507 PayloadRemoved: 0x4, 508 HeaderLength: 0x80, 509 Header: gopacket.NewPacket(SFlowTestPacket1[350:478], LayerTypeEthernet, gopacket.Default), 510 }, 511 SFlowExtendedSwitchFlowRecord{ 512 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 513 EnterpriseID: 0x0, 514 Format: 0x3e9, 515 FlowDataLength: 0x10, 516 }, 517 IncomingVLAN: 0x202, 518 IncomingVLANPriority: 0x0, 519 OutgoingVLAN: 0x0, 520 OutgoingVLANPriority: 0x0, 521 }, 522 }, 523 }, 524 SFlowFlowSample{ 525 EnterpriseID: 0x0, 526 Format: 0x1, 527 SampleLength: 0xd0, 528 SequenceNumber: 0x15acdd0, 529 SourceIDClass: 0x0, 530 SourceIDIndex: 0x255, 531 SamplingRate: 0x7d0, 532 SamplePool: 0x9567e130, 533 Dropped: 0x0, 534 InputInterface: 0x255, 535 OutputInterface: 0x0, 536 RecordCount: 0x2, 537 Records: []SFlowRecord{ 538 SFlowRawPacketFlowRecord{ 539 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 540 EnterpriseID: 0x0, 541 Format: 0x1, 542 FlowDataLength: 0x90, 543 }, 544 HeaderProtocol: 0x1, 545 FrameLength: 0x446, 546 PayloadRemoved: 0x4, 547 HeaderLength: 0x80, 548 Header: gopacket.NewPacket(SFlowTestPacket1[566:694], LayerTypeEthernet, gopacket.Default), 549 }, 550 SFlowExtendedSwitchFlowRecord{ 551 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 552 EnterpriseID: 0x0, 553 Format: 0x3e9, 554 FlowDataLength: 0x10, 555 }, 556 IncomingVLAN: 0x202, 557 IncomingVLANPriority: 0x0, 558 OutgoingVLAN: 0x0, 559 OutgoingVLANPriority: 0x0, 560 }, 561 }, 562 }, 563 SFlowFlowSample{ 564 EnterpriseID: 0x0, 565 Format: 0x1, 566 SampleLength: 0xd0, 567 SequenceNumber: 0x15e5c1f, 568 SourceIDClass: 0x0, 569 SourceIDIndex: 0x257, 570 SamplingRate: 0x7d0, 571 SamplePool: 0xb12faa60, 572 Dropped: 0x0, 573 InputInterface: 0x257, 574 OutputInterface: 0x0, 575 RecordCount: 0x2, 576 Records: []SFlowRecord{ 577 SFlowRawPacketFlowRecord{ 578 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 579 EnterpriseID: 0x0, 580 Format: 0x1, 581 FlowDataLength: 0x90, 582 }, 583 HeaderProtocol: 0x1, 584 FrameLength: 0x5ee, 585 PayloadRemoved: 0x4, 586 HeaderLength: 0x80, 587 Header: gopacket.NewPacket(SFlowTestPacket1[958:1086], LayerTypeEthernet, gopacket.Default), 588 }, 589 SFlowExtendedSwitchFlowRecord{ 590 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 591 EnterpriseID: 0x0, 592 Format: 0x3e9, 593 FlowDataLength: 0x10, 594 }, 595 IncomingVLAN: 0x202, 596 IncomingVLANPriority: 0x0, 597 OutgoingVLAN: 0x0, 598 OutgoingVLANPriority: 0x0, 599 }, 600 }, 601 }, 602 SFlowFlowSample{ 603 EnterpriseID: 0x0, 604 Format: 0x1, 605 SampleLength: 0xd0, 606 SequenceNumber: 0x15acdd1, 607 SourceIDClass: 0x0, 608 SourceIDIndex: 0x255, 609 SamplingRate: 0x7d0, 610 SamplePool: 0x9567e900, 611 Dropped: 0x0, 612 InputInterface: 0x255, 613 OutputInterface: 0x257, 614 RecordCount: 0x2, 615 Records: []SFlowRecord{ 616 SFlowRawPacketFlowRecord{ 617 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 618 EnterpriseID: 0x0, 619 Format: 0x1, 620 FlowDataLength: 0x90, 621 }, 622 HeaderProtocol: 0x1, 623 FrameLength: 0x5ee, 624 PayloadRemoved: 0x4, 625 HeaderLength: 0x80, 626 Header: gopacket.NewPacket(SFlowTestPacket1[1174:1302], LayerTypeEthernet, gopacket.Default), 627 }, 628 SFlowExtendedSwitchFlowRecord{ 629 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 630 EnterpriseID: 0x0, 631 Format: 0x3e9, 632 FlowDataLength: 0x10, 633 }, 634 IncomingVLAN: 0x202, 635 IncomingVLANPriority: 0x0, 636 OutgoingVLAN: 0x202, 637 OutgoingVLANPriority: 0x0, 638 }, 639 }, 640 }, 641 SFlowFlowSample{ 642 EnterpriseID: 0x0, 643 Format: 0x1, 644 SampleLength: 0x94, 645 SequenceNumber: 0x15e5c20, 646 SourceIDClass: 0x0, 647 SourceIDIndex: 0x257, 648 SamplingRate: 0x7d0, 649 SamplePool: 0xb12fb230, 650 Dropped: 0x0, 651 InputInterface: 0x257, 652 OutputInterface: 0x0, 653 RecordCount: 0x2, 654 Records: []SFlowRecord{ 655 SFlowRawPacketFlowRecord{ 656 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 657 EnterpriseID: 0x0, 658 Format: 0x1, 659 FlowDataLength: 0x54, 660 }, 661 HeaderProtocol: 0x1, 662 FrameLength: 0x46, 663 PayloadRemoved: 0x4, 664 HeaderLength: 0x42, 665 Header: gopacket.NewPacket(SFlowTestPacket1[1390:1458], LayerTypeEthernet, gopacket.Default), 666 }, 667 SFlowExtendedSwitchFlowRecord{ 668 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 669 EnterpriseID: 0x0, 670 Format: 0x3e9, 671 FlowDataLength: 0x10, 672 }, 673 IncomingVLAN: 0x202, 674 IncomingVLANPriority: 0x0, 675 OutgoingVLAN: 0x0, 676 OutgoingVLANPriority: 0x0, 677 }, 678 }, 679 }, 680 }, 681 CounterSamples: []SFlowCounterSample{ 682 SFlowCounterSample{ 683 Format: 0x2, 684 SampleLength: 0xa8, 685 SequenceNumber: 0x20f2, 686 SourceIDClass: 0x0, 687 SourceIDIndex: 0x20a, 688 RecordCount: 0x2, 689 Records: []SFlowRecord{ 690 SFlowGenericInterfaceCounters{ 691 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 692 EnterpriseID: 0x0, 693 Format: 0x1, 694 FlowDataLength: 0x58, 695 }, 696 IfIndex: 0x20a, 697 IfType: 0x6, 698 IfSpeed: 0x2540be400, 699 IfDirection: 0x1, 700 IfStatus: 0x3, 701 IfInOctets: 0x129826db06c0b, 702 IfInUcastPkts: 0xcb0ddd96, 703 IfInMulticastPkts: 0x6a8c6, 704 IfInBroadcastPkts: 0x7b, 705 IfInDiscards: 0x0, 706 IfInErrors: 0x0, 707 IfInUnknownProtos: 0x0, 708 IfOutOctets: 0x340235587c9e, 709 IfOutUcastPkts: 0x56642571, 710 IfOutMulticastPkts: 0x705ac4, 711 IfOutBroadcastPkts: 0x908f1, 712 IfOutDiscards: 0x0, 713 IfOutErrors: 0x0, 714 IfPromiscuousMode: 0x0, 715 }, 716 SFlowEthernetCounters{ 717 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 718 EnterpriseID: 0x0, 719 Format: 0x2, 720 FlowDataLength: 0x34, 721 }, 722 AlignmentErrors: 0x0, 723 FCSErrors: 0x0, 724 SingleCollisionFrames: 0x0, 725 MultipleCollisionFrames: 0x0, 726 SQETestErrors: 0x0, 727 DeferredTransmissions: 0x0, 728 LateCollisions: 0x0, 729 ExcessiveCollisions: 0x0, 730 InternalMacTransmitErrors: 0x0, 731 CarrierSenseErrors: 0x0, 732 FrameTooLongs: 0x0, 733 InternalMacReceiveErrors: 0x0, 734 SymbolErrors: 0x0, 735 }, 736 }, 737 }, 738 }, 739 } 740 if !reflect.DeepEqual(want, got) { 741 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 742 } 743 } else { 744 t.Error("Application layer packet not UDP") 745 } 746 } 747 748 func TestPacketPacket0(t *testing.T) { 749 p := gopacket.NewPacket(SFlowTestPacket2, LinkTypeEthernet, gopacket.Default) 750 if p.ErrorLayer() != nil { 751 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 752 } 753 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv4, LayerTypeUDP, LayerTypeSFlow}, t) 754 if got, ok := p.ApplicationLayer().(*SFlowDatagram); ok { 755 want := &SFlowDatagram{ 756 DatagramVersion: uint32(5), 757 AgentAddress: []byte{192, 168, 91, 17}, 758 SubAgentID: uint32(0), 759 SequenceNumber: uint32(46394), 760 AgentUptime: uint32(52000), 761 SampleCount: uint32(3), 762 FlowSamples: []SFlowFlowSample{ 763 SFlowFlowSample{ 764 EnterpriseID: 0x0, 765 Format: 0x1, 766 SampleLength: 340, 767 SequenceNumber: 139118, 768 SourceIDClass: 0, 769 SourceIDIndex: 3, 770 SamplingRate: 1, 771 SamplePool: 139118, 772 Dropped: 0, 773 InputInterface: 3, 774 OutputInterface: 1073741823, 775 RecordCount: 4, 776 Records: []SFlowRecord{ 777 SFlowExtendedURLRecord{ 778 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 779 EnterpriseID: 0, 780 Format: 1005, 781 FlowDataLength: 48, 782 }, 783 Direction: SFlowURLsrc, 784 URL: "http://www.sflow.org", 785 Host: "host1.sflow.org", 786 }, 787 SFlowExtendedUserFlow{ 788 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 789 EnterpriseID: 0, 790 Format: 1004, 791 FlowDataLength: 44, 792 }, 793 SourceCharSet: SFlowCSUTF8, 794 SourceUserID: "source user", 795 DestinationCharSet: SFlowCSUTF8, 796 DestinationUserID: "destination user", 797 }, 798 SFlowExtendedGatewayFlowRecord{ 799 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 800 EnterpriseID: 0, 801 Format: 1003, 802 FlowDataLength: 100, 803 }, 804 NextHop: []byte{0x0d, 0x0c, 0x0b, 0x0a}, 805 AS: 65001, 806 SourceAS: 123, 807 PeerAS: 999, 808 ASPathCount: 3, 809 ASPath: []SFlowASDestination{ 810 SFlowASDestination{ 811 Type: SFlowASSequence, 812 Count: 3, 813 Members: []uint32{123, 456, 789}, 814 }, 815 SFlowASDestination{ 816 Type: SFlowASSet, 817 Count: 3, 818 Members: []uint32{11111, 22222, 33333}, 819 }, 820 SFlowASDestination{ 821 Type: SFlowASSequence, 822 Count: 3, 823 Members: []uint32{777, 888, 999}, 824 }, 825 }, 826 Communities: []uint32{12, 13}, 827 LocalPref: 432, 828 }, 829 SFlowRawPacketFlowRecord{ 830 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 831 EnterpriseID: 0x0, 832 Format: 0x1, 833 FlowDataLength: 84, 834 }, 835 HeaderProtocol: 1, 836 FrameLength: 70, 837 PayloadRemoved: 4, 838 HeaderLength: 0x42, 839 Header: gopacket.NewPacket(SFlowTestPacket2[350:418], LayerTypeEthernet, gopacket.Default), 840 }, 841 }, 842 }, 843 SFlowFlowSample{ 844 EnterpriseID: 0x0, 845 Format: 0x1, 846 SampleLength: 400, 847 SequenceNumber: 139119, 848 SourceIDClass: 0, 849 SourceIDIndex: 3, 850 SamplingRate: 1, 851 SamplePool: 139119, 852 Dropped: 0, 853 InputInterface: 1073741823, 854 OutputInterface: 3, 855 RecordCount: 4, 856 Records: []SFlowRecord{ 857 SFlowExtendedURLRecord{ 858 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 859 EnterpriseID: 0, 860 Format: 1005, 861 FlowDataLength: 48, 862 }, 863 Direction: SFlowURLsrc, 864 URL: "http://www.sflow.org", 865 Host: "host1.sflow.org", 866 }, 867 SFlowExtendedUserFlow{ 868 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 869 EnterpriseID: 0, 870 Format: 1004, 871 FlowDataLength: 44, 872 }, 873 SourceCharSet: SFlowCSUTF8, 874 SourceUserID: "source user", 875 DestinationCharSet: SFlowCSUTF8, 876 DestinationUserID: "destination user", 877 }, 878 SFlowExtendedGatewayFlowRecord{ 879 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 880 EnterpriseID: 0, 881 Format: 1003, 882 FlowDataLength: 100, 883 }, 884 NextHop: []byte{0x0d, 0x0c, 0x0b, 0x0a}, 885 AS: 65001, 886 SourceAS: 123, 887 PeerAS: 999, 888 ASPathCount: 3, 889 ASPath: []SFlowASDestination{ 890 SFlowASDestination{ 891 Type: SFlowASSequence, 892 Count: 3, 893 Members: []uint32{123, 456, 789}, 894 }, 895 SFlowASDestination{ 896 Type: SFlowASSet, 897 Count: 3, 898 Members: []uint32{11111, 22222, 33333}, 899 }, 900 SFlowASDestination{ 901 Type: SFlowASSequence, 902 Count: 3, 903 Members: []uint32{777, 888, 999}, 904 }, 905 }, 906 Communities: []uint32{12, 13}, 907 LocalPref: 432, 908 }, 909 SFlowRawPacketFlowRecord{ 910 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 911 EnterpriseID: 0x0, 912 Format: 0x1, 913 FlowDataLength: 144, 914 }, 915 HeaderProtocol: 1, 916 FrameLength: 390, 917 PayloadRemoved: 4, 918 HeaderLength: 0x80, 919 Header: gopacket.NewPacket(SFlowTestPacket2[698:826], LayerTypeEthernet, gopacket.Default), 920 }, 921 }, 922 }, 923 SFlowFlowSample{ 924 EnterpriseID: 0x0, 925 Format: 0x1, 926 SampleLength: 340, 927 SequenceNumber: 139120, 928 SourceIDClass: 0, 929 SourceIDIndex: 3, 930 SamplingRate: 1, 931 SamplePool: 139120, 932 Dropped: 0, 933 InputInterface: 3, 934 OutputInterface: 1073741823, 935 RecordCount: 4, 936 Records: []SFlowRecord{ 937 SFlowExtendedURLRecord{ 938 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 939 EnterpriseID: 0, 940 Format: 1005, 941 FlowDataLength: 48, 942 }, 943 Direction: SFlowURLsrc, 944 URL: "http://www.sflow.org", 945 Host: "host1.sflow.org", 946 }, 947 SFlowExtendedUserFlow{ 948 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 949 EnterpriseID: 0, 950 Format: 1004, 951 FlowDataLength: 44, 952 }, 953 SourceCharSet: SFlowCSUTF8, 954 SourceUserID: "source user", 955 DestinationCharSet: SFlowCSUTF8, 956 DestinationUserID: "destination user", 957 }, 958 SFlowExtendedGatewayFlowRecord{ 959 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 960 EnterpriseID: 0, 961 Format: 1003, 962 FlowDataLength: 100, 963 }, 964 NextHop: []byte{0x0d, 0x0c, 0x0b, 0x0a}, 965 AS: 65001, 966 SourceAS: 123, 967 PeerAS: 999, 968 ASPathCount: 3, 969 ASPath: []SFlowASDestination{ 970 SFlowASDestination{ 971 Type: SFlowASSequence, 972 Count: 3, 973 Members: []uint32{123, 456, 789}, 974 }, 975 SFlowASDestination{ 976 Type: SFlowASSet, 977 Count: 3, 978 Members: []uint32{11111, 22222, 33333}, 979 }, 980 SFlowASDestination{ 981 Type: SFlowASSequence, 982 Count: 3, 983 Members: []uint32{777, 888, 999}, 984 }, 985 }, 986 Communities: []uint32{12, 13}, 987 LocalPref: 432, 988 }, 989 SFlowRawPacketFlowRecord{ 990 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 991 EnterpriseID: 0x0, 992 Format: 0x1, 993 FlowDataLength: 84, 994 }, 995 HeaderProtocol: 1, 996 FrameLength: 70, 997 PayloadRemoved: 4, 998 HeaderLength: 0x42, 999 Header: gopacket.NewPacket(SFlowTestPacket2[1106:1174], LayerTypeEthernet, gopacket.Default), 1000 }, 1001 }, 1002 }, 1003 }, 1004 } 1005 if !reflect.DeepEqual(want, got) { 1006 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1007 } 1008 } else { 1009 t.Error("Application layer packet not UDP") 1010 } 1011 } 1012 1013 func TestDecodeProcessorCounter(t *testing.T) { 1014 p := gopacket.NewPacket(SFlowTestPacket3, LayerTypeSFlow, gopacket.Default) 1015 1016 if p.ErrorLayer() != nil { 1017 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1018 } 1019 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1020 1021 got := p.ApplicationLayer().(*SFlowDatagram) 1022 1023 want := &SFlowDatagram{ 1024 DatagramVersion: uint32(5), 1025 AgentAddress: []byte{0x0a, 0x14, 0x04, 0x00}, 1026 SubAgentID: uint32(0x64), 1027 SequenceNumber: uint32(96480), 1028 AgentUptime: uint32(1929595000), 1029 SampleCount: uint32(1), 1030 CounterSamples: []SFlowCounterSample{ 1031 SFlowCounterSample{ 1032 Format: SFlowTypeExpandedCounterSample, 1033 SampleLength: 0x34, 1034 SequenceNumber: 0x0178e0, 1035 SourceIDClass: 0x00, 1036 SourceIDIndex: 0x01, 1037 RecordCount: 0x01, 1038 Records: []SFlowRecord{ 1039 SFlowProcessorCounters{ 1040 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1041 EnterpriseID: 0x0, 1042 Format: SFlowTypeProcessorCounters, 1043 FlowDataLength: 0x1c, 1044 }, 1045 FiveSecCpu: 0x05aa, 1046 OneMinCpu: 0x055a, 1047 FiveMinCpu: 0x0532, 1048 TotalMemory: 0xe78d7000, 1049 FreeMemory: 0x55e77000, 1050 }, 1051 }, 1052 }, 1053 }, 1054 } 1055 if !reflect.DeepEqual(want, got) { 1056 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1057 } 1058 } 1059 1060 func TestDecodeExtendedSwitchFlow(t *testing.T) { 1061 p := gopacket.NewPacket(SFlowTestPacket4, LayerTypeSFlow, gopacket.Default) 1062 1063 if p.ErrorLayer() != nil { 1064 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1065 } 1066 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1067 1068 got := p.ApplicationLayer().(*SFlowDatagram) 1069 1070 want := &SFlowDatagram{ 1071 DatagramVersion: uint32(5), 1072 AgentAddress: []byte{0xc0, 0xa8, 0x01, 0x07}, 1073 SubAgentID: uint32(0x00), 1074 SequenceNumber: uint32(0x027e), 1075 AgentUptime: uint32(0x32e0e47c), 1076 SampleCount: uint32(1), 1077 FlowSamples: []SFlowFlowSample{ 1078 SFlowFlowSample{ 1079 Format: SFlowTypeFlowSample, 1080 SampleLength: 0x38, 1081 SequenceNumber: 0x123, 1082 SourceIDClass: 0x00, 1083 SourceIDIndex: 0x1d, 1084 SamplingRate: 0x100, 1085 SamplePool: 0x337, 1086 Dropped: 0x5623, 1087 InputInterfaceFormat: 0x00, 1088 InputInterface: 0x1d, 1089 OutputInterfaceFormat: 0x00, 1090 OutputInterface: 0x04, 1091 RecordCount: 0x01, 1092 Records: []SFlowRecord{ 1093 SFlowExtendedSwitchFlowRecord{ 1094 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1095 EnterpriseID: 0x0, 1096 Format: SFlowTypeExtendedSwitchFlow, 1097 FlowDataLength: 0x10, 1098 }, 1099 IncomingVLAN: 0x03, 1100 IncomingVLANPriority: 0x02, 1101 OutgoingVLAN: 0x05, 1102 OutgoingVLANPriority: 0xffffffff, 1103 }, 1104 }, 1105 }, 1106 }, 1107 } 1108 if !reflect.DeepEqual(want, got) { 1109 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1110 } 1111 } 1112 1113 func TestDecodeExtendedRouterFlow(t *testing.T) { 1114 p := gopacket.NewPacket(SFlowTestPacket5, LayerTypeSFlow, gopacket.Default) 1115 1116 if p.ErrorLayer() != nil { 1117 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1118 } 1119 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1120 1121 got := p.ApplicationLayer().(*SFlowDatagram) 1122 1123 want := &SFlowDatagram{ 1124 DatagramVersion: uint32(5), 1125 AgentAddress: []byte{0xc0, 0xa8, 0x01, 0x12}, 1126 SubAgentID: uint32(0x00), 1127 SequenceNumber: uint32(0x027e), 1128 AgentUptime: uint32(0x32e0e47c), 1129 SampleCount: uint32(1), 1130 FlowSamples: []SFlowFlowSample{ 1131 SFlowFlowSample{ 1132 Format: SFlowTypeFlowSample, 1133 SampleLength: 0x34, 1134 SequenceNumber: 0x123, 1135 SourceIDClass: 0x00, 1136 SourceIDIndex: 0x1d, 1137 SamplingRate: 0x100, 1138 SamplePool: 0x334, 1139 Dropped: 0x5602, 1140 InputInterfaceFormat: 0x00, 1141 InputInterface: 0x1d, 1142 OutputInterfaceFormat: 0x00, 1143 OutputInterface: 0x04, 1144 RecordCount: 0x01, 1145 Records: []SFlowRecord{ 1146 SFlowExtendedRouterFlowRecord{ 1147 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1148 EnterpriseID: 0x0, 1149 Format: SFlowTypeExtendedRouterFlow, 1150 FlowDataLength: 0x10, 1151 }, 1152 NextHop: []byte{0xc0, 0xa8, 0x01, 0x21}, 1153 NextHopSourceMask: 0xffffffff, 1154 NextHopDestinationMask: 0xffffff80, 1155 }, 1156 }, 1157 }, 1158 }, 1159 } 1160 if !reflect.DeepEqual(want, got) { 1161 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1162 } 1163 } 1164 1165 func TestDecodeExtendedRouterFlowIPv6(t *testing.T) { 1166 p := gopacket.NewPacket(SFlowTestPacket8, LayerTypeSFlow, gopacket.Default) 1167 1168 if p.ErrorLayer() != nil { 1169 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1170 } 1171 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1172 1173 got := p.ApplicationLayer().(*SFlowDatagram) 1174 1175 want := &SFlowDatagram{ 1176 DatagramVersion: uint32(5), 1177 AgentAddress: []byte{0xc0, 0xa8, 0x01, 0x12}, 1178 SubAgentID: uint32(0x00), 1179 SequenceNumber: uint32(0x027e), 1180 AgentUptime: uint32(0x32e0e47c), 1181 SampleCount: uint32(1), 1182 FlowSamples: []SFlowFlowSample{ 1183 SFlowFlowSample{ 1184 Format: SFlowTypeFlowSample, 1185 SampleLength: 0x34, 1186 SequenceNumber: 0x123, 1187 SourceIDClass: 0x00, 1188 SourceIDIndex: 0x1d, 1189 SamplingRate: 0x100, 1190 SamplePool: 0x334, 1191 Dropped: 0x5602, 1192 InputInterfaceFormat: 0x00, 1193 InputInterface: 0x1d, 1194 OutputInterfaceFormat: 0x00, 1195 OutputInterface: 0x04, 1196 RecordCount: 0x01, 1197 Records: []SFlowRecord{ 1198 SFlowExtendedRouterFlowRecord{ 1199 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1200 EnterpriseID: 0x0, 1201 Format: SFlowTypeExtendedRouterFlow, 1202 FlowDataLength: 0x1c, 1203 }, 1204 NextHop: []byte{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 1205 NextHopSourceMask: 0xffffffff, 1206 NextHopDestinationMask: 0xffffff80, 1207 }, 1208 }, 1209 }, 1210 }, 1211 } 1212 if !reflect.DeepEqual(want, got) { 1213 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1214 } 1215 } 1216 1217 func TestDecodeExtendedIpv4TunnelIngressFlow(t *testing.T) { 1218 p := gopacket.NewPacket(SFlowTestPacket6, LayerTypeSFlow, gopacket.Default) 1219 1220 if p.ErrorLayer() != nil { 1221 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1222 } 1223 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1224 1225 got := p.ApplicationLayer().(*SFlowDatagram) 1226 1227 want := &SFlowDatagram{ 1228 DatagramVersion: uint32(5), 1229 AgentAddress: []byte{0x7f, 0x0, 0x0, 0x1}, 1230 SubAgentID: uint32(0), 1231 SequenceNumber: uint32(0x72), 1232 AgentUptime: uint32(0x1bd50), 1233 SampleCount: uint32(1), 1234 FlowSamples: []SFlowFlowSample{ 1235 SFlowFlowSample{ 1236 Format: SFlowTypeFlowSample, 1237 SampleLength: 0x48, 1238 SequenceNumber: 0x74, 1239 SourceIDClass: 0x0, 1240 SourceIDIndex: 0x20003e8, 1241 SamplingRate: 0x1, 1242 SamplePool: 0x74, 1243 Dropped: 0x0, 1244 InputInterfaceFormat: 0x0, 1245 InputInterface: 0x0, 1246 OutputInterfaceFormat: 0x0, 1247 OutputInterface: 0x80000001, 1248 RecordCount: 0x1, 1249 Records: []SFlowRecord{ 1250 SFlowExtendedIpv4TunnelIngressRecord{ 1251 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1252 EnterpriseID: 0x0, 1253 Format: SFlowTypeExtendedIpv4TunnelIngressFlow, 1254 FlowDataLength: 0x20, 1255 }, 1256 SFlowIpv4Record: SFlowIpv4Record{ 1257 Length: 0x0, 1258 Protocol: 0x2f, 1259 IPSrc: net.IP{0xc0, 0xa8, 0x0, 0x54}, 1260 IPDst: net.IP{0xc0, 0xa8, 0x0, 0x53}, 1261 PortSrc: 0x0, 1262 PortDst: 0x0, 1263 TCPFlags: 0x0, 1264 TOS: 0x0, 1265 }, 1266 }, 1267 }, 1268 }, 1269 }, 1270 } 1271 if !reflect.DeepEqual(want, got) { 1272 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1273 } 1274 } 1275 1276 func TestDecodeExtendedIpv4TunnelEgressFlow(t *testing.T) { 1277 p := gopacket.NewPacket(SFlowTestPacket7, LayerTypeSFlow, gopacket.Default) 1278 1279 if p.ErrorLayer() != nil { 1280 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1281 } 1282 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1283 1284 got := p.ApplicationLayer().(*SFlowDatagram) 1285 1286 want := &SFlowDatagram{ 1287 DatagramVersion: uint32(5), 1288 AgentAddress: []byte{0x7f, 0x0, 0x0, 0x1}, 1289 SubAgentID: uint32(1), 1290 SequenceNumber: uint32(0x12), 1291 AgentUptime: uint32(0x4268), 1292 SampleCount: uint32(1), 1293 FlowSamples: []SFlowFlowSample{ 1294 SFlowFlowSample{ 1295 Format: SFlowTypeFlowSample, 1296 SampleLength: 0x48, 1297 SequenceNumber: 0x12, 1298 SourceIDClass: 0x0, 1299 SourceIDIndex: 0x20003e9, 1300 SamplingRate: 0x1, 1301 SamplePool: 0x12, 1302 Dropped: 0x0, 1303 InputInterfaceFormat: 0x0, 1304 InputInterface: 0x6c, 1305 OutputInterfaceFormat: 0x0, 1306 OutputInterface: 0x80000001, 1307 RecordCount: 0x1, 1308 Records: []SFlowRecord{ 1309 SFlowExtendedIpv4TunnelEgressRecord{ 1310 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1311 EnterpriseID: 0x0, 1312 Format: SFlowTypeExtendedIpv4TunnelEgressFlow, 1313 FlowDataLength: 0x20, 1314 }, 1315 SFlowIpv4Record: SFlowIpv4Record{ 1316 Length: 0x0, 1317 Protocol: 0x0, 1318 IPSrc: net.IP{0x0, 0x0, 0x0, 0x0}, 1319 IPDst: net.IP{0xc0, 0xa8, 0x0, 0x54}, 1320 PortSrc: 0x0, 1321 PortDst: 0x0, 1322 TCPFlags: 0x0, 1323 TOS: 0x0, 1324 }, 1325 }, 1326 }, 1327 }, 1328 }, 1329 } 1330 if !reflect.DeepEqual(want, got) { 1331 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1332 } 1333 } 1334 1335 func TestDecodeEthernetFrameFlow(t *testing.T) { 1336 p := gopacket.NewPacket(SFlowEthernetFramePacket, LayerTypeSFlow, gopacket.Default) 1337 1338 if p.ErrorLayer() != nil { 1339 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1340 } 1341 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1342 1343 got := p.ApplicationLayer().(*SFlowDatagram) 1344 1345 want := &SFlowDatagram{ 1346 DatagramVersion: uint32(5), 1347 AgentAddress: net.IP{0xb9, 0x78, 0x16, 0xf6}, 1348 SubAgentID: 0x186a0, 1349 SequenceNumber: 0xb, 1350 AgentUptime: 0x3297, 1351 SampleCount: 0x7, 1352 FlowSamples: []SFlowFlowSample{ 1353 SFlowFlowSample{ 1354 EnterpriseID: 0x0, 1355 Format: 0x1, 1356 SampleLength: 0x40, 1357 SequenceNumber: 0x7d, 1358 SourceIDClass: 0x0, 1359 SourceIDIndex: 0x3, 1360 SamplingRate: 0x3e8, 1361 SamplePool: 0x1e848, 1362 Dropped: 0x0, 1363 InputInterfaceFormat: 0x0, 1364 InputInterface: 0x3fffffff, 1365 OutputInterfaceFormat: 0x0, 1366 OutputInterface: 0x3, 1367 RecordCount: 0x1, 1368 Records: []SFlowRecord{ 1369 SFlowEthernetFrameFlowRecord{ 1370 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1371 0x0, 1372 0x2, 1373 0x18, 1374 }, 1375 FrameLength: 0x10, 1376 SrcMac: net.HardwareAddr{0x0, 0x25, 0x90, 0xa2, 0x53, 0x58}, 1377 DstMac: net.HardwareAddr{0x0, 0x1d, 0xb5, 0xa2, 0x5f, 0xc0}, 1378 Type: 0x3, 1379 }, 1380 }, 1381 }, 1382 SFlowFlowSample{ 1383 EnterpriseID: 0x0, 1384 Format: 0x1, 1385 SampleLength: 0x40, 1386 SequenceNumber: 0x7e, 1387 SourceIDClass: 0x0, 1388 SourceIDIndex: 0x3, 1389 SamplingRate: 0x3e8, 1390 SamplePool: 0x1ec30, 1391 Dropped: 0x0, 1392 InputInterfaceFormat: 0x0, 1393 InputInterface: 0x3fffffff, 1394 OutputInterfaceFormat: 0x0, 1395 OutputInterface: 0x3, 1396 RecordCount: 0x1, 1397 Records: []SFlowRecord{ 1398 SFlowEthernetFrameFlowRecord{ 1399 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1400 EnterpriseID: 0x0, 1401 Format: 0x2, 1402 FlowDataLength: 0x18, 1403 }, FrameLength: 0x10, 1404 SrcMac: net.HardwareAddr{0x0, 0x25, 0x90, 0xa2, 0x53, 0x58}, 1405 DstMac: net.HardwareAddr{0x7a, 0x7d, 0x48, 0x51, 0xaa, 0xc7}, 1406 Type: 0x3, 1407 }, 1408 }, 1409 }, SFlowFlowSample{ 1410 EnterpriseID: 0x0, 1411 Format: 0x1, 1412 SampleLength: 0x40, 1413 SequenceNumber: 0x7f, 1414 SourceIDClass: 0x0, 1415 SourceIDIndex: 0x3, 1416 SamplingRate: 0x3e8, 1417 SamplePool: 0x1f018, 1418 Dropped: 0x0, 1419 InputInterfaceFormat: 0x0, 1420 InputInterface: 0x3fffffff, 1421 OutputInterfaceFormat: 0x0, 1422 OutputInterface: 0x3, 1423 RecordCount: 0x1, 1424 Records: []SFlowRecord{ 1425 SFlowEthernetFrameFlowRecord{ 1426 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1427 EnterpriseID: 0x0, 1428 Format: 0x2, 1429 FlowDataLength: 0x18, 1430 }, 1431 FrameLength: 0x10, 1432 SrcMac: net.HardwareAddr{0x0, 0x25, 0x90, 0xa2, 0x53, 0x58}, 1433 DstMac: net.HardwareAddr{0x7a, 0x7d, 0x48, 0x51, 0xaa, 0xc7}, 1434 Type: 0x3, 1435 }, 1436 }, 1437 }, 1438 SFlowFlowSample{ 1439 EnterpriseID: 0x0, 1440 Format: 0x1, 1441 SampleLength: 0x40, 1442 SequenceNumber: 0x80, 1443 SourceIDClass: 0x0, 1444 SourceIDIndex: 0x3, 1445 SamplingRate: 0x3e8, 1446 SamplePool: 0x1f400, 1447 Dropped: 0x0, 1448 InputInterfaceFormat: 0x0, 1449 InputInterface: 0x3fffffff, 1450 OutputInterfaceFormat: 0x0, 1451 OutputInterface: 0x3, 1452 RecordCount: 0x1, 1453 Records: []SFlowRecord{ 1454 SFlowEthernetFrameFlowRecord{ 1455 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1456 EnterpriseID: 0x0, 1457 Format: 0x2, 1458 FlowDataLength: 0x18, 1459 }, 1460 FrameLength: 0x10, 1461 SrcMac: net.HardwareAddr{0x0, 0x25, 0x90, 0xa2, 0x53, 0x58}, 1462 DstMac: net.HardwareAddr{0x7a, 0x7d, 0x48, 0x51, 0xaa, 0xc7}, 1463 Type: 0x3, 1464 }, 1465 }, 1466 }, 1467 SFlowFlowSample{ 1468 EnterpriseID: 0x0, 1469 Format: 0x1, 1470 SampleLength: 0x40, 1471 SequenceNumber: 0x81, 1472 SourceIDClass: 0x0, 1473 SourceIDIndex: 0x3, 1474 SamplingRate: 0x3e8, 1475 SamplePool: 0x1f7e8, 1476 Dropped: 0x0, 1477 InputInterfaceFormat: 0x0, 1478 InputInterface: 0x3fffffff, 1479 OutputInterfaceFormat: 0x0, 1480 OutputInterface: 0x3, 1481 RecordCount: 0x1, 1482 Records: []SFlowRecord{ 1483 SFlowEthernetFrameFlowRecord{ 1484 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1485 EnterpriseID: 0x0, 1486 Format: 0x2, 1487 FlowDataLength: 0x18, 1488 }, 1489 FrameLength: 0x10, 1490 SrcMac: net.HardwareAddr{0x0, 0x25, 0x90, 0xa2, 0x53, 0x58}, 1491 DstMac: net.HardwareAddr{0x9e, 0x2b, 0xbb, 0x23, 0x50, 0xb5}, 1492 Type: 0x3, 1493 }, 1494 }, 1495 }, 1496 SFlowFlowSample{ 1497 EnterpriseID: 0x0, 1498 Format: 0x1, 1499 SampleLength: 0x40, 1500 SequenceNumber: 0x82, 1501 SourceIDClass: 0x0, 1502 SourceIDIndex: 0x3, 1503 SamplingRate: 0x3e8, 1504 SamplePool: 0x1fbd0, 1505 Dropped: 0x0, 1506 InputInterfaceFormat: 0x0, 1507 InputInterface: 0x3, 1508 OutputInterfaceFormat: 0x0, 1509 OutputInterface: 0x3fffffff, 1510 RecordCount: 0x1, 1511 Records: []SFlowRecord{ 1512 SFlowEthernetFrameFlowRecord{ 1513 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1514 EnterpriseID: 0x0, 1515 Format: 0x2, 1516 FlowDataLength: 0x18, 1517 }, 1518 FrameLength: 0x10, 1519 SrcMac: net.HardwareAddr{0x0, 0x1d, 0xb5, 0xa2, 0x5f, 0xc0}, 1520 DstMac: net.HardwareAddr{0x0, 0x25, 0x90, 0xa2, 0x53, 0x58}, 1521 Type: 0x3, 1522 }, 1523 }, 1524 }, 1525 SFlowFlowSample{ 1526 EnterpriseID: 0x0, 1527 Format: 0x1, 1528 SampleLength: 0x40, 1529 SequenceNumber: 0x83, 1530 SourceIDClass: 0x0, 1531 SourceIDIndex: 0x3, 1532 SamplingRate: 0x3e8, 1533 SamplePool: 0x1ffb8, 1534 Dropped: 0x0, 1535 InputInterfaceFormat: 0x0, 1536 InputInterface: 0x3fffffff, 1537 OutputInterfaceFormat: 0x0, 1538 OutputInterface: 0x3, 1539 RecordCount: 0x1, 1540 Records: []SFlowRecord{ 1541 SFlowEthernetFrameFlowRecord{ 1542 SFlowBaseFlowRecord: SFlowBaseFlowRecord{ 1543 EnterpriseID: 0x0, 1544 Format: 0x2, 1545 FlowDataLength: 0x18, 1546 }, 1547 FrameLength: 0x10, 1548 SrcMac: net.HardwareAddr{0x0, 0x25, 0x90, 0xa2, 0x53, 0x58}, 1549 DstMac: net.HardwareAddr{0x9e, 0x2b, 0xbb, 0x23, 0x50, 0xb5}, 1550 Type: 0x3, 1551 }, 1552 }, 1553 }, 1554 }, 1555 CounterSamples: []SFlowCounterSample(nil), 1556 } 1557 if !reflect.DeepEqual(want, got) { 1558 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1559 } 1560 } 1561 1562 func TestDecodePortnameCounter(t *testing.T) { 1563 p := gopacket.NewPacket(SFlowTestPacket9, LayerTypeSFlow, gopacket.Default) 1564 if p.ErrorLayer() != nil { 1565 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1566 } 1567 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1568 1569 got := p.ApplicationLayer().(*SFlowDatagram) 1570 1571 want := &SFlowDatagram{ 1572 DatagramVersion: 0x5, 1573 AgentAddress: net.IP{0x7f, 0x0, 0x0, 0x1}, 1574 SequenceNumber: 0x1b36d, 1575 AgentUptime: 0xe04d248, 1576 SampleCount: 0x1, 1577 CounterSamples: []SFlowCounterSample{ 1578 SFlowCounterSample{ 1579 Format: 0x2, 1580 SampleLength: 0xd8, 1581 SequenceNumber: 0x5be0, 1582 SourceIDIndex: 0xe, 1583 RecordCount: 0x4, 1584 Records: []SFlowRecord{ 1585 SFlowEthernetCounters{ 1586 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1587 Format: SFlowTypeEthernetInterfaceCounters, 1588 FlowDataLength: 0x34, 1589 }, 1590 SingleCollisionFrames: 0xffffffff, 1591 MultipleCollisionFrames: 0xffffffff, 1592 SQETestErrors: 0xffffffff, 1593 DeferredTransmissions: 0xffffffff, 1594 LateCollisions: 0xffffffff, 1595 ExcessiveCollisions: 0xffffffff, 1596 InternalMacTransmitErrors: 0xffffffff, 1597 CarrierSenseErrors: 0xffffffff, 1598 FrameTooLongs: 0xffffffff, 1599 InternalMacReceiveErrors: 0xffffffff, 1600 SymbolErrors: 0xffffffff, 1601 }, 1602 SFlowOpenflowPortCounters{ 1603 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1604 Format: SFlowTypeOpenflowPortCounters, 1605 FlowDataLength: 0xc, 1606 }, 1607 DatapathID: 0x62d33ce76e49, 1608 PortNo: 0x3, 1609 }, 1610 SFlowPORTNAME{ 1611 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1612 Format: SFlowTypePORTNAMECounters, 1613 FlowDataLength: 0x14, 1614 }, 1615 Len: 0x10, 1616 Str: "tapd98154f2-00", 1617 }, 1618 SFlowGenericInterfaceCounters{ 1619 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1620 Format: SFlowTypeGenericInterfaceCounters, 1621 FlowDataLength: 0x58, 1622 }, 1623 IfIndex: 0xe, 1624 IfType: 0x6, 1625 IfSpeed: 0x2540be400, 1626 IfDirection: 0x1, 1627 IfStatus: 0x3, 1628 IfInOctets: 0x4749, 1629 IfInUcastPkts: 0xb5, 1630 IfInBroadcastPkts: 0xffffffff, 1631 IfInUnknownProtos: 0xffffffff, 1632 IfOutOctets: 0x8a0b, 1633 IfOutUcastPkts: 0x1d2, 1634 IfOutMulticastPkts: 0xffffffff, 1635 IfOutBroadcastPkts: 0xffffffff, 1636 }, 1637 }, 1638 }, 1639 }, 1640 } 1641 if !reflect.DeepEqual(want, got) { 1642 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1643 } 1644 } 1645 1646 func TestDecodeVLANCounter(t *testing.T) { 1647 p := gopacket.NewPacket(SFlowTestPacket10, LayerTypeSFlow, gopacket.Default) 1648 1649 if p.ErrorLayer() != nil { 1650 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1651 } 1652 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1653 1654 got := p.ApplicationLayer().(*SFlowDatagram) 1655 1656 want := &SFlowDatagram{ 1657 DatagramVersion: uint32(5), 1658 AgentAddress: []byte{0x0a, 0x14, 0x04, 0x00}, 1659 SubAgentID: uint32(0x64), 1660 SequenceNumber: uint32(96480), 1661 AgentUptime: uint32(1929595000), 1662 SampleCount: uint32(1), 1663 CounterSamples: []SFlowCounterSample{ 1664 SFlowCounterSample{ 1665 Format: SFlowTypeExpandedCounterSample, 1666 SampleLength: 0x34, 1667 SequenceNumber: 0x0178e0, 1668 SourceIDClass: 0x00, 1669 SourceIDIndex: 0x01, 1670 RecordCount: 0x01, 1671 Records: []SFlowRecord{ 1672 SFlowVLANCounters{ 1673 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1674 EnterpriseID: 0x0, 1675 Format: SFlowTypeVLANCounters, 1676 FlowDataLength: 0x1c, 1677 }, 1678 VlanID: 0x0a, 1679 Octets: 0x018c2ccc, 1680 UcastPkts: 0x9683, 1681 MulticastPkts: 0x029016, 1682 BroadcastPkts: 0x01f673, 1683 Discards: 0x00, 1684 }, 1685 }, 1686 }, 1687 }, 1688 } 1689 if !reflect.DeepEqual(want, got) { 1690 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1691 } 1692 } 1693 1694 func TestDecodeLACPCounter(t *testing.T) { 1695 p := gopacket.NewPacket(SFlowTestPacket11, LayerTypeSFlow, gopacket.Default) 1696 1697 if p.ErrorLayer() != nil { 1698 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1699 } 1700 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1701 1702 got := p.ApplicationLayer().(*SFlowDatagram) 1703 1704 want := &SFlowDatagram{ 1705 DatagramVersion: uint32(5), 1706 AgentAddress: []byte{0x7f, 0x00, 0x00, 0x01}, 1707 SubAgentID: uint32(0x00), 1708 SequenceNumber: uint32(14565), //38e5 1709 AgentUptime: uint32(95295000), //5AE1618 1710 SampleCount: uint32(1), 1711 CounterSamples: []SFlowCounterSample{ 1712 SFlowCounterSample{ 1713 Format: SFlowTypeCounterSample, 1714 SampleLength: 0x74, 1715 SequenceNumber: 0x0d30, 1716 SourceIDClass: 0x00, 1717 SourceIDIndex: 0x1, 1718 RecordCount: 0x01, 1719 Records: []SFlowRecord{ 1720 SFlowLACPCounters{ 1721 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1722 EnterpriseID: 0x0, 1723 Format: SFlowTypeLACPCounters, 1724 FlowDataLength: 0x38, 1725 }, 1726 ActorSystemID: net.HardwareAddr{0x7e, 0x60, 0x69, 0x73, 0x8f, 0x42}, 1727 PartnerSystemID: net.HardwareAddr{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 1728 AttachedAggID: uint32(1), 1729 LacpPortState: SFLLACPPortState{PortStateAll: uint32(91553792)}, 1730 LACPDUsRx: uint32(0), 1731 MarkerPDUsRx: uint32(4294967295), 1732 MarkerResponsePDUsRx: uint32(4294967295), 1733 UnknownRx: uint32(4294967295), 1734 IllegalRx: uint32(0), 1735 LACPDUsTx: uint32(1173), 1736 MarkerPDUsTx: uint32(4294967295), 1737 MarkerResponsePDUsTx: uint32(4294967295), 1738 }, 1739 }, 1740 }, 1741 }, 1742 } 1743 if !reflect.DeepEqual(want, got) { 1744 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1745 } 1746 } 1747 1748 func TestDecodeOpenflowCounter(t *testing.T) { 1749 p := gopacket.NewPacket(SFlowTestPacket12, LayerTypeSFlow, gopacket.Default) 1750 1751 if p.ErrorLayer() != nil { 1752 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1753 } 1754 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1755 1756 got := p.ApplicationLayer().(*SFlowDatagram) 1757 1758 want := &SFlowDatagram{ 1759 DatagramVersion: 0x5, 1760 AgentAddress: net.IP{0x7f, 0x0, 0x0, 0x1}, 1761 SequenceNumber: 0x1b35a, 1762 AgentUptime: 0xe0412e0, 1763 SampleCount: 0x1, 1764 CounterSamples: []SFlowCounterSample{ 1765 SFlowCounterSample{ 1766 Format: SFlowTypeCounterSample, 1767 SampleLength: 0xd0, 1768 SequenceNumber: 0x5bdb, 1769 SourceIDIndex: 0xb, 1770 RecordCount: 0x4, 1771 Records: []SFlowRecord{ 1772 SFlowEthernetCounters{ 1773 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1774 Format: SFlowTypeEthernetInterfaceCounters, 1775 FlowDataLength: 0x34, 1776 }, 1777 SingleCollisionFrames: 0xffffffff, 1778 MultipleCollisionFrames: 0xffffffff, 1779 SQETestErrors: 0xffffffff, 1780 DeferredTransmissions: 0xffffffff, 1781 LateCollisions: 0xffffffff, 1782 ExcessiveCollisions: 0xffffffff, 1783 InternalMacTransmitErrors: 0xffffffff, 1784 CarrierSenseErrors: 0xffffffff, 1785 FrameTooLongs: 0xffffffff, 1786 InternalMacReceiveErrors: 0xffffffff, 1787 SymbolErrors: 0xffffffff, 1788 }, 1789 SFlowOpenflowPortCounters{ 1790 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1791 Format: SFlowTypeOpenflowPortCounters, 1792 FlowDataLength: 0xc, 1793 }, 1794 DatapathID: 0x62d33ce76e49, 1795 PortNo: 0xfffe, 1796 }, 1797 SFlowPORTNAME{ 1798 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1799 Format: SFlowTypePORTNAMECounters, 1800 FlowDataLength: 0xc, 1801 }, 1802 Len: 0x8, 1803 Str: "br-int", 1804 }, 1805 SFlowGenericInterfaceCounters{ 1806 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1807 Format: SFlowTypeGenericInterfaceCounters, 1808 FlowDataLength: 0x58, 1809 }, 1810 IfIndex: 0xb, 1811 IfType: 0x6, 1812 IfSpeed: 0x5f5e100, 1813 IfInBroadcastPkts: 0xffffffff, 1814 IfInUnknownProtos: 0xffffffff, 1815 IfOutMulticastPkts: 0xffffffff, 1816 IfOutBroadcastPkts: 0xffffffff, 1817 }, 1818 }, 1819 }, 1820 }, 1821 } 1822 if !reflect.DeepEqual(want, got) { 1823 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1824 } 1825 } 1826 1827 func TestDecodeAppResourcesOvsdbCounter(t *testing.T) { 1828 p := gopacket.NewPacket(SFlowTestPacket13, LayerTypeSFlow, gopacket.Default) 1829 1830 if p.ErrorLayer() != nil { 1831 t.Error("Failed to decode packet:", p.ErrorLayer().Error()) 1832 } 1833 checkLayers(p, []gopacket.LayerType{LayerTypeSFlow}, t) 1834 1835 got := p.ApplicationLayer().(*SFlowDatagram) 1836 1837 want := &SFlowDatagram{ 1838 DatagramVersion: 0x5, 1839 AgentAddress: net.IP{0x7f, 0x0, 0x0, 0x1}, 1840 SequenceNumber: 0x1b35f, 1841 AgentUptime: 0xe045160, 1842 SampleCount: 0x1, 1843 CounterSamples: []SFlowCounterSample{ 1844 SFlowCounterSample{ 1845 Format: SFlowTypeCounterSample, 1846 SampleLength: 0x5c, 1847 SequenceNumber: 0x5bdd, 1848 SourceIDIndex: 0x20003e8, 1849 RecordCount: 0x2, 1850 Records: []SFlowRecord{ 1851 SFlowAppresourcesCounters{ 1852 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1853 Format: SFLowTypeAPPRESOURCESCounters, 1854 FlowDataLength: 0x28, 1855 }, 1856 UserTime: 0xb152d, 1857 SystemTime: 0xa3739, 1858 MemUsed: 0x58b000, 1859 }, 1860 SFlowOVSDPCounters{ 1861 SFlowBaseCounterRecord: SFlowBaseCounterRecord{ 1862 Format: SFlowTypeOVSDPCounters, 1863 FlowDataLength: 0x18, 1864 }, 1865 NHit: 0x3f7, 1866 NMissed: 0x148, 1867 NMaskHit: 0xa3b, 1868 }, 1869 }, 1870 }, 1871 }, 1872 } 1873 if !reflect.DeepEqual(want, got) { 1874 t.Errorf("SFlow layer mismatch, \nwant:\n\n%#v\ngot:\n\n\n%#v\n\n", want, got) 1875 } 1876 } 1877 1878 func BenchmarkDecodeSFlowPacket1(b *testing.B) { 1879 for i := 0; i < b.N; i++ { 1880 gopacket.NewPacket(SFlowTestPacket1, LinkTypeEthernet, gopacket.NoCopy) 1881 } 1882 } 1883 1884 func BenchmarkDecodeSFlowPacket2(b *testing.B) { 1885 for i := 0; i < b.N; i++ { 1886 gopacket.NewPacket(SFlowTestPacket2, LinkTypeEthernet, gopacket.NoCopy) 1887 } 1888 } 1889 1890 func BenchmarkDecodeSFlowPacket3(b *testing.B) { 1891 for i := 0; i < b.N; i++ { 1892 gopacket.NewPacket(SFlowTestPacket3, LinkTypeEthernet, gopacket.NoCopy) 1893 } 1894 } 1895 1896 func BenchmarkDecodeSFlowPacket4(b *testing.B) { 1897 for i := 0; i < b.N; i++ { 1898 gopacket.NewPacket(SFlowTestPacket4, LinkTypeEthernet, gopacket.NoCopy) 1899 } 1900 } 1901 1902 func BenchmarkDecodeSFlowPacket9(b *testing.B) { 1903 for i := 0; i < b.N; i++ { 1904 gopacket.NewPacket(SFlowTestPacket9, LinkTypeEthernet, gopacket.NoCopy) 1905 } 1906 } 1907 1908 func BenchmarkDecodeSFlowPacket10(b *testing.B) { 1909 for i := 0; i < b.N; i++ { 1910 gopacket.NewPacket(SFlowTestPacket10, LinkTypeEthernet, gopacket.NoCopy) 1911 } 1912 } 1913 1914 func BenchmarkDecodeSFlowPacket11(b *testing.B) { 1915 for i := 0; i < b.N; i++ { 1916 gopacket.NewPacket(SFlowTestPacket11, LinkTypeEthernet, gopacket.NoCopy) 1917 } 1918 } 1919 1920 func BenchmarkDecodeSFlowLayerPacket1(b *testing.B) { 1921 var sflow SFlowDatagram 1922 for i := 0; i < b.N; i++ { 1923 sflow.DecodeFromBytes(SFlowTestPacket1[ /*eth*/ 14+ /*ipv4*/ 20+ /*udp*/ 8:], gopacket.NilDecodeFeedback) 1924 } 1925 } 1926 1927 func BenchmarkDecodeSFlowLayerPacket2(b *testing.B) { 1928 var sflow SFlowDatagram 1929 for i := 0; i < b.N; i++ { 1930 sflow.DecodeFromBytes(SFlowTestPacket2[ /*eth*/ 14+ /*ipv4*/ 20+ /*udp*/ 8:], gopacket.NilDecodeFeedback) 1931 } 1932 }