rude-patch 15.4 KB
Newer Older
1
2
3
4
5
6
7
8
Index: configure
===================================================================
RCS file: /flux/CVS/emulab-rude/configure,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** configure	27 Jun 2006 17:50:14 -0000	1.1.1.1
--- configure	27 Jun 2006 18:26:14 -0000	1.2
9
***************
10
*** 2062,2068 ****
11
12
13
14
  ###################
  # Make it happen. #
  ###################
! CFLAGS="$CFLAGS -I../include"
15
16
17
18
  trap '' 1 2 15
  cat > confcache <<\EOF
  # This file is a shell script that caches the results of configure
--- 2062,2068 ----
19
20
21
22
  ###################
  # Make it happen. #
  ###################
! CFLAGS="$CFLAGS -I\$(srcdir)/../include -I../include"
23
24
25
26
27
28
29
30
31
  trap '' 1 2 15
  cat > confcache <<\EOF
  # This file is a shell script that caches the results of configure
Index: autoconf/configure.in
===================================================================
RCS file: /flux/CVS/emulab-rude/autoconf/configure.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
32
33
*** autoconf/configure.in	27 Jun 2006 17:50:15 -0000	1.1.1.1
--- autoconf/configure.in	27 Jun 2006 18:26:17 -0000	1.2
34
***************
35
*** 121,126 ****
36
37
38
39
  ###################
  # Make it happen. #
  ###################
! CFLAGS="$CFLAGS -I../include"
40
41
42
  AC_OUTPUT(Makefile:autoconf/Makefile.in rude/Makefile crude/Makefile, \
  	  echo timestamp > include/stamp.h)
--- 121,126 ----
43
44
45
46
  ###################
  # Make it happen. #
  ###################
! CFLAGS="$CFLAGS -I\$(srcdir)/../include -I../include"
47
48
49
50
51
52
  AC_OUTPUT(Makefile:autoconf/Makefile.in rude/Makefile crude/Makefile, \
  	  echo timestamp > include/stamp.h)
Index: crude/main.c
===================================================================
RCS file: /flux/CVS/emulab-rude/crude/main.c,v
retrieving revision 1.1.1.1
53
54
retrieving revision 1.3
diff -c -r1.1.1.1 -r1.3
55
*** crude/main.c	27 Jun 2006 17:50:15 -0000	1.1.1.1
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--- crude/main.c	28 Jul 2006 23:55:12 -0000	1.3
***************
*** 35,42 ****
--- 35,44 ----
  #include <sys/stat.h>
  #include <sys/socket.h>
  #include <sys/time.h>
+ #ifndef __CYGWIN__
  #include <sched.h>
  #include <sys/mman.h>
+ #endif /* ifndef__CYGWIN__ */
  #include <arpa/inet.h>
  #include <netinet/in.h>
  #include <limits.h>
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
*** 106,112 ****
--- 108,116 ----
    long temp1          = 0;
    int ps_flag         = 0;
    struct sigaction action;
+ #ifndef __CYGWIN__
    struct sched_param p;
+ #endif /* ifndef__CYGWIN__ */
    char *sptr, *eptr;
    struct flow_stat *newflows;
  
***************
*** 205,212 ****
--- 209,220 ----
        retval = -2;
     }
     if(user_id != 0){
+ #ifndef __CYGWIN__
        fprintf(stderr,"crude: must be root to set the priority level\n");
        retval = -2;
+ #else /* ifndef__CYGWIN__ */
+       fprintf(stderr,"crude: priority level is not supported on Cygwin\n");
+ #endif /* ifndef__CYGWIN__ */
     }
        } else {
     RUDEBUG1("crude: invalid commandline arguments!\n");
***************
*** 288,302 ****
--- 296,315 ----
    /* (if retval < 0 -> ERROR or/and EXIT IMMEDIATELY) */
    if(retval < 0){ goto crude_exit; }
   
+ #ifndef __CYGWIN__
    /*
     * If this process is owned by root we can do some tricks to
     * improve the performance... (the -P option)
107
108
109
110
111
112
113
114
115
116
117
118
119
120
     */
    if((user_id == 0) && (priority > 0)){
      /* Try to lock the memory to avoid paging delays */
+ #ifdef HAVE_MUNLOCKALL
      if(mlockall(MCL_CURRENT | MCL_FUTURE) < 0){
        RUDEBUG1("crude: memory lock failed: %s\n", strerror(errno));
      }
+ #else
+     RUDEBUG1("crude: memory lock unsupported\n");
+ #endif
  
      /* Switch to Round-Robin-Real-Time Scheduling */
      p.sched_priority = priority;
***************
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
*** 307,312 ****
--- 320,326 ----
      }
      RUDEBUG7("crude: program priority set to %d\n", p.sched_priority);
    }                                                                             
+ #endif /* ifndef__CYGWIN__ */
   
    /* Activate the signal handler(s) */
    memset(&action, 0, sizeof(struct sigaction));
***************
*** 332,337 ****
--- 346,352 ----
  
   crude_exit:
    if (retval >= 0 && nflows > 0) { ps_flag = 1; }
+ #ifndef __CYGWIN__
    /*
     * Restore the tweaked settings...
     */
***************
*** 346,354 ****
        RUDEBUG7("crude: program priority restored\n");
      }
  
      /* Release the locked memory */
      munlockall();
!   }                                                                             
  
    if(ps_flag){ print_stats(); }
    if(main_file > 0){ close(main_file); }
--- 361,372 ----
152
153
154
155
156
157
        RUDEBUG7("crude: program priority restored\n");
      }
  
+ #ifdef HAVE_MUNLOCKALL
      /* Release the locked memory */
      munlockall();
158
159
160
! #endif
!   }
! #endif /* ifndef__CYGWIN__ */
161
162
  
    if(ps_flag){ print_stats(); }
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
    if(main_file > 0){ close(main_file); }
***************
*** 384,392 ****
--- 402,413 ----
   */
  void crude_handler(int value)
  {
+ #ifndef __CYGWIN__
    struct sched_param pri;
+ #endif /* ifndef__CYGWIN__ */
    RUDEBUG7("\ncrude: SIGNAL caught - exiting...\n");
   
+ #ifndef __CYGWIN__
    /* Check & restore process priority */
    if((getuid() == 0) && (sched_getscheduler(0) != SCHED_OTHER)){
      pri.sched_priority = 0;
***************
*** 396,401 ****
--- 417,423 ----
        RUDEBUG7("crude_handler: crude priority restored\n");
      }
    }                                                                             
+ #endif /* ifndef__CYGWIN__ */
  
    if(nflows > 0){ print_stats(); }
    if(main_file > 0){ close(main_file); }
189
190
191
192
193
194
195
196
197
198
***************
*** 663,670 ****
  
      /* print average delay as sign and absolute value */
      if ( (sec < 0) || (usec < 0) ) {
!       sec  = llabs( sec );
!       usec = llabs( usec );
        printf("Delay: average = -%lld.%06llu   ", sec, usec);
      } else {
        printf("Delay: average = %lld.%06llu   ", sec, usec);
199
--- 685,692 ----
200
201
202
203
204
205
206
207
  
      /* print average delay as sign and absolute value */
      if ( (sec < 0) || (usec < 0) ) {
!       if (sec < 0) sec *= -1;
!       if (usec < 0) usec *= -1;
        printf("Delay: average = -%lld.%06llu   ", sec, usec);
      } else {
        printf("Delay: average = %lld.%06llu   ", sec, usec);
208
209
210
211
212
213
214
215
Index: include/rude.h
===================================================================
RCS file: /flux/CVS/emulab-rude/include/rude.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** include/rude.h	27 Jun 2006 17:50:15 -0000	1.1.1.1
--- include/rude.h	27 Jun 2006 18:22:18 -0000	1.2
216
217
218
219
220
221
222
223
224
225
***************
*** 24,29 ****
--- 24,30 ----
  #ifndef _RUDE_H
  #define _RUDE_H
  
+ #include <sys/types.h>
  #include <netinet/in.h>  /* for struct sockaddr_in */
  #include <sys/time.h>    /* for struct timeval     */
  
226
227
228
229
Index: rude/flow_txmit.c
===================================================================
RCS file: /flux/CVS/emulab-rude/rude/flow_txmit.c,v
retrieving revision 1.1.1.1
230
231
retrieving revision 1.4
diff -c -r1.1.1.1 -r1.4
232
*** rude/flow_txmit.c	27 Jun 2006 17:50:14 -0000	1.1.1.1
233
234
235
236
237
238
239
240
241
242
243
244
245
246
--- rude/flow_txmit.c	28 Jul 2006 23:55:13 -0000	1.4
***************
*** 29,36 ****
--- 29,38 ----
  #include <string.h>
  #include <unistd.h>
  #include <errno.h>
+ #ifndef __CYGWIN__
  #include <sched.h>
  #include <sys/mman.h>
+ #endif /* ifndef__CYGWIN__ */
  #include <sys/time.h>
  #include <sys/types.h>
  #include <sys/socket.h>
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
***************
*** 43,58 ****
  extern struct udp_data *data;
  extern char            *buffer;
  
  
  /*
!  * wait_for_xmit(): Wait for certain period of time in busy-loop
   */
  __inline__ void wait_for_xmit(struct timeval *target, struct timeval *now)
  {
    while(1){
-     gettimeofday(now,NULL);
      if(timercmp(now,target,<)){
!       /* FIXME: check if the timegap is large => use [u | nano]sleep() */
        continue;
      }
      return;
265
--- 45,119 ----
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
  extern struct udp_data *data;
  extern char            *buffer;
  
+ static int usecpertick = 0;
  
  /*
!  * init_wait(): set the resolution of the clock.
!  * We use this in wait_for_xmit(), if the desired sleep time is at least
!  * twice the clock resolution, we sleep rather than spin.
!  * XXX this could be determined dynamically.
!  */
! void wait_init(int tickspersec)
! {
!   if (tickspersec < 1000000)
!     usecpertick = 1000000 / tickspersec;
! }
! 
! #ifdef WAITSTATS
! static unsigned int calls;
! static unsigned int toolong;
! static unsigned long long toolongby;
! #endif
! 
! void wait_finish(void)
! {
! #ifdef WAITSTATS
!   printf("%d calls, %d slept too long (by %dusec ave)\n",
! 	 calls, toolong, toolongby/toolong);
! #endif
! }
! 
! /*
!  * wait_for_xmit(): Wait for certain period of time
   */
  __inline__ void wait_for_xmit(struct timeval *target, struct timeval *now)
  {
+   gettimeofday(now,NULL);
+   if (usecpertick) {
+     struct timeval dtv;
+     int usec;
+ 
+     timersub(target,now,&dtv);
+     usec = dtv.tv_sec * 1000000 + dtv.tv_usec;
+     if (usec >= usecpertick*2) {
+       int res = usec % usecpertick;
+ 
+       /* empirical voodoo */
+       if (res == 0) res = 1;
+ 
+       usec -= res;
+       dtv.tv_sec = usec / 1000000;
+       dtv.tv_usec = usec % 1000000;
+       select(0,NULL,NULL,NULL,&dtv);
+       gettimeofday(now,NULL);
+ 
+ #ifdef WAITSTATS
+       /* XXX fernow stats */
+       calls++;
+       if (timercmp(now,target,>)) {
+         toolong++;
+         timersub(now,target,&dtv);
+         usec = dtv.tv_sec * 1000000 + dtv.tv_usec;
+         toolongby += usec;
+         return;
+       }
+ #endif
+     }
+   }
+ 
    while(1){
      if(timercmp(now,target,<)){
!       gettimeofday(now,NULL);
        continue;
      }
      return;
341
342
***************
*** 78,83 ****
343
--- 139,148 ----
344
345
346
347
348
349
350
351
352
353
354
355
356
357
    data->sequence_number = htonl(flow->sequence_nmbr);
    wait_for_xmit(&flow->next_tx, &now);
  
+   /* Emulab hack: this can happen for a final zero transmission */
+   if (p->rate == 0)
+     return;
+ 
    /* ...and fill in the rest of the data */
    data->tx_time_seconds  = htonl(now.tv_sec);
    data->tx_time_useconds = htonl(now.tv_usec);
Index: rude/main.c
===================================================================
RCS file: /flux/CVS/emulab-rude/rude/main.c,v
retrieving revision 1.1.1.1
358
359
retrieving revision 1.3
diff -c -r1.1.1.1 -r1.3
360
*** rude/main.c	27 Jun 2006 17:50:14 -0000	1.1.1.1
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
--- rude/main.c	28 Jul 2006 23:55:13 -0000	1.3
***************
*** 31,42 ****
  #include <string.h>
  #include <unistd.h>
  #include <fcntl.h>
- #include <sys/mman.h>
  #include <sys/time.h>
  #include <sys/wait.h>
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <sched.h>
  #include <arpa/inet.h>
  #include <netinet/in.h>
  
--- 31,44 ----
  #include <string.h>
  #include <unistd.h>
  #include <fcntl.h>
  #include <sys/time.h>
  #include <sys/wait.h>
  #include <sys/types.h>
  #include <sys/socket.h>
+ #ifndef __CYGWIN__
  #include <sched.h>
+ #include <sys/mman.h>
+ #endif /* ifndef__CYGWIN__ */
  #include <arpa/inet.h>
  #include <netinet/in.h>
  
***************
*** 82,88 ****
--- 84,92 ----
    int retval            = 0;
    uid_t user_id         = getuid();
    struct sigaction action;
+ #ifndef __CYGWIN__
    struct sched_param p;
+ #endif /* ifndef__CYGWIN__ */
  
    printf("rude version %s, Copyright (C) 1999 Juha Laine and Sampo Saaristo\n"
  	 "rude comes with ABSOLUTELY NO WARRANTY!\n"
403
404
405
406
407
408
409
410
411
***************
*** 95,101 ****
      exit(1);
    }
  
!   while(((opt_ret=getopt(argc,argv,"s:P:hv")) != EOF) && (retval == 0)){
      switch(opt_ret){
      case 'v':
        if((optind == 2) && (argc == 2)){
412
--- 99,105 ----
413
414
415
416
417
418
419
420
      exit(1);
    }
  
!   while(((opt_ret=getopt(argc,argv,"s:P:hvC:")) != EOF) && (retval == 0)){
      switch(opt_ret){
      case 'v':
        if((optind == 2) && (argc == 2)){
***************
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
*** 138,145 ****
--- 142,153 ----
  	  retval = -2;
  	}
  	if(user_id != 0){
+ #ifndef __CYGWIN__
  	  fprintf(stderr,"rude: must be root to set the priority level\n");
  	  retval = -2;
+ #else /* ifndef__CYGWIN__ */
+ 	  fprintf(stderr,"rude: priority level is not supported on Cygwin\n");
+ #endif /* ifndef__CYGWIN__ */
  	}
        } else {
  	RUDEBUG1("rude: invalid commandline arguments!\n");
***************
436
*** 147,152 ****
437
--- 155,164 ----
438
439
440
441
442
443
444
445
446
447
448
        }
        break;
  
+     case 'C':
+       wait_init(atoi(optarg));
+       break;
+ 
      default:
        usage(argv[0]);
        retval = -2;
***************
449
450
451
452
453
454
455
456
457
*** 198,212 ****
--- 210,229 ----
      goto rude_exit1;
    }
  
+ #ifndef __CYGWIN__
    /*
     * If this process is owned by root we can do some tricks to
     * improve the performance... (the -P option)
458
459
460
461
462
463
464
465
466
467
468
469
470
471
     */
    if((user_id == 0) && (priority > 0)){
      /* Try to lock the memory to avoid paging delays */
+ #ifdef HAVE_MUNLOCKALL
      if(mlockall(MCL_CURRENT | MCL_FUTURE) < 0){
        RUDEBUG1("rude: memory lock failed: %s\n", strerror(errno));
      }
+ #else
+     RUDEBUG1("rude: memory lock unsupported\n");
+ #endif
  
      /* Switch to Round-Robin-Real-Time Scheduling */
      p.sched_priority = priority;
***************
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
*** 217,222 ****
--- 234,240 ----
      }
      RUDEBUG7("rude: program priority set to %d\n", p.sched_priority);
    }
+ #endif /* ifndef__CYGWIN__ */
  
    /*
     * All is fine - start looping & transmitting
***************
*** 229,234 ****
--- 247,253 ----
  
   rude_exit:
  
+ #ifndef __CYGWIN__
    /*
     * Restore the tweaked settings...
     */
***************
*** 242,250 ****
--- 261,272 ----
494
495
496
497
498
499
500
501
        RUDEBUG7("rude: program priority restored\n");
      }
  
+ #ifdef HAVE_MUNLOCKALL
      /* Release the locked memory */
      munlockall();
+ #endif
    }
502
+ #endif /* ifndef__CYGWIN__ */
503
504
  
   rude_exit1:
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
  
***************
*** 262,270 ****
--- 284,295 ----
  void rude_handler(int value)
  {
    int ret_val = (value * (-1));
+ #ifndef __CYGWIN__
    struct sched_param pri;
+ #endif /* ifndef__CYGWIN__ */
    RUDEBUG7("\nrude_handler(): receiver SIGNAL %d - clean-up & exit\n",value);
  
+ #ifndef __CYGWIN__
    /* Check & restore process priority */
    if((getuid() == 0) && (sched_getscheduler(0) != SCHED_OTHER)){
      pri.sched_priority = 0;
521
522
***************
*** 275,281 ****
523
--- 300,309 ----
524
525
526
527
528
529
      }
    }
  
+ #ifdef HAVE_MUNLOCKALL
    munlockall();
+ #endif
530
+ #endif /* ifndef__CYGWIN__ */
531
532
533
534
535
    clean_up();
    exit(ret_val);
  } /* main() */
***************
*** 414,419 ****
536
--- 442,448 ----
537
538
539
540
541
542
543
      }
      flow = flow->next;
    }
+   wait_finish();
    return;
  } /* print_results() */
  
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
Index: rude/parse.c
===================================================================
RCS file: /flux/CVS/emulab-rude/rude/parse.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** rude/parse.c	27 Jun 2006 17:50:14 -0000	1.1.1.1
--- rude/parse.c	27 Jun 2006 18:28:48 -0000	1.2
***************
*** 688,694 ****
--- 688,696 ----
        /* NEW in 0.50: Enable flow "stop" - ZERO transmission rate... */
        if(temp->params.cbr.rate == 0){
  	temp->next_tx = temp->flow_stop;
+ 	/* Emulab hack: make final zero transmission actually happen
  	temp->next_tx.tv_sec++;
+ 	*/
        }
        break;
      case(TRACE):
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
Index: rude/rude.8
===================================================================
RCS file: /flux/CVS/emulab-rude/rude/rude.8,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** rude/rude.8	27 Jun 2006 17:50:15 -0000	1.1.1.1
--- rude/rude.8	28 Jul 2006 23:55:13 -0000	1.2
***************
*** 35,41 ****
  The script 
  .IB file 
  describing the flows to be sent by the rude program. 
! See ../rude/DOC/example.cfg, for an example. 
  .IP \fB\-h 
  Print a short help.
  .IP \fB\-v
--- 35,41 ----
  The script 
  .IB file 
  describing the flows to be sent by the rude program. 
! See /usr/share/doc/rude/DOC/example.cfg, for an example. 
  .IP \fB\-h 
  Print a short help.
  .IP \fB\-v