X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=apps%2FUDPEcho%2FNodeConnectivity%2FcreateNodeConnectivityM.pl;fp=apps%2FUDPEcho%2FNodeConnectivity%2FcreateNodeConnectivityM.pl;h=fdf9e16efe78fb9badec49dfcb2ea2a8732ec615;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hp=0000000000000000000000000000000000000000;hpb=adf1de6c009d13b7b52e68535c63b28f59c97400;p=tinyos-2.x.git diff --git a/apps/UDPEcho/NodeConnectivity/createNodeConnectivityM.pl b/apps/UDPEcho/NodeConnectivity/createNodeConnectivityM.pl new file mode 100644 index 00000000..fdf9e16e --- /dev/null +++ b/apps/UDPEcho/NodeConnectivity/createNodeConnectivityM.pl @@ -0,0 +1,167 @@ +#!/usr/bin/perl + +# FileName: createMotelabTopology.pl +# Date: December 31, 2004 +# +# Description: Converts a TOSSIM .nss (topology) file into Motelab format +# Usage: ./createMotelabTopology.pl .nssfile + +# Input: A TOSSIM .nss topology file +# Output: A nesc file containing a 2D array that represents +# the latency for each node and a func that returns true or false +# as to whether that node can communicate with other nodes + + +use strict; + +###################### +# # +# Parse Parameters # +# # +###################### + +if ( 2 > @ARGV ) { + die "Usage: ./createMotelabTopology <.nss file> "; +} + +####################### +# # +# Open file handles # +# # +####################### + +open(INPUT_MAP, "$ARGV[0]") + or die "Unable to open input file $ARGV[0] ($!)"; + +open(INPUT_NSS, "$ARGV[1]") + or die "Unable to open input file $ARGV[1] ($!)"; + +######################### +# # +# Parse and store file # +# outputs # +# # +######################### + +my @mappingArray; +while (my @input = split(/\s+/, )) { + $mappingArray[$input[0]] = $input[1]; +} + +my %probHash; +my $maxI = 0; +my $maxJ = 0; + +while (my @input = split(/:/, )) { + + # 09 Jan 2005 : GWA : Yikes, not sure about ordering here. Also what the + # .nss file includes is the bit error probability, + # essentially the inverse of what we want. + + $probHash{"$input[0]x$input[1]"} = (1 - $input[2]); + + if ($input[0] > $maxI) { + $maxI = $input[0]; + } + if ($input[1] > $maxJ) { + $maxJ = $input[1]; + } +} + +############################# +# # +# Write out the nesC code # +# # +############################# + +my $dateString = `date`; +print <