]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
It is possible to specify message size per stream.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 18 Jan 2008 10:09:22 +0000 (11:09 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 18 Jan 2008 10:09:22 +0000 (11:09 +0100)
wme_test/wclient.c

index 266ef30c790f56917f4868f5cd5429d864540cdf..dcfbc66c8ec5432ecebad34f8b023ee0a088bfbe 100644 (file)
@@ -27,7 +27,7 @@ unsigned opt_jitter = 0;
 char    *opt_output = "delay_stats";
 unsigned opt_count_sec = 0;
 unsigned opt_def_bandwidth = 200;
-unsigned opt_def_period_msec = 10;
+unsigned opt_def_period_msec = 0;
 int opt_granularity_usec = MIN_GRANULARITY;
 
 int ac_sockfd[AC_NUM];
@@ -334,12 +334,17 @@ void* sender(void* arg)
 
        set_rt_prio(90-stream->ac);
 
-       if (opt_packet_size) {
-               packet_size = opt_packet_size;
+       if (stream->packet_size) {
+               packet_size = stream->packet_size;
                period_usec = SEC_TO_USEC*packet_size*8/stream->bandwidth_bps;
-       } else {
+       } else if (stream->period_usec) {
                period_usec = stream->period_usec;
                packet_size = (long long)stream->bandwidth_bps/8 * period_usec/SEC_TO_USEC;
+       } else {
+               char buf[200];
+               stream_to_text(buf, sizeof(buf), stream, 0);
+               fprintf(stderr, "Neither packet size nor period was specified for a stream %s\n", buf);
+               exit(1);
        }
        stream->packet_size = packet_size;
        stream->period_usec = period_usec;
@@ -451,7 +456,8 @@ char* parse_bandwidths(char *params)
                
                sp->bandwidth_bps = bw*Kbit;
 
-               long period;
+               long period = 0;
+               long packet_size = 0;
                if (*params == '@') {
                        params++;
                        period = strtol(params, &next_char, 10);
@@ -459,9 +465,22 @@ char* parse_bandwidths(char *params)
                                return params;
                        params = next_char;
                }
-               else
-                       period = opt_def_period_msec;
+               else {
+                       if (*params == '/') {
+                               params++;
+                               packet_size = strtol(params, &next_char, 10);
+                               if (packet_size == 0)
+                                       return params;
+                               params = next_char;
+                       } else {
+                               packet_size = opt_packet_size;
+                               period = opt_def_period_msec;
+                       }
+               }
                sp->period_usec = period*MSEC_TO_USEC;
+               sp->packet_size = packet_size;
+
+               
 
                if (*params != '\0' && *params != ',')
                        return params;
@@ -524,16 +543,21 @@ int main(int argc, char *argv[])
                                fprintf(stderr, "Usage: %s [ options ] server_addr\n\n", argv[0]);
                                fprintf(stderr, "Options:\n");
                                fprintf(stderr, "    -B  default bandwidth for -b option [kbit]\n");
-                               fprintf(stderr, "    -b  bandwidth of streams (VO|VI|BE|BK)[:<kbit>][@<msec>][,...]\n");
+                               fprintf(stderr, "    -b  bandwidth of streams (VO|VI|BE|BK)[:<kbit>][@<msec> or /<bytes>][,...]\n");
                                fprintf(stderr, "    -c  count (number of seconds to run)\n");
                                fprintf(stderr, "    -g  histogram granularity [usec]\n");
                                fprintf(stderr, "    -j  send jitter (0-100) [%%]\n");
                                fprintf(stderr, "    -o  output filename (.dat will be appended)\n");
-                               fprintf(stderr, "    -s  size of data payload in packets [bytes]\n");
+                               fprintf(stderr, "    -s  size of data payload in packets [bytes] (default: %d)\n", opt_packet_size);
                                fprintf(stderr, "    -T  default period for -b option [msec]\n");
                                exit(1);
                }
        }
+       if (opt_packet_size && opt_def_period_msec) {
+               fprintf(stderr, "Error: Nonzero -T and -s can't be used together!.\n");
+               exit(1);
+       }
+
        if (optind < argc) {
                server_addr = argv[optind];
        } else {