Skip to content

Commit 62b0595

Browse files
committedFeb 3, 2020
fixed support for --report-notes and added --report-packets, solving issues EricssonResearch#165 and EricssonResearch#141
1 parent 7be2e43 commit 62b0595

26 files changed

+243
-85
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ spindump_test.out
2020
install_manifest.txt
2121
test/*.out.pre
2222
test/*.out
23+
test/*.cmd
2324
src/*.out
2425
build

‎Usage.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,16 @@ Sets the tool to either report or not report individual spin bit values or spin
8383
--report-qr-loss
8484
--not-report-qr-loss
8585

86-
Sets the tool to either report or not report round-trip loss rates or unidirectional loss rates for QUIC connections based on two experimental algorithms, when using the --textual mode. The default is to not report packet loss rates.
86+
Sets the tool to either report or not report round-trip loss rates or unidirectional loss rates for QUIC connections based on two experimental algorithms, when using the --textual mode. The default is to not report packet loss rates.
8787

88-
--debug
88+
--report-packets
89+
--no-report-packets
90+
--report-notes
91+
--no-report-notes
92+
93+
The first two options set the tool to either report statistics on every packet or not. Note that --report-spins also sets reporting for all packets, but only for QUIC flows. The second two options set the tool to either report the textual "note" field on JSON or textual outputs or not.
94+
95+
--debug
8996
--no-debug
9097
--deepdebug
9198
--no-deepdebug

‎doc/api/analyzer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Called whenever there's a spin bit value in a QUIC connection from the responder
145145

146146
### spindump_analyze_event_newpacket
147147

148-
Called whenever there's a new packet.
148+
Called whenever there's a new packet but no other callback was made (e.g., no new RTT measurements were made).
149149

150150
### spindump_analyze_event_firstresponsepacket
151151

‎src/spindump_analyze.c

+30-11
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,11 @@ spindump_analyze_process_handlers(struct spindump_analyze* state,
348348
if ((handler->eventmask & event) != 0) {
349349
spindump_assert(spindump_analyze_max_handlers == spindump_connection_max_handlers);
350350
spindump_assert(i < spindump_connection_max_handlers);
351-
spindump_deepdebugf("calling handler %x (%lx)", handler->eventmask, (unsigned long)handler->function);
351+
state->stats->analyzerHandlerCalls++;
352+
spindump_deepdebugf("calling %uth handler %x (%lx)",
353+
state->stats->analyzerHandlerCalls,
354+
handler->eventmask,
355+
(unsigned long)handler->function);
352356
(*(handler->function))(state,
353357
handler->handlerData,
354358
&connection->handlerConnectionDatas[i],
@@ -451,10 +455,19 @@ spindump_analyze_process(struct spindump_analyze* state,
451455
//
452456

453457
spindump_assert(state != 0);
458+
spindump_assert(state->stats != 0);
454459
spindump_assert(packet != 0);
455460
spindump_assert(spindump_packet_isvalid(packet));
456461
spindump_assert(p_connection != 0);
457462

463+
//
464+
// Store a count of events before processing this packet
465+
//
466+
467+
packet->analyzerHandlerCalls = state->stats->analyzerHandlerCalls;
468+
spindump_deepdebugf("initialized handler counter to %u for spindump_analyze_process",
469+
packet->analyzerHandlerCalls);
470+
458471
//
459472
// Switch based on type of L2
460473
//
@@ -699,21 +712,27 @@ spindump_analyze_process_pakstats(struct spindump_analyze* state,
699712
connection);
700713
}
701714

702-
spindump_analyze_process_handlers(state,
703-
spindump_analyze_event_newpacket,
704-
packet,
705-
connection);
706-
707-
if (ecnCe) {
708-
spindump_analyze_process_handlers(state,
715+
if (ecnCe) {
716+
spindump_analyze_process_handlers(state,
709717
fromResponder ? spindump_analyze_event_responderecnce :
710-
spindump_analyze_event_initiatorecnce,
718+
spindump_analyze_event_initiatorecnce,
711719
packet,
712720
connection);
713-
}
714-
721+
}
715722

723+
//
724+
// Call the generic "new packet" handler unless some other handler was called earlier
725+
//
716726

727+
spindump_deepdebugf("considering whether to call newpacket handler %u == %u?",
728+
packet->analyzerHandlerCalls,state->stats->analyzerHandlerCalls);
729+
if (packet->analyzerHandlerCalls == state->stats->analyzerHandlerCalls) {
730+
spindump_analyze_process_handlers(state,
731+
spindump_analyze_event_newpacket,
732+
packet,
733+
connection);
734+
}
735+
717736
//
718737
// Loop through any possible aggregated connections this connection
719738
// belongs to, and report the same measurement udpates there.

‎src/spindump_analyze_event.c

+36
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ static void
7878
spindump_analyze_processevent_qrloss_measurement(struct spindump_analyze* state,
7979
const struct spindump_event* event,
8080
struct spindump_connection** p_connection);
81+
static void
82+
spindump_analyze_processevent_packet(struct spindump_analyze* state,
83+
const struct spindump_event* event,
84+
struct spindump_connection** p_connection);
8185
static int
8286
spindump_analyze_event_parseicmpsessionid(const struct spindump_event* event,
8387
uint16_t* p_peerId);
@@ -177,6 +181,9 @@ spindump_analyze_processevent(struct spindump_analyze* state,
177181
case spindump_event_type_rtloss_measurement:
178182
spindump_analyze_processevent_rtloss_measurement(state, event, p_connection);
179183
break;
184+
case spindump_event_type_packet:
185+
spindump_analyze_processevent_packet(state, event, p_connection);
186+
break;
180187
default:
181188
spindump_errorf("invalid event type %u", event->eventType);
182189
return;
@@ -885,6 +892,35 @@ spindump_analyze_processevent_qrloss_measurement(struct spindump_analyze* state,
885892
spindump_analyze_event_updateinfo(state,*p_connection,event);
886893
}
887894

895+
//
896+
// Process an event of type "packet" from another instance of Spindump
897+
// somewhere else. Update statistics and make any other necessary
898+
// changes in the local database of connections.
899+
//
900+
// The parameter state is the analyzer data structure, event is the
901+
// incoming event, and p_connection is an output parameter, in the end
902+
// pointing to either 0 if no affected connection could be identified,
903+
// or a pointer to the connection object from the connection table of
904+
// the analyzer.
905+
//
906+
907+
static void
908+
spindump_analyze_processevent_packet(struct spindump_analyze* state,
909+
const struct spindump_event* event,
910+
struct spindump_connection** p_connection) {
911+
912+
*p_connection = spindump_analyze_processevent_find_connection(state,event);
913+
if (*p_connection == 0) return;
914+
915+
//
916+
// Did we find a connection in the end? If yes, update other
917+
// information (statistics, state) from the event to the connection
918+
// object.
919+
//
920+
921+
spindump_analyze_event_updateinfo(state,*p_connection,event);
922+
}
923+
888924
//
889925
// Find the already existing connection pointed to by the
890926
// event. Return that connection object, or 0 if not found. If the

‎src/spindump_event.c

+3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ spindump_event_type_tostring(enum spindump_event_type type) {
9696
case spindump_event_type_ecn_congestion_event: return("ecnce");
9797
case spindump_event_type_rtloss_measurement: return("rtloss");
9898
case spindump_event_type_qrloss_measurement: return("qrloss");
99+
case spindump_event_type_packet: return("packet");
99100
default:
100101
spindump_errorf("invalid event type");
101102
return("UNKNOWN");
@@ -183,6 +184,8 @@ spindump_event_equal(const struct spindump_event* event1,
183184
if (strcmp(event1->u.qrlossMeasurement.qLoss, event2->u.qrlossMeasurement.qLoss) != 0) return(0);
184185
if (strcmp(event1->u.qrlossMeasurement.rLoss, event2->u.qrlossMeasurement.rLoss) != 0) return(0);
185186
break;
187+
case spindump_event_type_packet:
188+
break;
186189
default:
187190
spindump_errorf("unrecognised event type %u", event1->eventType);
188191
return(0);

‎src/spindump_event.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ enum spindump_event_type {
4040
spindump_event_type_spin_value = 6,
4141
spindump_event_type_ecn_congestion_event = 7,
4242
spindump_event_type_rtloss_measurement = 8,
43-
spindump_event_type_qrloss_measurement = 9
43+
spindump_event_type_qrloss_measurement = 9,
44+
spindump_event_type_packet = 10
4445
};
4546

4647
enum spindump_direction {

‎src/spindump_event_parser_json.c

+24-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ spindump_event_parser_json_parse_aux_rtloss_measurement(const struct spindump_js
5757
struct spindump_event* event);
5858
static int
5959
spindump_event_parser_json_parse_aux_qrloss_measurement(const struct spindump_json_value* json,
60-
struct spindump_event* event);
60+
struct spindump_event* event);
61+
static int
62+
spindump_event_parser_json_parse_aux_packet(const struct spindump_json_value* json,
63+
struct spindump_event* event);
6164

6265
//
6366
// Actual code --------------------------------------------------------------------------------
@@ -225,6 +228,12 @@ spindump_event_parser_json_parse(const struct spindump_json_value* json,
225228
}
226229
break;
227230

231+
case spindump_event_type_packet:
232+
if (!spindump_event_parser_json_parse_aux_packet(json,event)) {
233+
return(0);
234+
}
235+
break;
236+
228237
default:
229238
spindump_errorf("Invalid event type %u", event->eventType);
230239
return(0);
@@ -479,7 +488,7 @@ spindump_event_parser_json_parse_aux_rtloss_measurement(const struct spindump_js
479488

480489
static int
481490
spindump_event_parser_json_parse_aux_qrloss_measurement(const struct spindump_json_value* json,
482-
struct spindump_event* event) {
491+
struct spindump_event* event) {
483492
const struct spindump_json_value* whoField = spindump_json_value_getfield("Who",json);
484493
const struct spindump_json_value* qField = spindump_json_value_getfield("Q_loss",json);
485494
const struct spindump_json_value* rField = spindump_json_value_getfield("R_loss",json);
@@ -511,6 +520,16 @@ spindump_event_parser_json_parse_aux_qrloss_measurement(const struct spindump_js
511520
return(1);
512521
}
513522

523+
//
524+
// Parse the record about a new packet. It has no extra information.
525+
//
526+
527+
static int
528+
spindump_event_parser_json_parse_aux_packet(const struct spindump_json_value* json,
529+
struct spindump_event* event) {
530+
return(1);
531+
}
532+
514533
//
515534
// Take an event description in the input parameter "event", and print
516535
// it out as a JSON-formatted Spindump event. The printed version will
@@ -656,6 +675,9 @@ spindump_event_parser_json_print(const struct spindump_event* event,
656675
addtobuffer2(", \"R_loss\": \"%s\"", event->u.qrlossMeasurement.rLoss);
657676
break;
658677

678+
case spindump_event_type_packet:
679+
break;
680+
659681
default:
660682
spindump_errorf("invalid event type");
661683
}

‎src/spindump_event_parser_text.c

+3
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ spindump_event_parser_text_print(const struct spindump_event* event,
183183
}
184184
break;
185185

186+
case spindump_event_type_packet:
187+
break;
188+
186189
default:
187190
spindump_errorf("invalid event type");
188191
}

‎src/spindump_eventformatter.c

+19-4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ spindump_eventformatter_initialize(struct spindump_analyze* analyzer,
6767
int reportSpinFlips,
6868
int reportRtLoss,
6969
int reportQrLoss,
70+
int reportPackets,
7071
int reportNotes,
7172
int anonymizeLeft,
7273
int anonymizeRight,
@@ -92,6 +93,7 @@ spindump_eventformatter_initialize(struct spindump_analyze* analyzer,
9293
int reportSpinFlips,
9394
int reportRtLoss,
9495
int reportQrLoss,
96+
int reportPackets,
9597
int reportNotes,
9698
int anonymizeLeft,
9799
int anonymizeRight,
@@ -128,6 +130,7 @@ spindump_eventformatter_initialize(struct spindump_analyze* analyzer,
128130
formatter->reportSpinFlips = reportSpinFlips;
129131
formatter->reportRtLoss = reportRtLoss;
130132
formatter->reportQrLoss = reportQrLoss;
133+
formatter->reportPackets = reportPackets;
131134
formatter->reportNotes = reportNotes;
132135
formatter->anonymizeLeft = anonymizeLeft;
133136
formatter->anonymizeRight = anonymizeRight;
@@ -165,6 +168,7 @@ spindump_eventformatter_initialize_file(struct spindump_analyze* analyzer,
165168
int reportSpinFlips,
166169
int reportRtLoss,
167170
int reportQrLoss,
171+
int reportPackets,
168172
int reportNotes,
169173
int anonymizeLeft,
170174
int anonymizeRight,
@@ -183,6 +187,7 @@ spindump_eventformatter_initialize_file(struct spindump_analyze* analyzer,
183187
reportSpinFlips,
184188
reportRtLoss,
185189
reportQrLoss,
190+
reportPackets,
186191
reportNotes,
187192
anonymizeLeft,
188193
anonymizeRight,
@@ -223,6 +228,7 @@ spindump_eventformatter_initialize_remote(struct spindump_analyze* analyzer,
223228
int reportSpinFlips,
224229
int reportRtLoss,
225230
int reportQrLoss,
231+
int reportPackets,
226232
int reportNotes,
227233
int anonymizeLeft,
228234
int anonymizeRight,
@@ -242,6 +248,7 @@ spindump_eventformatter_initialize_remote(struct spindump_analyze* analyzer,
242248
reportSpinFlips,
243249
reportRtLoss,
244250
reportQrLoss,
251+
reportPackets,
245252
reportNotes,
246253
anonymizeLeft,
247254
anonymizeRight,
@@ -503,7 +510,7 @@ spindump_eventformatter_measurement_one(struct spindump_analyze* state,
503510
// Sanity checks
504511
//
505512

506-
spindump_deepdeepdebugf("spindump_eventformatter_measurement_one called for event %u", event);
513+
spindump_deepdeepdebugf("spindump_eventformatter_measurement_one handler called for event %u", event);
507514

508515
spindump_assert(state != 0);
509516
spindump_assert(handlerData != 0);
@@ -611,8 +618,13 @@ spindump_eventformatter_measurement_one(struct spindump_analyze* state,
611618
break;
612619

613620
case spindump_analyze_event_newpacket:
614-
spindump_deepdeepdebugf("point 5x");
615-
return;
621+
spindump_deepdeepdebugf("point 5x %d in eventformatter handler", formatter->reportPackets);
622+
if (formatter->reportPackets) {
623+
eventType = spindump_event_type_packet;
624+
break;
625+
} else {
626+
return;
627+
}
616628

617629
case spindump_analyze_event_initiatorecnce:
618630
spindump_deepdeepdebugf("point 5k");
@@ -669,7 +681,7 @@ spindump_eventformatter_measurement_one(struct spindump_analyze* state,
669681
spindump_connections_getnetworks(connection,&initiatorAddress,&responderAddress);
670682
const char* notes = 0;
671683
char notesbuf[sizeof(eventobj.notes)];
672-
spindump_deepdeepdebugf("reportNotes in eventformatter = %u", formatter->reportNotes);
684+
spindump_deepdeepdebugf("reportPackets and -Notes in eventformatter = %u %u", formatter->reportPackets, formatter->reportNotes);
673685
if (formatter->reportNotes) {
674686
spindump_connection_report_brief_notefieldval(connection,sizeof(notesbuf),notesbuf);
675687
notes = &notesbuf[0];
@@ -863,6 +875,9 @@ spindump_eventformatter_measurement_one(struct spindump_analyze* state,
863875
sprintf(eventobj.u.qrlossMeasurement.rLoss, "%.3f", connection->rLossesFrom2to1*100);
864876
break;
865877

878+
case spindump_analyze_event_newpacket:
879+
break;
880+
866881
default:
867882
return;
868883

‎src/spindump_eventformatter.h

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct spindump_eventformatter {
6969
int reportSpinFlips;
7070
int reportRtLoss;
7171
int reportQrLoss;
72+
int reportPackets;
7273
int reportNotes;
7374
int anonymizeLeft;
7475
int anonymizeRight;
@@ -93,6 +94,7 @@ spindump_eventformatter_initialize_file(struct spindump_analyze* analyzer,
9394
int reportSpinFlips,
9495
int reportRtLoss,
9596
int reportQrLoss,
97+
int reportPackets,
9698
int reportNotes,
9799
int anonymizeLeft,
98100
int anonymizeRight,
@@ -110,6 +112,7 @@ spindump_eventformatter_initialize_remote(struct spindump_analyze* analyzer,
110112
int reportSpinFlips,
111113
int reportRtLoss,
112114
int reportQrLoss,
115+
int reportPackets,
113116
int reportNotes,
114117
int anonymizeLeft,
115118
int anonymizeRight,

0 commit comments

Comments
 (0)