Revision 80f4c362

View differences:

ed.c
9 9
#include "ed.h"
10 10

  
11 11
FILE *resfile;
12
FILE *delayfile;
12 13
FILE *statusfile;
13 14

  
14 15
struct ed_simulator {
......
128 129
		p->chunks[idx]->completed = event_scheduler_elapsed_time(eds->sched);
129 130
//		fprintf(stderr,"[DEBUG] peer %d receives chunk %d ", p->id, chunk);
130 131
		ed_simulator_update_chunk_delay(eds, chunk);
132
		if (delayfile) {
133
		    fprintf(delayfile, "%f,%d,%d,%f\n", ed_simulator_time(eds), p->id, p->chunks[idx]->chunk, ed_simulator_time(eds) - p->chunks[idx]->chunk);
134
		    fflush(delayfile);
135
		}
131 136
		if (eds->chunks[chunk].received == eds->num_peers && resfile) 
132 137
		{
133 138
		    fprintf(resfile, "Chunk %d received at %f in %f\n", p->chunks[idx]->chunk, ed_simulator_time(eds), ed_simulator_time(eds) - p->chunks[idx]->chunk);
sssim.c
26 26

  
27 27
static struct peer *peers;
28 28
extern FILE *resfile;
29
extern FILE *delayfile;
29 30
extern FILE *statusfile;
30 31
static FILE *statsfile;
31 32
static FILE *graphfile;
......
52 53
  printf("\t-n <number of peers>:\t\tSet the number of peers\n");
53 54
  printf("\t-t <trace file>\n");
54 55
  printf("\t-r <results file>:\t\t(dynamically generated during simulation)\n");
56
  printf("\t-d <delay file>:\t\t(dynamically generated during simulation)\n");
55 57
  printf("\t-p <status file>\n");
56 58
  printf("\t-P:\t\t\t\tPrint the neighbourhoods\n");
57 59
  printf("\t-S <stats file>\n");
......
67 69
{
68 70
  int o;
69 71
  
70
  while ((o = getopt(argc, argv, "c:eo:n:t:r:s:p:S:b:T:g:G:hP")) != -1) {
72
  while ((o = getopt(argc, argv, "d:c:eo:n:t:r:s:p:S:b:T:g:G:hP")) != -1) {
71 73
    switch(o) {
72 74
      case 'e':
73 75
        event_driven = 1;
......
94 96
      case 'r':
95 97
        resfile = fopen(optarg, "w");
96 98
        break;
99
      case 'd':
100
        delayfile = fopen(optarg, "w");
101
        break;
97 102
      case 'p':
98 103
        statusfile = fopen(optarg, "w");
99 104
        break;
......
174 179
    if (graphfile) {
175 180
      graph_dotprint(graphfile, &source, peers, n);
176 181
    }
182
    if (delayfile) {
183
	fprintf(delayfile, "Time,Receiver,Chunk,Delay\n");
184
	fflush(delayfile);
185
    }
177 186
    printf("Buf Size: %d\n", buf_size);
178 187
    if(event_driven)
179 188
			ch = ed_loop(peers, num_peers, num_chunks, ts);
......
195 204
      per_node_delay_analysis(statsfile,  ch, num_chunks);
196 205
    }
197 206

  
207
    if (delayfile)
208
	    fclose(delayfile);
209

  
198 210
  return 0;
199 211
}
td.c
8 8
#include "td.h"
9 9

  
10 10
FILE *resfile;
11
FILE *delayfile;
11 12
FILE *statusfile;
12 13
static int ts;
13 14
static struct peer *peers;
......
67 68
        peers[p].recv_chunks[idx] = NULL;
68 69
        chunks[peers[p].chunks[idx]->chunk].avg_delay += t - peers[p].chunks[idx]->chunk;
69 70
        chunks[peers[p].chunks[idx]->chunk].max_delay = max(chunks[peers[p].chunks[idx]->chunk].max_delay, t - peers[p].chunks[idx]->chunk);
71
        if (delayfile) {
72
            fprintf(delayfile, "%d,%d,%d,%d\n", t, p, peers[p].chunks[idx]->chunk,  t - peers[p].chunks[idx]->chunk);
73
            fflush(delayfile);
74
	}
70 75
        if (chunks[peers[p].chunks[idx]->chunk].received == num_peers) {
71 76
          if (resfile) {
72 77
            fprintf(resfile, "Chunk %d received at %d in %d\n", peers[p].chunks[idx]->chunk, t, t - peers[p].chunks[idx]->chunk);

Also available in: Unified diff