[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use a trace for traffic gntr?




> Dear ns-gurus,
> 
> Can anyone out there explain "How to use a trace file
> for a traffic source generator". The trace file I am
> referring to is *not* the ns-generated tracefile.
>  For example, I have a file with tuples
>  "Bytes  vs. Timestamp". e.g  100 2.4456, 
> indicating 100 byte-pkt arrived at 2.4456 secs... and so on... How do I
> make ns read the file and generate pkts appropriately?
> 
> I looked at the documentation for Application/Traffic/Trace, but its
> very unclear and the format is also confusing (to me)
> 
Each record in the trace file consists of 2 32-bit fields.  The first
represents the inter-packet time in microseconds, the second represents
the packet size in bytes.

So you probably want to do the following:

1.  Swap the order of the fields
2.  Convert absolute time to inter-packet times.
3.  Convert inter-packet times to microseconds.
4.  Convert them to binary.

For number 4, a simple program like the following might work.

Lee



#include <stdio.h>

typedef struct _trec {
  unsigned int trec_time;
  unsigned int trec_len;
} trec;

main()

{
  trec t;
  void exit();

  /* assume we read and write stdio */

  while (fscanf(stdin, "%d %d", &t.trec_time, &t.trec_len) != EOF)
    if (fwrite((char *)&t, sizeof(trec), 1, stdout) != 1) {
      (void)fprintf(stderr, "write failed\n");
      exit(1);
    }

  return 0;
}