Revision 19d6b4ca

View differences:

measures.c
22 22
	int n_mhs;
23 23
} nodeID;
24 24

  
25
static MonHandler chunk_dup, chunk_playout, neigh_size, chunk_receive, chunk_send, offer_accept, chunk_hops, chunk_delay;
25
static MonHandler chunk_dup, chunk_playout, neigh_size, chunk_receive, chunk_send, offer_accept, chunk_hops, chunk_delay, playout_delay;
26 26
static MonHandler rx_bytes_chunk_per_sec, tx_bytes_chunk_per_sec, rx_bytes_sig_per_sec, tx_bytes_sig_per_sec;
27 27
static MonHandler rx_chunks, tx_chunks;
28 28

  
......
53 53
/*
54 54
 * Register playout/loss of a chunk before playout
55 55
*/
56
void reg_chunk_playout(bool b)
56
void reg_chunk_playout(int id, bool b, uint64_t timestamp)
57 57
{
58
	struct timeval tnow;
59

  
58 60
	if (!chunk_playout && b) {	//don't count losses before the first arrived chunk
59 61
		enum stat_types st[] = {AVG, SUM, RATE};
60 62
		add_measure(&chunk_playout, GENERIC, 0, 120, "ChunksPlayed", st, sizeof(st)/sizeof(enum stat_types), NULL, MSG_TYPE_ANY);	//[chunks]
61 63
	}
62 64
	monNewSample(chunk_playout, b);
65

  
66
	if (!playout_delay) {
67
		enum stat_types st[] = {WIN_AVG, WIN_VAR};
68
		add_measure(&playout_delay, GENERIC, 0, 120, "PlayoutDelay", st, sizeof(st)/sizeof(enum stat_types), NULL, MSG_TYPE_ANY);	//[peers]
69
	}
70
	gettimeofday(&tnow, NULL);
71
	monNewSample(playout_delay, tnow.tv_usec + tnow.tv_sec * 1000000ULL - timestamp);
63 72
}
64 73

  
65 74
/*
measures.h
13 13
double get_average_lossrate(struct  nodeID**id, int len);
14 14
int get_hopcount(struct nodeID *id);
15 15
void reg_chunk_duplicate();
16
void reg_chunk_playout(bool b);
16
void reg_chunk_playout(int id, bool b, uint64_t timestamp);
17 17
void reg_neigh_size(int s);
18 18
void reg_chunk_receive(int id, uint64_t timestamp, int hopcount);
19 19
void reg_chunk_send(int id);
output.c
23 23
  void *data;
24 24
  int size;
25 25
  int id;
26
  uint64_t timestamp;
26 27
};
27 28
static struct outbuf *buff;
28 29

  
......
75 76
  buff[i].data = NULL;
76 77
  dprintf("Next Chunk: %d -> %d\n", next_chunk, buff[i].id + 1);
77 78
#ifdef MONL
78
  reg_chunk_playout(true);
79
  reg_chunk_playout(buff[i].id, true, buff[i].timestamp);
79 80
#endif
80 81
  next_chunk = buff[i].id + 1;
81 82
}
......
122 123
        buffer_free(i % buff_size);
123 124
      } else {
124 125
#ifdef MONL
125
        reg_chunk_playout(false);
126
        reg_chunk_playout(c->id, false, c->timestamp);
126 127
#endif
127 128
        next_chunk++;
128 129
      }
......
136 137
    dprintf("\tOut Chunk[%d] - %d: %s\n", c->id, c->id % buff_size, c->data);
137 138
    chunk_write(c->id, c->data, c->size);
138 139
#ifdef MONL
139
    reg_chunk_playout(true);
140
    reg_chunk_playout(c->id, true, c->timestamp);
140 141
#endif
141 142
    next_chunk++;
142 143
    buffer_flush(next_chunk);
......
159 160
    memcpy(buff[c->id % buff_size].data, c->data, c->size);
160 161
    buff[c->id % buff_size].size = c->size;
161 162
    buff[c->id % buff_size].id = c->id;
163
    buff[c->id % buff_size].timestamp = c->timestamp;
162 164
  }
163 165
}

Also available in: Unified diff