Fix sampling for Juniper MX104. No sampling algorithm required

This commit is contained in:
Peter Haag 2017-12-31 12:43:40 +01:00
parent 13131ffb41
commit 31137a3f5b
3 changed files with 31 additions and 11 deletions

View File

@ -1,8 +1,12 @@
2017-12-29 2017-12-31
- IPFIX sampling - sampling algorithm no longer required for tag #34
- IPFIX sampling add tags #305 and #304 - set them identical to #34, #35
2017-12-30
- Add new output format json. Print each record as individual json object - Add new output format json. Print each record as individual json object
2017-12-28 2017-12-28
- Add sampling elements ID 302,304,305. put them identcal to ID 48,49,50 - Add sampling elements ID 302,304,305. put them identical to ID 48,49,50
- Add option to label filter terms. syntax: (<filter>) %labelname. - Add option to label filter terms. syntax: (<filter>) %labelname.
- Add %lbl option to print flow label in output - Add %lbl option to print flow label in output
- Update nfdump(1) man page for flowlabels - Update nfdump(1) man page for flowlabels
@ -26,6 +30,8 @@
- Add ipfix sampling. Process option template/record with sampling elements 34 and 35 - Add ipfix sampling. Process option template/record with sampling elements 34 and 35
- Report updates on existing samplers in v9 only if values change. issue 84 - Report updates on existing samplers in v9 only if values change. issue 84
2017-11-05 v1.6.16
2017-12-10 2017-12-10
- Add lz4 compression - Add lz4 compression
- Remove old xstat legancy code, not needed - Remove old xstat legancy code, not needed

View File

@ -1349,7 +1349,8 @@ uint16_t offset_std_sampler_interval, offset_std_sampler_algorithm, found_std_sa
switch (id) { switch (id) {
// general sampling // general sampling
case IPFIX_samplingInterval: case IPFIX_samplingInterval: // legacy #34
case IPFIX_samplingPacketInterval: // #305
if ( length == 4 ) { if ( length == 4 ) {
offset_std_sampler_interval = offset; offset_std_sampler_interval = offset;
found_std_sampling++; found_std_sampling++;
@ -1359,7 +1360,8 @@ uint16_t offset_std_sampler_interval, offset_std_sampler_algorithm, found_std_sa
exporter->info.id, length); exporter->info.id, length);
} }
break; break;
case IPFIX_samplingAlgorithm: case IPFIX_samplingAlgorithm: // legacy #35
case IPFIX_selectorAlgorithm: // #304
if ( length == 1 ) { if ( length == 1 ) {
offset_std_sampler_algorithm = offset; offset_std_sampler_algorithm = offset;
dbg_printf(" 1 byte sampling algorithm option at offset: %u\n", offset); dbg_printf(" 1 byte sampling algorithm option at offset: %u\n", offset);
@ -1374,12 +1376,16 @@ uint16_t offset_std_sampler_interval, offset_std_sampler_algorithm, found_std_sa
offset += length; offset += length;
} }
if ( found_std_sampling == 2 ) { // need all two tags if ( offset_std_sampler_interval ) {
dbg_printf("[%u] Std sampling information found\n", exporter->info.id); dbg_printf("[%u] Std sampling interval found. offset: %u\n",
exporter->info.id, offset_std_sampler_interval);
if ( offset_std_sampler_algorithm )
dbg_printf("[%u] Std sampling algorithm found. offset: %u\n",
exporter->info.id, offset_std_sampler_algorithm);
InsertStdSamplerOffset(fs, id, offset_std_sampler_interval, offset_std_sampler_algorithm); InsertStdSamplerOffset(fs, id, offset_std_sampler_interval, offset_std_sampler_algorithm);
dbg_printf("\n");
} }
dbg_printf("\n");
processed_records++; processed_records++;
} // End of Process_ipfix_option_templates } // End of Process_ipfix_option_templates
@ -1747,7 +1753,8 @@ uint8_t *in;
} else { } else {
id = in[offset_table->offset_id]; id = in[offset_table->offset_id];
} }
mode = in[offset_table->offset_mode];
mode = offset_table->offset_mode ? in[offset_table->offset_mode] : 0;
interval = Get_val32((void *)&in[offset_table->offset_interval]); interval = Get_val32((void *)&in[offset_table->offset_interval]);
InsertSampler(fs, exporter, id, mode, interval); InsertSampler(fs, exporter, id, mode, interval);
@ -1760,7 +1767,7 @@ uint8_t *in;
if ( TestFlag(offset_table->flags, HAS_STD_SAMPLER_DATA) ) { if ( TestFlag(offset_table->flags, HAS_STD_SAMPLER_DATA) ) {
int32_t id = -1; int32_t id = -1;
uint16_t mode = in[offset_table->offset_std_sampler_algorithm]; uint16_t mode = offset_table->offset_std_sampler_algorithm ? in[offset_table->offset_std_sampler_algorithm] : 0;
uint32_t interval = Get_val32((void *)&in[offset_table->offset_std_sampler_interval]); uint32_t interval = Get_val32((void *)&in[offset_table->offset_std_sampler_interval]);
InsertSampler(fs, exporter, id, mode, interval); InsertSampler(fs, exporter, id, mode, interval);

View File

@ -228,9 +228,16 @@ typedef struct ipfix_template_elements_e_s {
#define IPFIX_DestinationIPv6PrefixLength 30 #define IPFIX_DestinationIPv6PrefixLength 30
#define IPFIX_flowLabelIPv6 31 #define IPFIX_flowLabelIPv6 31
#define IPFIX_icmpTypeCodeIPv4 32 #define IPFIX_icmpTypeCodeIPv4 32
// 33 igmpTYpe
// deprecated elements for sampling
#define IPFIX_samplingInterval 34 #define IPFIX_samplingInterval 34
#define IPFIX_samplingAlgorithm 35 #define IPFIX_samplingAlgorithm 35
// 1 - Deterministic Sampling,
// 2 - Random Sampling.
#define IPFIX_samplingPacketInterval 305
#define IPFIX_selectorAlgorithm 304
// reserved 38, 39 // reserved 38, 39
// reserved 48, 49, 50, 51 // reserved 48, 49, 50, 51