Advertisement
shamiul93

Untitled

Jan 12th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 KB | None | 0 0
  1.  
  2. #INPUT: output file AND number of iterations
  3.  
  4. outputDirectory="output_wired_cum_wireless/"
  5. rm -rf $outputDirectory
  6. rm -rf Output/
  7. mkdir -p $outputDirectory
  8.  
  9. tclFile="final_w2w.tcl"
  10.  
  11.  
  12. iteration_float=1.0;
  13. under="_";
  14.  
  15. outFile="$outputDirectory""OUT"
  16. tempFile="$outputDirectory""TEMPFILE"
  17. graphData="$outputDirectory""GRAPH"
  18.  
  19.  
  20. nNodesInit=10
  21. # pcktRateInit = 100
  22.  
  23. nNodes=$nNodesInit
  24. # pcktRate = $pcktRateInit
  25.  
  26. iteration=$(printf %.0f $iteration_float);
  27.  
  28.  
  29. echo 'Number of nodes will be varied.'
  30.  
  31.  
  32. echo 'Please enter the # of iteration'
  33. read nIter
  34.  
  35. round=1
  36.  
  37. while [ $round -le $nIter ]
  38. do
  39. ###############################START A ROUND
  40.  
  41. echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  42. echo " ROUND : $round "
  43. echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  44.  
  45. l=0;thr=0.0;del=0.0;s_packet=0.0;r_packet=0.0;d_packet=0.0;del_ratio=0.0;
  46. dr_ratio=0.0;time=0.0;total_retransmit=0.0;rTotalDelay=0.0;
  47.  
  48. i=0
  49. while [ $i -lt $iteration ]
  50. do
  51. #################START AN ITERATION
  52. echo "################EXECUTING $(($i+1)) th ITERATION################"
  53.  
  54. # echo "!!!!!!!!!!!!!!!nNOdes = $nNodes!!!!!!!!!!!!!!!!"
  55. ns $tclFile $nNodes
  56. # ns $tclFile
  57. echo "SIMULATION COMPLETE. BUILDING STAT..."
  58.  
  59. flnm="$outputDirectory""tem""$round"
  60. awk -f final_w2w_awk.awk wired-and-wireless.tr > $tempFile
  61. cp wired-and-wireless.tr $flnm
  62.  
  63.  
  64. # ======================================================================
  65. # UPDATING THE VALUES IN EACH ITERATION
  66. # ======================================================================
  67.  
  68. while read val
  69. do
  70.  
  71. l=$(($l+1))
  72.  
  73. if [ "$l" == "1" ]; then
  74. thr=$(echo "scale=5; $thr+$val/$iteration_float" | bc)
  75. # echo -ne "throughput: $thr "
  76. elif [ "$l" == "2" ]; then
  77. del=$(echo "scale=5; $del+$val/$iteration_float" | bc)
  78. # echo -ne "delay: "
  79. elif [ "$l" == "3" ]; then
  80. s_packet=$(echo "scale=5; $s_packet+$val/$iteration_float" | bc)
  81. # echo -ne "send packet: "
  82. elif [ "$l" == "4" ]; then
  83. r_packet=$(echo "scale=5; $r_packet+$val/$iteration_float" | bc)
  84. # echo -ne "received packet: "
  85. elif [ "$l" == "5" ]; then
  86. d_packet=$(echo "scale=5; $d_packet+$val/$iteration_float" | bc)
  87. # echo -ne "drop packet: "
  88. elif [ "$l" == "6" ]; then
  89. del_ratio=$(echo "scale=5; $del_ratio+$val/$iteration_float" | bc)
  90. # echo -ne "delivery ratio: "
  91. elif [ "$l" == "7" ]; then
  92. dr_ratio=$(echo "scale=5; $dr_ratio+$val/$iteration_float" | bc)
  93. # echo -ne "drop ratio: "
  94. elif [ "$l" == "8" ]; then
  95. time=$(echo "scale=5; $time+$val/$iteration_float" | bc)
  96. # echo -ne "time: "
  97. elif [ "$l" == "9" ]; then
  98. rTotalDelay=$(echo "scale=5; $rTotalDelay+$val/$iteration_float" | bc)
  99. fi
  100.  
  101. # echo "val: $val"
  102. done < $tempFile
  103.  
  104. i=$(($i+1))
  105. l=0
  106. done
  107.  
  108.  
  109. ########## OUTPUT FILE GENERATION
  110.  
  111. output_file="$outFile$under$round"
  112. echo "" > $output_file # clearing the output file
  113.  
  114.  
  115. echo "# of Nodes: $nNodes " >> $output_file
  116.  
  117.  
  118. echo "" >> $output_file
  119. echo "" >> $output_file
  120. echo "" >> $output_file
  121.  
  122.  
  123. echo "Throughput: $thr " >> $output_file
  124. echo "AverageDelay: $del " >> $output_file
  125. echo "Sent Packets: $s_packet " >> $output_file
  126. echo "Received Packets: $r_packet " >> $output_file
  127. echo "Dropped Packets: $d_packet " >> $output_file
  128. echo "PacketDeliveryRatio: $del_ratio " >> $output_file
  129. echo "PacketDropRatio: $dr_ratio " >> $output_file
  130. echo "Total time: $time " >> $output_file
  131. echo "Total Delay: $rTotalDelay " >> $output_file
  132. # ==========================================================================
  133. ##############################
  134. cat $output_file
  135.  
  136.  
  137. ############################
  138. round=$(($round+1))
  139. #
  140. ########Plotting Graph
  141.  
  142. echo -ne "$nNodes " >> $graphData
  143.  
  144. nNodes=$(($nNodesInit*$round))
  145. # pcktRate=$(($pcktRateInit*$round))
  146.  
  147. # if [ "$param" == "1" ]; then
  148. # echo -ne "$nNodes " >> $graphData
  149. # nNodes=$(($nNodesInit*$round))
  150. # elif [ "$param" == "2" ]; then
  151. # echo -ne "$nFlows " >> $graphData
  152. # nFlows=$(($nFlowsInit*$round))
  153. # elif [ "$param" == "3" ]; then
  154. # echo -ne "$pcktRate " >> $graphData
  155. # pcktRate=$(($pcktRateInit*$round))
  156. # fi
  157.  
  158. # echo "throughput: $thr delay: $del deliver_rat: $del_ratio drop_rat: $dr_ratio" >> $graphData
  159.  
  160. echo "$thr $del $del_ratio $dr_ratio" >> $graphData
  161. #####################END A ROUND
  162. done
  163.  
  164. param="No of nodes"
  165.  
  166. # if [ "$param" == "1" ]; then
  167. # param="No of nodes"
  168. # elif [ "$param" == "2" ]; then
  169. # param="No of flows"
  170. # elif [ "$param" == "3" ]; then
  171. # param="Packet Rate"
  172. # fi
  173.  
  174. arr[0]=""
  175. arr[1]=""
  176. arr[2]="Throughput"
  177. arr[3]="Average Delay"
  178. arr[4]="Packet Delivery Ratio"
  179. arr[5]="Packet Drop Ratio"
  180.  
  181. arr2[0]=""
  182. arr2[1]=""
  183. arr2[2]="Throughput ( bit/second )"
  184. arr2[3]="Average Delay ( second )"
  185. arr2[4]="Packet Delivery Ratio ( % )"
  186. arr2[5]="Packet Drop Ratio ( % )"
  187.  
  188. i=5
  189. while [ $i -ge 2 ]
  190. do
  191. gnuplot -persist -e "set terminal png size 700,500; set output '$outputDirectory${arr[$i]}VS$param.png';set title 'Wired-cum-Wireless : ${arr[$i]} vs $param'; set xlabel '$param'; set ylabel '${arr2[$i]}'; plot '$outputDirectory/GRAPH' using 1:$i with lines"
  192. i=$(($i-1))
  193. done
  194.  
  195. # mv $outputDirectory "Output"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement