This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathREADME.tline_graphs
599 lines (583 loc) · 18.8 KB
/
README.tline_graphs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
README - Time Line Graphs
NOTE:
-----
This code is lacking about a 1000 lines of intellegence that is needed
to draw these graphs correctly. The basic problem we face is that we have
the time values for the segments arriving/leaving on one end since the
traffic dump is carried out on that end. The time values for the other end
have to be estimated based on some heuristic. This requires a lot of
intellegence and requires taking care of various conditions like
retransmits, timeouts etc. The current heuristic is a simple one of
adding/subtacting 1/3rd of the rtt.
We started this project thinking it is easy to draw these graphs, and then
realized that it is infact quite a complicated task. All this works with a
-L option at command line, but may not accurately reflect the segment
timings.
We are currently working on fixing this problem and should be able to
provide more accurate results in the near future.
For tcptrace maintainers:
-------------------------
I have left the code in here as the starting point to work on. Whoever is
working on this project would want to clean up this file trace.c (based on
the diffs below), and continue development as a seperate module.
Don't forget to update this file when this option is fully developed.
--Avinash ([email protected])
9 July 2002
-------------------
DIFFS - plotter.c
-------------------
68,75d67
< Bool header_done; /* Flag indicating plotter header written to file */
< Bool axis_switched; /* Switch x & y axis types.
< * (Needed for Time Line Charts,
< * Default = FALSE)
< */
< char *title; /* Plotter title */
< char *xlabel; /* Plotter x-axis label */
< char *ylabel; /* Plotter y-axis label */
91,92d82
< static void WritePlotHeader(PLOTTER pl);
< static void CallDoPlot(PLOTTER pl, char *plot_cmd, int plot_argc, ...);
94a85,88
>
>
>
>
114,119d107
< struct plotter_info *ppi;
<
< ppi = &pplotters[pl];
<
< /* see if we're graphing from "0" OR if the axis type is switched */
< if (graph_time_zero || ppi->axis_switched) {
120a109,111
> /* see if we're graphing from "0" */
> if (graph_time_zero) {
> struct plotter_info *ppi = &pplotters[pl];
268c259
<
---
>
273,276d263
<
< /* Write the plotter header if not already written */
< if(!ppi->header_done)
< WritePlotHeader(pl);
327a315,336
> /* graph coordinates... */
> /* X coord is timeval unless graph_time_zero is true */
> /* Y is signed except when it's a sequence number */
> /* ugly hack -- unsigned makes the graphs hard to work with and is
> only needed for the time sequence graphs */
> /* suggestion by Michele Clark at UNC - make them double instead */
> Mfprintf(f,"%s %s\n",
> graph_time_zero?"dtime":"timeval",
> ((strcmp(ylabel,"sequence number") == 0)&&(!graph_seq_zero))?
> "double":"signed");
>
> if (show_title) {
> if (xplot_title_prefix)
> Mfprintf(f,"title\n%s %s\n",
> ExpandFormat(xplot_title_prefix),
> title);
> else
> Mfprintf(f,"title\n%s\n", title);
> }
> Mfprintf(f,"xlabel\n%s\n", xlabel);
> Mfprintf(f,"ylabel\n%s\n", ylabel);
>
331,338c340
< ppi->axis_switched = FALSE;
< ppi->header_done = FALSE;
<
< /* Save these fields to be writtn to the plotter header later in DoPlot() */
< ppi->title = strdup(title);
< ppi->xlabel = strdup(xlabel);
< ppi->ylabel = strdup(ylabel);
<
---
>
369,373c371
<
< /* Write the plotter header if not already written */
< if(!ppi->header_done)
< WritePlotHeader(pl);
<
---
>
424,425c422,423
< if (colorplot)
< CallDoPlot(pl, color, 0);
---
> if (colorplot)
> DoPlot(pl,"%s",color);
437c435,437
< CallDoPlot(pl,"line", 4, t1, x1, t2, x2);
---
> DoPlot(pl,"line %s %u %s %u",
> xp_timestamp(pl,t1), x1,
> xp_timestamp(pl,t2), x2);
449c449,451
< CallDoPlot(pl,"dline", 4, t1, x1, t2, x2);
---
> DoPlot(pl,"dline %s %u %s %u",
> xp_timestamp(pl,t1), x1,
> xp_timestamp(pl,t2), x2);
459c461
< CallDoPlot(pl,"diamond", 2, t, x);
---
> DoPlot(pl,"diamond %s %u", xp_timestamp(pl,t), x);
469c471
< CallDoPlot(pl,"dot", 2, t, x);
---
> DoPlot(pl,"dot %s %u", xp_timestamp(pl,t), x);
479c481
< CallDoPlot(pl,"plus", 2, t, x);
---
> DoPlot(pl,"plus %s %u", xp_timestamp(pl,t), x);
489c491
< CallDoPlot(pl,"box", 2, t, x);
---
> DoPlot(pl,"box %s %u", xp_timestamp(pl,t), x);
501,503c503
< char arrow_type[7];
< snprintf(arrow_type, sizeof(arrow_type), "%carrow", dir);
< CallDoPlot(pl, arrow_type, 2, t, x);
---
> DoPlot(pl,"%carrow %s %u", dir, xp_timestamp(pl,t), x);
554,556c554
< char tick_type[6];
< snprintf(tick_type, sizeof(tick_type), "%ctick", dir);
< CallDoPlot(pl, tick_type, 2, t, x);
---
> DoPlot(pl,"%ctick %s %u", dir, xp_timestamp(pl,t), x);
643,646c641
< char text_type[6];
< snprintf(text_type, sizeof(text_type), "%stext", where);
<
< CallDoPlot(pl, text_type, 2, t, x);
---
> DoPlot(pl,"%stext %s %u", where, xp_timestamp(pl,t), x);
653c648
< CallDoPlot(pl, str, 0);
---
> DoPlot(pl,"%s", str);
656,663d650
< void
< plotter_invisible(
< PLOTTER pl,
< struct timeval t,
< u_long x)
< {
< CallDoPlot(pl,"invisible", 2, t, x);
< }
665d651
<
768,925d753
< /* This function may be called with 0, 2 or 4 arguments depending on plot command.
< * case 0:
< * The arguments t1, x1, t2, x2 do not hold any valid values, and are not used.
< * case 2:
< * Arguments t2 and x2 are the same as arguments t1 and x1. Only t1 and x1 are used.
< * case 4:
< * All arguments are valid and are used.
< */
< static void
< CallDoPlot(
< PLOTTER pl,
< char *plot_cmd,
< int plot_argc,
< ...)
< {
< struct timeval t1;
< u_long x1;
< struct timeval t2;
< u_long x2;
< va_list ap;
< struct plotter_info *ppi;
< char fmt[200];
<
< if (pl == NO_PLOTTER)
< return;
<
< if (pl > plotter_ix) {
< fprintf(stderr,"Illegal plotter: %d\n", pl);
< exit(-1);
< }
<
< ppi = &pplotters[pl];
<
< /* Get the arguments from the variable list */
< va_start(ap, plot_argc);
< if(plot_argc > 0)
< {
< t1 = va_arg(ap, struct timeval);
< x1 = va_arg(ap, u_long);
< }
< if(plot_argc > 2)
< {
< t2 = va_arg(ap, struct timeval);
< x2 = va_arg(ap, u_long);
< }
< va_end(ap);
<
< if(ppi->axis_switched) {
< switch(plot_argc) {
< case 0:
< snprintf(fmt, sizeof(fmt), "%s%c", plot_cmd, NULL);
< DoPlot(pl, fmt);
< break;
< case 2:
< snprintf(fmt, sizeof(fmt), "%s %%u -%%s%c", plot_cmd, NULL);
< DoPlot(pl, fmt,
< x1, xp_timestamp(pl,t1));
< break;
< case 4:
< snprintf(fmt, sizeof(fmt), "%s %%u -%%s %%u -%%s%c", plot_cmd, NULL);
< DoPlot(pl, fmt,
< x1, xp_timestamp(pl,t1),
< x2, xp_timestamp(pl,t2));
< break;
< default:
< fprintf(stderr, "CallDoPlot: Illegal number of arguments (%d)\n", plot_argc);
< }
< }
< else {
< switch(plot_argc) {
< case 0:
< snprintf(fmt, sizeof(fmt), "%s%c", plot_cmd, NULL);
< DoPlot(pl, fmt);
< break;
< case 2:
< snprintf(fmt, sizeof(fmt), "%s %%s %%u%c", plot_cmd, NULL);
< DoPlot(pl, fmt,
< xp_timestamp(pl,t1), x1);
< break;
< case 4:
< snprintf(fmt, sizeof(fmt), "%s %%s %%u %%s %%u%c", plot_cmd, NULL);
< DoPlot(pl, fmt,
< xp_timestamp(pl,t1), x1,
< xp_timestamp(pl,t2), x2);
< break;
< default:
< fprintf(stderr, "CallDoPlot: Illegal number of arguments (%d)\n", plot_argc);
< }
< }
<
< return;
< }
<
< static void
< WritePlotHeader(
< PLOTTER pl)
< {
< MFILE *f = NULL;
< struct plotter_info *ppi;
<
< if (pl == NO_PLOTTER)
< return;
<
< if (pl > plotter_ix) {
< fprintf(stderr,"Illegal plotter: %d\n", pl);
< exit(-1);
< }
<
< ppi = &pplotters[pl];
<
< if ((f = ppi->fplot) == NULL)
< return;
<
< if(ppi->axis_switched) {
< /* Header for the Time Line Charts */
< Mfprintf(f,"%s %s\n", "unsigned", "dtime");
< }
< else {
< /* Header for all other plots */
< /* graph coordinates... */
< /* X coord is timeval unless graph_time_zero is true */
< /* Y is signed except when it's a sequence number */
< /* ugly hack -- unsigned makes the graphs hard to work with and is
< only needed for the time sequence graphs */
< /* suggestion by Michele Clark at UNC - make them double instead */
< Mfprintf(f,"%s %s\n",
< graph_time_zero?"dtime":"timeval",
< ((strcmp(ppi->ylabel,"sequence number") == 0)&&(!graph_seq_zero))?
< "double":"signed");
< }
<
< if (show_title) {
< if (xplot_title_prefix)
< Mfprintf(f,"title\n%s %s\n",
< ExpandFormat(xplot_title_prefix),
< ppi->title);
< else
< Mfprintf(f,"title\n%s\n", ppi->title);
< }
<
< Mfprintf(f,"xlabel\n%s\n", ppi->xlabel);
< Mfprintf(f,"ylabel\n%s\n", ppi->ylabel);
<
< /* Indicate that the header has now been written to the plotter file */
< ppi->header_done = TRUE;
<
< return;
< }
<
< /* Switch the x and y axis type (Needed for Time Line Charts. Default = FLASE) */
< void plotter_switch_axis(
< PLOTTER pl,
< Bool flag)
< {
< struct plotter_info *ppi = &pplotters[pl];
<
< ppi->axis_switched = flag;
< }
--------------------
DIFFS - tcptrace.h
--------------------
450,452d449
< /* Time Line Graph */
< PLOTTER tline_plotter;
<
634d630
< extern Bool graph_tline;
744,746c740
< void plotter_nothing(PLOTTER, timeval);
< void plotter_invisible(PLOTTER, timeval, u_long);
< void plotter_switch_axis(PLOTTER, Bool);
---
> void plotter_nothing(PLOTTER pl, struct timeval t);
991d984
< #define TLINE_FILE_EXTENSION "_tline.xpl"
--------------------
DIFFS - tcptrace.c
--------------------
107d106
< Bool graph_tline = FALSE;
531d529
< -L create time line graph[s]\n\
1800d1797
< graph_tline = TRUE;
1802,1804d1798
< case 'L': graph_tline = TRUE;
< fprintf(stderr, "\nWarning: You have chosen the option '-L' to plot Time Line Graphs.\n This option is yet under development and may not reflect accurate results.\n Please take a look at the file README.tline_graphs for more details.\n\n");
< break;
1927d1920
< case 'L': graph_tline = !TRUE; break;
1998a1992
> fprintf(stderr,"graph tsg: %s\n", BOOL2STR(graph_tsg));
2001,2004d1994
< fprintf(stderr,"graph tsg: %s\n", BOOL2STR(graph_tsg));
< fprintf(stderr,"graph segsize: %s\n", BOOL2STR(graph_segsize));
< fprintf(stderr,"graph owin: %s\n", BOOL2STR(graph_owin));
< fprintf(stderr,"graph tline: %s\n", BOOL2STR(graph_tline));
-----------------
DIFFS - trace.c
-----------------
74,75d73
< static int tline_left = 0; /* left and right time lines for the time line charts */
< static int tline_right = 0;
138,140d135
< char *a2b_seg_color = "green"; /* colors for segments on the time line chart */
< char *b2a_seg_color = "yellow";
<
470,521d464
< /* init time line graphs (Avinash, 2 July 2002) */
< ptp->a2b.tline_plotter = ptp->b2a.tline_plotter = NO_PLOTTER;
< if (graph_tline && !ptp->ignore_pair) {
< if (!ignore_non_comp || (SYN_SET(ptcp))) {
< /* We don't want the standard a2b type name so we will specify
< * a filename of type a_b when we call new_plotter.
< */
< char filename[25];
< snprintf(filename,sizeof(filename),"%s_%s",
< ptp->a2b.host_letter, ptp->a2b.ptwin->host_letter);
<
< snprintf(title,sizeof(title),"%s_==>_%s (time line graph)",
< ptp->a_endpoint, ptp->b_endpoint);
< /* We will keep both the plotters the same since we want all
< * segments going in either direction to be plotted on the same
< * graph
< */
< ptp->a2b.tline_plotter = ptp->b2a.tline_plotter =
< new_plotter(&ptp->a2b,filename,title,
< "segments",
< "relative time",
< TLINE_FILE_EXTENSION);
<
< /* Switch the x & y axis types.
< * The default is x - timeval, y - unsigned,
< * we need x - unsigned, y - dtime.
< * Both the plotters are the same so we will
< * only call this function once.
< */
< plotter_switch_axis(ptp->a2b.tline_plotter, TRUE);
<
< /* set graph zero points */
< plotter_nothing(ptp->a2b.tline_plotter, current_time);
< plotter_nothing(ptp->b2a.tline_plotter, current_time);
<
< /* Some graph initializations
< * Generating a drawing space between x=0-100.
< * The time lines will be at x=40 for source, x=60 for destination.
< * Rest of the area on either sides will be used to print segment
< * information.
< *
< * seg info |----->|
< * |<-----| seg info
< */
< tline_left = 40;
< tline_right = 60;
< plotter_invisible(ptp->a2b.tline_plotter, current_time, 0);
< plotter_invisible(ptp->a2b.tline_plotter, current_time, 100);
< }
< }
<
<
1159d1101
< PLOTTER tlinepl;
1412,1414d1353
<
< /* plotter shorthand (NOTE: we are using one plotter for both directions) */
< tlinepl = thisdir->tline_plotter;
1415a1355
>
1726,1861c1666
< }
<
< /* graph time line */
< /* Since the axis types have been switched specially for these graphs,
< * x is actually used as y and y as x
< * -Avinash.
< *
< * NOTE: This code is lacking about a 1000 lines of intellegence that is needed
< * ----- to draw these graphs correctly. I have left it in here as the starting
< * point to work on. Whoever is working on this project would want to clean
< * up this file trace.c (based on the patches in the README.tline_graphs
< * file), and continue development as a seperate module. We started this
< * project thinking it is easy to draw these graphs, and then realized that
< * it is infact quite a complicated task. All this works with a -L option at
< * command line.
< */
< if (tlinepl != NO_PLOTTER) {
< char buf1[200];
< char buf2[50];
< static seqnum a2b_first_seqnum = 0;
< static seqnum b2a_first_seqnum = 0;
< /* 1/3rd rtt. Since we have the timestamps only on one side, we calculate the
< * arrrival/departure time of the segments on the other side by adding/subtracting
< * 1/3rd rtt. We assume that it takes 1/3rd time for the segment to travel in
< * either direction, and 1/3rd time for processing.
< * We also skew the calculated times so that the acks are not seen before the
< * segments actually arrive.
< */
< struct timeval one3rd_rtt;
< struct timeval copy_current_time;
< /* Make a copy of the current time (Needed for calculations) */
< copy_current_time.tv_sec = current_time.tv_sec;
< copy_current_time.tv_usec = current_time.tv_usec;
< /* Compute 1/3rd rtt */
< one3rd_rtt.tv_sec = 0;
< one3rd_rtt.tv_usec = thisdir->rtt_last/3;
< /* Adjust seconds and microseconds */
< while(one3rd_rtt.tv_usec >= US_PER_SEC) {
< one3rd_rtt.tv_usec -= US_PER_SEC;
< one3rd_rtt.tv_sec += 1;
< }
<
< /* Initializations */
< memset(&buf1, 0, sizeof(buf1));
< memset(&buf2, 0, sizeof(buf2));
<
< /* Segment information */
< /* Check the flags */
< if(SYN_SET(ptcp))
< strncat(buf1, "SYN ", 4);
< if(FIN_SET(ptcp))
< strncat(buf1, "FIN ", 4);
< if(RESET_SET(ptcp))
< strncat(buf1, "RST ", 4);
< if(PUSH_SET(ptcp))
< strncat(buf1, "PSH ", 4);
< if(URGENT_SET(ptcp))
< strncat(buf1, "URG ", 4);
<
<
< /* Write the sequence numbers */
< if(dir == A2B) {
< /* Use relative sequence numbers after the first segment in either direction */
< snprintf(buf2, sizeof(buf2), "%u:%u(%u) %c", (start - a2b_first_seqnum),
< (end - a2b_first_seqnum), (end-start), NULL);
< strncat(buf1, buf2, strlen(buf2));
< if(a2b_first_seqnum == 0 && !SYN_SET(ptcp)) // Don't use relative sequence numbers until handshake is complete.
< a2b_first_seqnum = thisdir->min_seq;
< }else if(dir == B2A) {
< /* Use relative sequence numbers after the first segment in either direction */
< snprintf(buf2, sizeof(buf2), "%u:%u(%u) %c", (start - b2a_first_seqnum),
< (end - b2a_first_seqnum), (end-start), NULL);
< strncat(buf1, buf2, strlen(buf2));
< if(b2a_first_seqnum == 0 && !SYN_SET(ptcp))
< b2a_first_seqnum = thisdir->min_seq;
< }
<
< /* Acknowledgements */
< if(ACK_SET(ptcp)) {
< memset(&buf2, 0, sizeof(buf2));
< if(dir == A2B)
< snprintf(buf2, sizeof(buf2), "ack %u %c", (th_ack - b2a_first_seqnum), NULL);
< else if(dir == B2A)
< snprintf(buf2, sizeof(buf2), "ack %u %c", (th_ack - a2b_first_seqnum), NULL);
< strncat(buf1, buf2, strlen(buf2));
< }
<
< /* Advertised Window */
< memset(&buf2, 0, sizeof(buf2));
< snprintf(buf2, sizeof(buf2), "win %u %c", eff_win,NULL);
< strncat(buf1, buf2, strlen(buf2));
<
< /* Retransmits */
< if(retrans) {
< memset(&buf2, 0, sizeof(buf2));
< snprintf(buf2, sizeof(buf2), "R %c", NULL);
< strncat(buf1, buf2, strlen(buf2));
< }
<
< /* Hardware Duplicates */
< if(hw_dup) {
< memset(&buf2, 0, sizeof(buf2));
< snprintf(buf2, sizeof(buf2), "HD %c", NULL);
< strncat(buf1, buf2, strlen(buf2));
< }
<
< /* Draw the segment ------>/<------- */
< if(dir == A2B) {
< tv_add(©_current_time, one3rd_rtt);
< plotter_line(tlinepl, ptp_save->first_time, tline_left, copy_current_time, tline_left);
< plotter_line(tlinepl, ptp_save->first_time, tline_right, copy_current_time, tline_right);
< if(SYN_SET(ptcp)|| FIN_SET(ptcp) || RESET_SET(ptcp))
< plotter_perm_color(tlinepl, synfin_color);
< else
< plotter_perm_color(tlinepl, a2b_seg_color);
< plotter_line(tlinepl, current_time, tline_left, copy_current_time, tline_right);
< plotter_rarrow(tlinepl, copy_current_time, tline_right);
< plotter_perm_color(tlinepl, default_color);
< plotter_text(tlinepl, current_time, tline_left, "l", buf1);
< }
< else if(dir == B2A) {
< tv_sub(©_current_time, one3rd_rtt);
< plotter_line(tlinepl, ptp_save->first_time, tline_left, copy_current_time, tline_left);
< plotter_line(tlinepl, ptp_save->first_time, tline_right, copy_current_time, tline_right);
< if(SYN_SET(ptcp)|| FIN_SET(ptcp) || RESET_SET(ptcp))
< plotter_perm_color(tlinepl, synfin_color);
< else
< plotter_perm_color(tlinepl, b2a_seg_color);
< plotter_line(tlinepl, copy_current_time, tline_right, current_time, tline_left);
< plotter_larrow(tlinepl, current_time, tline_left);
< plotter_perm_color(tlinepl, default_color);
< plotter_text(tlinepl, copy_current_time, tline_right, "r", buf1);
< }
<
< }
<
---
> }