[ns] throughput in 802.11

Network/Ns-2 | 2007/07/23 20:06 | adioshun
[ns] throughput in 802.11



--=-4u/lpYXeoH45EUz4ZptR
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Here are two awk scripts that will calculate throughput from the output
of a CMU trace file for wireless networks. The first will display for
each node: node id, total number of bytes received, total time, and
average throughput.

The second script is more involved and will output average delay,
dropped packets, collisions, etc over all nodes on the WLAN. In addition
it will create the files throughput.dat, delay.dat, and rate.day for the
delay/throughput/rate measured at each node. The script was written for
a simulation with a fixed packet size (1000 bytes), so the script counts
packets not bytes. It may not be useful because it is very specific for
the simulation I was running, but it gives an example of how to generate
more statistics out of the trace file.

Unfortunately, I do not remember from whom I obtained the original awk
script for throughput (from someone on this list?). My apologies to the
author.

To run the script on trace file, out.tr:
throughput < out.tr

m

On Mon, 2002-09-09 at 12:55, Bhaskar Anepu wrote:
>
> Hi,
> I'm facing a problem plotting thruput curves using
> tracegraph as my trace files are very big (around 120
> Mb each). i would appreciate if you mail some perl
> scripts so that i can go through them and start
> writing my own stuff.
>
> Regards,
> Bhaskar.

--
Michael Mercurio
lafcadio@bu.edu

--=-4u/lpYXeoH45EUz4ZptR
Content-Disposition: attachment; filename=throughput
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=throughput; charset=ISO-8859-1

#!/usr/bin/awk -f
#
# AWK script to compute throughput of nodes
# in ns trace output file.
#
# - Only nodes that have received data will
# be counted (throughput of 0 not reported).
# - Only Agent (AGT) data is counted.
#=20
# Throughput is:=20
# total bytes received / tdelta
#
# where tdelta is the time difference
# of when the first packet is sent=20
# and the last packet is received.
#
# Last updated: March 30, 2002 0912 mm=20
/ AGT / {
# these are for the new trace
# new_time =3D $3;
# new_node =3D $9=20
# new_bytes =3D $37

event =3D $1
time =3D $2;
node =3D $3;
bytes =3D $8;

# strip leading and trailing _ from node
sub(/^_*/, "", node);=20
sub(/_*$/, "", node);

if ( event =3D=3D "s" ) {
if ( time < start_time[node] || start_time[node] =3D=3D 0 )
start_time[node] =3D time;
}
else if ( event =3D=3D "r" ) {
if ( time > end_time[node] )=20
end_time[node] =3D time;
total_bytes[node] +=3D bytes;
}
}
END {
for ( node in total_bytes ) {
if ( total_bytes[node] > 0 ) {
tdelta =3D end_time[node] - start_time[node];
printf("%d %d %f %d\n",=20
node,=20
total_bytes[node],=20
tdelta,
total_bytes[node]*8 / tdelta);
}
}
}

--=-4u/lpYXeoH45EUz4ZptR
Content-Disposition: attachment; filename=genstats
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=genstats; charset=ISO-8859-1

#! /usr/bin/awk -f
#
# Parse a ns2 wireless trace file and generate the following stats:
# - number of flows (senders)
# - time of simulation run
# - number of packets sent (at the Application)
# - number of packets received (at the Application)
# - number of packets dropped (at the Application)
# - number of collisions (802.11)
# - average delay
# - average throughput
# - average traffic rate (measured)
#
# Last updated: April 5, 2002 0113 mm
function average (array) {
sum =3D 0;
items =3D 0;
for (i in array) {
sum +=3D array[i];
items++;
}
# printf("DEBUG sum is %d, items is %d\n", sum, items);
if (sum =3D=3D 0 || items =3D=3D 0)
return 0; =20
else
return sum / items;
}

function max( array ) {
for (i in array) {
if (array[i] > largest)
largest =3D array[i];
}
return largest;
}

function min(array) {
for (i in array) {
if (0 =3D=3D smallest)
smallest =3D array[i];
else if (array[i] < smallest)
smallest =3D array[i];
}
return smallest;
}
BEGIN {
total_packets_sent =3D 0;
total_packets_received =3D 0;
total_packets_dropped =3D 0;
first_packet_sent =3D 0;
last_packet_sent =3D 0;
last_packet_received =3D 0;
}
{
event =3D $1;
time =3D $2;
node =3D $3;
type =3D $4;
reason =3D $5;
packetid =3D $6;

# strip leading and trailing _ from node
sub(/^_*/, "", node);=20
sub(/_*$/, "", node);

if ( time < simulation_start || simulation_start =3D=3D 0 )
simulation_start =3D time;
if ( time > simulation_end )
simulation_end =3D time;

if ( reason =3D=3D "COL" )
total_collisions++;

if ( type =3D=3D "AGT" ) {
nodes[node] =3D node; # to count number of nodes
if ( time < node_start_time[node] || node_start_time[node] =3D=3D 0=
)
node_start_time[node] =3D time;

if ( time > node_end_time[node] )
node_end_time[node] =3D time;

if ( event =3D=3D "s" ) {
flows[node] =3D node; # to count number of flows
if ( time < first_packet_sent || first_packet_sent =3D=3D 0 )
first_packet_sent =3D time;
if ( time > last_packet_sent )
last_packet_sent =3D time;
# rate
packets_sent[node]++;
total_packets_sent++;

# delay
pkt_start_time[packetid] =3D time;
}
else if ( event =3D=3D "r" ) {
if ( time > last_packet_received )
last_packet_received =3D time;
# throughput
packets_received[node]++;
total_packets_received++;
=20
# delay
pkt_end_time[packetid] =3D time;
}
else if ( event =3D=3D "D" ) {
total_packets_dropped++;
# pkt_end_time[packetid] =3D time; # EXPERIMENTAL=20
}
}
}
END {
print "" > "throughput.dat";
print "" > "rate.dat";
number_flows =3D 0;
for (i in flows)
number_flows++;

# find dropped packets
if ( total_packets_sent !=3D total_packets_received ) {
printf("***OUCH*** Dropped Packets!\n\n");
for ( packetid in pkt_start_time ) {
if ( 0 =3D=3D pkt_end_time[packetid] ) {
total_packets_dropped++;
# pkt_end_time[packetid] =3D simulation_end; # EXPERIMENTAL
}
}
}

for (i in nodes) {
if ( packets_received[i] > 0 ) {
end =3D node_end_time[i];
start =3D node_start_time[i - number_flows];
runtime =3D end - start;
if ( runtime > 0 ) {
throughput[i] =3D packets_received[i]*8000 / runtime;
printf("%d %f %f %d\n", i, start, end, throughput[i]) >> "t=
hroughput.dat";
}
}
# rate - not very accurate
if ( packets_sent[i] > 2 ) {
end =3D node_end_time[i];
start =3D node_start_time[i];
runtime =3D end - start;
if ( runtime > 0 ) {
rate[i] =3D (packets_sent[i]*8000) / runtime;
printf("%d %f %f %d\n", i, start, end, rate[i]) >> "rate.da=
t";
}
}
}

# delay
for ( pkt in pkt_end_time) {
end =3D pkt_end_time[pkt];
start =3D pkt_start_time[pkt];
delta =3D end - start;
if ( delta > 0 ) {
delay[pkt] =3D delta;
printf("%d %f %f %f\n", pkt, start, end, delta) > "delay.dat";
}
}
=20
# offered load
total_runtime =3D last_packet_sent - first_packet_sent;
if ( total_runtime > 0 && total_packets_sent > 0)
load =3D ((total_packets_sent * 8000)/total_runtime) / 2000000; # n=
o overhead

printf("\
RUN OFFERED PACKETS PACKETS PACKETS AVERAGE MAX =
MIN AVERAGE AVERAGE\n\
FLOWS TIME LOAD SENT RECEIVED DROPPED COLLISIONS DELAY DELAY =
DELAY THROUGHPUT TRAFFIC RATE\n\
----- ----- ------- -------- -------- -------- ---------- ---------- ------=
---- ---------- ------------ ------------\n");

printf("%5d %5.1f %7.4f %8d %8d %8d %10d %10.4f %10.4f %10.4f %12d %12d=
\n",
number_flows,
total_runtime,
load,
total_packets_sent,
total_packets_received,
total_packets_dropped,
total_collisions,
average(delay),
max(delay),
min(delay),
average(throughput),
average(rate));

printf("%5d %5.1f %7.4f %8d %8d %8d %10d %10.4f %10.4f %10.4f %12d %12d=
\n",
number_flows,
total_runtime,
load,
total_packets_sent,
total_packets_received,
total_packets_dropped,
total_collisions,
average(delay),
max(delay),
min(delay),
average(throughput),
average(rate)) >> "stats.dat";
}

--=-4u/lpYXeoH45EUz4ZptR--

출처 : http://mailman.isi.edu/pipermail/ns-users/2002-September/025628.html
http://www.gongdory.co.kr/390


2007/07/23 20:06 2007/07/23 20:06
TAG
Trackback address :: http://4ellene.net/tt/trackback/1188
  1. Will tramadol hcl test positive in drug testing.

    Tracked from Tramadol. 2008/06/29 18:08  삭제

    Low price tramadol. Tramadol hydrochloride. Tramadol side effects. Tramadol. What is tramadol.

  2. Cheap flight tickets discount flights worldwide.

    Tracked from Cheap flight tickets. 2008/07/02 13:04  삭제

    Cheap flight tickets to h. Cheap flight tickets. Vacation cheap flight tickets discount airline.

  3. Free family incest pictures.

    Tracked from Incest. 2008/08/08 17:33  삭제

    Free erotic incest stories. Mother son incest pictures. Gay incest stories.

  4. Teen incest stories.

    Tracked from Gay incest. 2008/12/29 04:41  삭제

    Real incest. Free incest stories. Incest. Incest sex. Russian incest. Family incest.

  5. Mature sex.

    Tracked from Mature incest. 2009/01/16 08:58  삭제

    Chubby mature. Mature moms. Mature sex. Mature pantyhose. Mature nude women. Mature thumbs. Older mature sexgalleries. Mature nude.

  6. Cialis.

    Tracked from Compare levitra cialis. 2009/02/25 16:56  삭제

    Cialis injury attorney ohio. Cheap cialis. Cialis.

  7. Cialis best price buy online.

    Tracked from Cialis. 2009/02/27 16:27  삭제

    Viagra vs cialis. Cialis effects. Cialis and drug craving. Cialis.

  8. Generic viagra.

    Tracked from Viagra. 2009/02/27 20:21  삭제

    Generic viagra. Your viagra onlinne guide. Viagra for order lamisil viagra. Viagra london.

  9. Tramadol.

    Tracked from Tramadol cod. 2009/03/24 10:20  삭제

    Tramadol. Ultram tramadol.

Comments List

  1. sg girls 2008/05/23 06:06

  2. pics of ebony 2008/05/24 00:47

  3. teenage girl in thong 2008/05/24 01:05

Write a comment.

[로그인][오픈아이디란?]