Skip to content

Commit

Permalink
issues #217 #218 #224 worked on and issues #219 #222 and #225 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
jariarkko committed Nov 10, 2020
1 parent 0f17e09 commit 9ce7bc3
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 26 deletions.
5 changes: 5 additions & 0 deletions Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ These options are used to control the amount of anonymization that Spindump does

Sets the tool to use always addresses (--addresses) or when possible, DNS names (--names) in its output. The use of names is the default.

--relative
--absolute

Timestamps output by Spindump can be represented as absolute time from epoch, or relative from the first shown event. Default is absolute.

--report-spins
--not-report-spins
--report-spin-flips
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ add_test( NAME spindump_testtraces COMMAND spindump_testtraces.sh WORKING_DIRECT
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/spindump.tar.gz
COMMAND rm ARGS -f ${PROJECT_SOURCE_DIR}/spindump.tar.gz
COMMAND tar
ARGS czf spindump.tar.gz CMakeLists.txt src/CMakeLists.txt README.md .gitignore LICENSE.txt images/*.png images/*.jpg src/*.h src/*.c src/*.sh test/*.txt test/*.pcap test/*.expected test/*.options
ARGS czf spindump.tar.gz CMakeLists.txt src/CMakeLists.txt README.md .gitignore LICENSE.txt images/*.png images/*.jpg src/*.h src/*.c src/*.sh test/*.txt test/*.pcap* test/*.expected test/*.options* test/*.json test/*.noinput test/*.exitcode test/*.nets
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)

Expand Down
5 changes: 4 additions & 1 deletion src/spindump_analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ spindump_analyze_connectionspecifichandlerstillinuse(struct spindump_analyze* st
//

struct spindump_analyze*
spindump_analyze_initialize(unsigned int filterExceptionalValuePercentage,
spindump_analyze_initialize(int showRelativeTime,
unsigned int filterExceptionalValuePercentage,
unsigned long long bandwidthMeasurementPeriod,
unsigned int periodicReportPeriod,
const spindump_tags* defaultTags) {
Expand Down Expand Up @@ -108,6 +109,8 @@ spindump_analyze_initialize(unsigned int filterExceptionalValuePercentage,
//

memset(state,0,size);
state->showRelativeTime = showRelativeTime;
state->firstEventTime = 0;
state->table = spindump_connectionstable_initialize(bandwidthMeasurementPeriod,
periodicReportPeriod,
defaultTags);
Expand Down
5 changes: 4 additions & 1 deletion src/spindump_analyze.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ struct spindump_analyze_handler {
};

struct spindump_analyze {
int showRelativeTime; // Whether reports are in absolute or relative time
unsigned long long firstEventTime; // The time of the first event reported in this Spindump run
struct spindump_connectionstable* table; // a table of all current connections
struct spindump_stats* stats; // pointer to statistics object
unsigned int nHandlers; // the number of slots used in the handler table
Expand All @@ -103,7 +105,8 @@ struct spindump_analyze {
//

struct spindump_analyze*
spindump_analyze_initialize(unsigned int filterExceptionalValuePercentage,
spindump_analyze_initialize(int showRelativeTime,
unsigned int filterExceptionalValuePercentage,
unsigned long long bandwidthMeasurementPeriod,
unsigned int periodicReportPeriod,
const spindump_tags* defaultTags);
Expand Down
29 changes: 8 additions & 21 deletions src/spindump_eventformatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,19 +557,18 @@ spindump_eventformatter_measurement_one(struct spindump_analyze* state,
// Construct the time stamp
//

spindump_deepdeepdebugf("point 3");
unsigned long long timestamplonglong;
// if (packet != 0) {
timestamplonglong =
((unsigned long long)timestamp->tv_sec) * 1000 * 1000 +
(unsigned long long)timestamp->tv_usec;
//} else {
//struct timeval now;
//spindump_getcurrenttime(&now);
//timestamplonglong =
//((unsigned long long)now.tv_sec) * 1000 * 1000 +
//(unsigned long long)now.tv_usec;
//}
spindump_deepdeepdebugf("event generation relative %u %llu %llu",
state->showRelativeTime,
state->firstEventTime,
timestamplonglong);
if (state->showRelativeTime) {
if (state->firstEventTime == 0) state->firstEventTime = timestamplonglong;
timestamplonglong -= state->firstEventTime;
}

//
// Determine event type
Expand Down Expand Up @@ -749,13 +748,8 @@ spindump_eventformatter_measurement_one(struct spindump_analyze* state,
connection->bytesFromSide1.bytesInLastPeriod,
connection->bytesFromSide2.bytesInThisPeriod,
connection->bytesFromSide2.bytesInLastPeriod);
spindump_deepdeepdebugf("calling spindump_event_initialize");
spindump_deepdeepdebugf("calling spindump_event_initialize, really but first pb2bps");
spindump_counter_64bit bw1 = spindump_bandwidth_periodbytes_to_bytespersec(&connection->bytesFromSide1);
spindump_deepdeepdebugf("calling spindump_event_initialize, really and now second pb2bps");
spindump_counter_64bit bw2 = spindump_bandwidth_periodbytes_to_bytespersec(&connection->bytesFromSide2);
spindump_deepdeepdebugf("calling spindump_event_initialize, really really");
spindump_deepdeepdebugf("notes field pt 1 = %s", notes);
spindump_event_initialize(eventType,
connection->type,
connection->state,
Expand All @@ -772,10 +766,6 @@ spindump_eventformatter_measurement_one(struct spindump_analyze* state,
&connection->tags,
notes,
&eventobj);
spindump_deepdeepdebugf("point 7");
spindump_deepdeepdebugf("point 7, 2nd");
spindump_deepdeepdebugf("point 7, 3rd");
spindump_deepdeepdebugf("point 7, 4th");
switch (event) {

case spindump_analyze_event_newconnection:
Expand Down Expand Up @@ -1011,7 +1001,6 @@ spindump_eventformatter_measurement_one(struct spindump_analyze* state,
// Based on the format type, provide different kinds of output
//

spindump_deepdeepdebugf("point 8");
switch (formatter->format) {
case spindump_eventformatter_outputformat_text:
spindump_eventformatter_measurement_one_text(formatter,event,&eventobj,connection);
Expand All @@ -1023,8 +1012,6 @@ spindump_eventformatter_measurement_one(struct spindump_analyze* state,
spindump_errorf("invalid output format in internal variable");
exit(1);
}

spindump_deepdeepdebugf("point 9 (end)");
}

//
Expand Down
11 changes: 11 additions & 0 deletions src/spindump_main_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ spindump_main_configuration_defaultvalues(struct spindump_main_configuration* co
config->toolmode = spindump_toolmode_visual;
config->format = spindump_eventformatter_outputformat_text;
config->maxReceive = 0;
config->showRelativeTime = 0;
config->showStats = 0;
config->reverseDns = 0;
config->reportSpins = 0;
Expand Down Expand Up @@ -231,6 +232,14 @@ spindump_main_processargs(int argc,

spindump_deepdeepdebug = 0;

} else if (strcmp(argv[0],"--relative") == 0) {

config->showRelativeTime = 1;

} else if (strcmp(argv[0],"--absolute") == 0) {

config->showRelativeTime = 0;

} else if (strcmp(argv[0],"--stats") == 0) {

config->showStats = 1;
Expand Down Expand Up @@ -928,6 +937,8 @@ spindump_main_help(void) {
printf("\n");
printf(" --names Use DNS names or addresses in the output. (The default is\n");
printf(" --addresses using names.)\n");
printf(" --relative Show timestamps as absolute time from epoch, or relative\n");
printf(" --absolute from the first shown event. Default is absolute.\n");
printf("\n");
printf(" --report-spins Report individual spin bit values in --textual mode.\n");
printf(" --not-report-spins\n");
Expand Down
1 change: 1 addition & 0 deletions src/spindump_main_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct spindump_main_configuration {
enum spindump_toolmode toolmode;
enum spindump_eventformatter_outputformat format;
unsigned int maxReceive;
int showRelativeTime;
int showStats;
int reverseDns;
int reportPackets;
Expand Down
3 changes: 2 additions & 1 deletion src/spindump_main_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ spindump_main_loop_operation(struct spindump_main_state* state) {

spindump_deepdeepdebugf("main loop, analyzer initialization");
if (config->toolmode == spindump_toolmode_visual) config->periodicReportPeriod = 0;
struct spindump_analyze* analyzer = spindump_analyze_initialize(config-> filterExceptionalValuesPercentage,
struct spindump_analyze* analyzer = spindump_analyze_initialize(config->showRelativeTime,
config-> filterExceptionalValuesPercentage,
config->bandwidthMeasurementPeriod,
config->periodicReportPeriod,
&config->defaultTags);
Expand Down
4 changes: 4 additions & 0 deletions src/spindump_remote_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
// Datatypes ----------------------------------------------------------------------------------
//

#if (MHD_VERSION >= 0x00097000)
#define ENUMMHD
#endif

#ifdef ENUMMHD
#define MHDRESULT enum MHD_Result
#else
Expand Down
2 changes: 1 addition & 1 deletion src/spindump_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ systemtests(void) {
// Analyzer tests -- ICMP
//

struct spindump_analyze* analyzer = spindump_analyze_initialize(0,1000000,0,0);
struct spindump_analyze* analyzer = spindump_analyze_initialize(0,0,1000000,0,0);
spindump_checktest(analyzer != 0);
struct spindump_packet packet1;
struct spindump_connection* connection1 = 0;
Expand Down
1 change: 1 addition & 0 deletions src/spindump_testtraces.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ traces="trace_icmpv4_short
trace_cmd_aggregate_multinet
trace_tcp_short
trace_tcp_short_json trace_dns
trace_tcp_tiny1
trace_quic_v18_short_spin
trace_quic_v18_short_spin_all
trace_quic_v18_long_spin
Expand Down
8 changes: 8 additions & 0 deletions test/trace_tcp_tiny1.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{ "Event": "packet", "Type": "TCP", "Addrs": ["10.30.0.167","95.217.214.232"], "Session": "61085:80", "Ts": 0, "State": "Starting", "Dir": "initiator", "Length": 64, "Packets1": 1, "Packets2": 0, "Bytes1": 64, "Bytes2": 0, "Bandwidth1": 64, "Bandwidth2": 0 },
{ "Event": "new", "Type": "TCP", "Addrs": ["10.30.0.167","95.217.214.232"], "Session": "61085:80", "Ts": 0, "State": "Starting", "Packets1": 1, "Packets2": 0, "Bytes1": 64, "Bytes2": 0, "Bandwidth1": 64, "Bandwidth2": 0 },
{ "Event": "measurement", "Type": "TCP", "Addrs": ["10.30.0.167","95.217.214.232"], "Session": "61085:80", "Ts": 19991, "State": "Up", "Right_rtt": 19991, "Packets1": 1, "Packets2": 1, "Bytes1": 64, "Bytes2": 60, "Bandwidth1": 64, "Bandwidth2": 60 },
{ "Event": "measurement", "Type": "TCP", "Addrs": ["10.30.0.167","95.217.214.232"], "Session": "61085:80", "Ts": 20056, "State": "Up", "Left_rtt": 65, "Packets1": 1, "Packets2": 1, "Bytes1": 64, "Bytes2": 60, "Bandwidth1": 64, "Bandwidth2": 60 },
{ "Event": "measurement", "Type": "TCP", "Addrs": ["10.30.0.167","95.217.214.232"], "Session": "61085:80", "Ts": 729994, "State": "Closing", "Right_rtt": 709938, "Packets1": 3, "Packets2": 2, "Bytes1": 168, "Bytes2": 112, "Bandwidth1": 168, "Bandwidth2": 112 },
{ "Event": "measurement", "Type": "TCP", "Addrs": ["10.30.0.167","95.217.214.232"], "Session": "61085:80", "Ts": 730103, "State": "Closed", "Left_rtt": 109, "Packets1": 3, "Packets2": 2, "Bytes1": 168, "Bytes2": 112, "Bandwidth1": 168, "Bandwidth2": 112 }
]
1 change: 1 addition & 0 deletions test/trace_tcp_tiny1.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--textual --format json --report-packets --relative
Binary file added test/trace_tcp_tiny1.pcap
Binary file not shown.
6 changes: 6 additions & 0 deletions test/trace_tcp_tiny1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

Very small TCP session, with no content. Generated with:

nc -4 arkko.com 80

Six packets in the trace.

0 comments on commit 9ce7bc3

Please sign in to comment.