]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
SEC_TO_USEC,USEC_TO_NSEC, MSEC_TO_USEC makra pridany
authorMartin Molnar <molnar@sum.(none)>
Mon, 3 Dec 2007 16:51:35 +0000 (17:51 +0100)
committerMartin Molnar <molnar@sum.(none)>
Mon, 3 Dec 2007 16:51:35 +0000 (17:51 +0100)
wme_test/common.h
wme_test/run
wme_test/wclient.c

index 4c7508da72e7fe5bd10b978a927345cc7fe642ad..5cbc8f9a50fcfbfdcb4225a64e629b7ffdd35683 100644 (file)
@@ -9,6 +9,10 @@
 #define Kbit 1000
 #define Mbit (Kbit*Kbit)
 
+#define SEC_TO_USEC       1000000LL
+#define MSEC_TO_USEC      1000LL
+#define USEC_TO_NSEC      1000LL
+
 enum {
        AC_VO = 0,
        AC_VI = 1,
index 821c8557b5bbc380e4420fcb2b7c1448bdd99c49..71d1b6e3d9ff0ceda9c64ce7c76d1208392f5019 100755 (executable)
@@ -32,7 +32,7 @@ plot [0:*] [0.01:*] "${FILE}.dat" using 1:2 title "AC_VO",\
                    "${FILE}.dat" using 1:3 title "AC_VI",\
                    "${FILE}.dat" using 1:4 title "AC_BE",\
                    "${FILE}.dat" using 1:5 title "AC_BK"
-set term postscript color eps size 12cm,9cm
+ set term postscript color eps size 12cm,9cm
 set output '${FILE}.eps'
 replot
 EOF
index d2bca8d2cdbbaf420f2c2b8dcaaaa7b7321ea03c..fe08a5c9956913844ca58904a2f44c23bf84332b 100644 (file)
@@ -20,8 +20,7 @@
 
 #define MSEC (1000)
 
-#define PARAM_SERVERADDR 1
-#define MAX_SENDENDPOINTS  10
+#define MAX_SENDENDPOINTS  10 
 
 unsigned opt_packet_size = 800;
 unsigned opt_period_usec = 10*MSEC;
@@ -232,8 +231,8 @@ void* receiver(void* queue)
                send_timestamp = msg.send_timestamp;
                
                timespec_sub(&trans_time,&recv_timestamp ,&send_timestamp);
-               trans_time_usec = (trans_time.tv_sec * 1000000 + \
-                                        trans_time.tv_nsec / 1000) /2;
+               trans_time_usec = (trans_time.tv_sec * SEC_TO_USEC + \
+                                        trans_time.tv_nsec / USEC_TO_NSEC) /2;
          
                if (trans_time_usec < MAX_DELAY_US)
                        delay_stats[ac][trans_time_usec/GRANULARITY]++;
@@ -269,20 +268,20 @@ void* sender(void* endpoint)
 
        if (opt_packet_size) {
                packet_size = opt_packet_size;
-               period_usec = 1000000LL*packet_size*8/spoint->bandwidth_bps;
+               period_usec = SEC_TO_USEC*packet_size*8/spoint->bandwidth_bps;
        } else {
                period_usec = spoint->period_usec;
-               packet_size = (long long)spoint->bandwidth_bps/8 * period_usec/1000000;
+               packet_size = (long long)spoint->bandwidth_bps/8 * period_usec/SEC_TO_USEC;
        }
        snprintf(stream_desc, sizeof(stream_desc), "%d: %s %s (%d bytes per %s +-%s, %d packets/s)\n",
                 spoint-sepoint, ac_to_text[ac], bandwidth_to_text(buf1, spoint->bandwidth_bps),
                 packet_size, usec_to_text(buf2, period_usec),
-                usec_to_text(buf3, opt_jitter*period_usec/100), 1000000/period_usec);
+                usec_to_text(buf3, opt_jitter*period_usec/100), (int) SEC_TO_USEC/period_usec);
        printf("%s", stream_desc);
        fprintf(logfd, "# Stream %s", stream_desc);
 
        if (packet_size < sizeof(struct msg_t)) {
-               fprintf(stderr, "Pakcet size too small (min %d)\n", sizeof(struct msg_t));
+               fprintf(stderr, "Packet size too small (min %d)\n", sizeof(struct msg_t));
                exit(1);
        }
 
@@ -326,10 +325,10 @@ void* sender(void* endpoint)
                /*           |~~~+~~~| jitter interval (width = 2*opt_jitter percentage from period)*/
                /* |-------------|     nominal period*/
                if (opt_jitter) {
-                       period.tv_nsec = 1000LL*(period_usec*(100-opt_jitter)/100
+                       period.tv_nsec = USEC_TO_NSEC*(period_usec*(100-opt_jitter)/100
                                                 + rand() % (2*period_usec*opt_jitter/100));
                } else {
-                       period.tv_nsec = 1000LL*(period_usec);
+                       period.tv_nsec = USEC_TO_NSEC*(period_usec);
                }
                period.tv_sec = 0;