File: README.tcp_plots

package info (click to toggle)
xplot-xplot.org 0.90.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,884 kB
  • sloc: ansic: 4,311; perl: 1,087; sh: 152; makefile: 112
file content (98 lines) | stat: -rw-r--r-- 2,424 bytes parent folder | download | duplicates (4)
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
The following C-like psuedocode should help you make tcp plots like
those in the MIT/LCS/TR-494.  The code below is simultaneously making
two different plots, one plot for each direction that data can be
carried on a tcp connection.  In addition to emulating the pseudo code
below, you'll have to add some boilerplate to the plotter files.  See
demo.1 for an example tcp plot.

static  struct last {
  unsigned long ack;
  unsigned long windowend;
  struct timeval time;
} a, b;

typedef struct {
  unsigned long  a_address;
  unsigned long  b_address;
  unsigned short a_port;
  unsigned short b_port;
} tcp_pair;

tcp_pair tp;

PLOTTER topl;
PLOTTER frompl;
PLOTTER abpl;
PLOTTER bapl;

for each tcp packet in order {
  struct ip_header *iph;
  struct tcp_header *tcph;
  tcp_pair ttp;
  unsigned int tcp_length;
  unsigned int tcp_data_length;
  unsigned int start;
  unsigned int end;
  struct timeval time;
    
  iph = get_pointer_to_ip_header;
  ttp = iph2ttp(iph);

  /* figure out which direction this packet is going */
  if (tp.a_address == ttp.a_address && tp.a_port == ttp.a_port) {
    topl = bapl;
    frompl = abpl;
    r = &a;
  } else {
    topl = abpl;
    frompl = bapl;
    r = &b;
  }
    
  tcph = iph2tcph(iph);
  
  time = nh->nh_timestamp;
    
  tcp_length = ntohs(iph->total_length) - (4 * iph->ihl);
  tcp_data_length =
    tcp_length - (4 * tcph->data_offset) + tcph->syn + tcph->fin;
  
  start = ntohl(tcph->sequence_number);
  end = start + tcp_data_length;
  
  /* draw the packet */

  plotter_darrow(frompl, time, start);
  plotter_uarrow(frompl, time, end);
  plotter_line(frompl, time, start, time, end);
    
  /* draw the ack and win in the other plotter */
  if (tcph->ack) {
    unsigned int ack;
    unsigned int win;
    unsigned int winend;
    ack = ntohl(tcph->acknowledgment_number);
    win = ntohs(tcph->window);
    winend = ack + win;
      
    if (r->time.tv_sec != -1) {
      plotter_line(topl, r->time, r->ack, time, r->ack);
      if (r->ack != ack) {
	plotter_line(topl, time, r->ack, time, ack);
      } else {
	plotter_dtick(topl, time, ack);
      }
      if (plotwindow) {
	plotter_line(topl, r->time, r->windowend, time, r->windowend);
	if (r->windowend != winend) {
	  plotter_line(topl, time, r->windowend, time, winend);
	} else {
	  plotter_utick(topl, time, winend);
	}
      }
    }
    r->time = time;
    r->ack = ack;
    r->windowend = winend;
  }
}