SUBANGKAR

shell

Jan 3rd, 2019
125
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # cd /
  2. # cd home
  3. # cd duran
  4. # cd Downloads/
  5.  
  6. #       CHANGE PATH IN 4 PLACES *******************************************************
  7.  
  8. #INPUT: output file AND number of iterations
  9. output_file_format="802_15_4";
  10. iteration_float=5.0;
  11.  
  12.  
  13. num_node=20
  14. num_flow=10
  15.  
  16. pckt_size=64
  17. pckt_per_sec=100
  18. coverage=5
  19.  
  20. iteration=$(printf %.0f $iteration_float);
  21.  
  22.  
  23. r=1
  24. end=5
  25.  
  26. while [ $r -le $end ]
  27. do
  28.  
  29.  
  30. echo "total iteration: $iteration"
  31. ###############################START A ROUND
  32. l=0;thr=0.0;del=0.0;s_packet=0.0;r_packet=0.0;d_packet=0.0;del_ratio=0.0;
  33. dr_ratio=0.0;time=0.0;t_energy=0.0;energy_bit=0.0;energy_byte=0.0;energy_packet=0.0;total_retransmit=0.0;energy_efficiency=0.0;
  34.  
  35. i=0
  36. while [ $i -lt $iteration ]
  37. do
  38. #################START AN ITERATION
  39. echo "                             EXECUTING $(($i+1)) th ITERATION"
  40.  
  41.  
  42. ns 802_15_4.tcl $num_node $num_flow $pckt_per_sec $coverage
  43. echo "SIMULATION COMPLETE. BUILDING STAT......"
  44.  
  45. awk -f 802_15_4.awk 802_15_4.tr > 802_15_4.out
  46.  
  47.  
  48. while read val
  49. do
  50.     l=$(($l+1))
  51.  
  52.  
  53.     if [ "$l" == "1" ]; then   
  54.         thr=$(echo "scale=5; $thr+$val/$iteration_float" | bc)
  55. #       echo -ne "throughput: $thr "
  56.     elif [ "$l" == "2" ]; then
  57.         del=$(echo "scale=5; $del+$val/$iteration_float" | bc)
  58. #       echo -ne "delay: "
  59.     elif [ "$l" == "3" ]; then
  60.         del_ratio=$(echo "scale=5; $del_ratio+$val/$iteration_float" | bc)
  61. #       echo -ne "delivery ratio: "
  62.     elif [ "$l" == "4" ]; then
  63.         dr_ratio=$(echo "scale=5; $dr_ratio+$val/$iteration_float" | bc)
  64. #       echo -ne "drop ratio: "
  65.     elif [ "$l" == "5" ]; then
  66.         t_energy=$(echo "scale=5; $t_energy+$val/$iteration_float" | bc)
  67. #       echo -ne "total_energy: "
  68.     fi
  69.  
  70.     echo "$val"
  71. #                            CHNG PATH      3       ######################################################
  72. done < 802_15_4.out
  73.  
  74.  
  75.  
  76. i=$(($i+1))
  77. l=0
  78. #################END AN ITERATION
  79. done
  80.  
  81. dir=""
  82. under="_"
  83. file="$dir$output_file_format$under$r.out"
  84.  
  85. node_var="pckt_per_sec_var"
  86. t="throughput"
  87. d="delay"
  88. deli="delivary_ratio"
  89. drop="drop_ratio"
  90. en="energy"
  91.  
  92. throughput_xgr="$node_var$under$t.xgr"
  93. delay_xgr="$node_var$under$d.xgr"
  94. deliverRatio_xgr="$node_var$under$deli.xgr"
  95. dropRatio_xgr="$node_var$under$drop.xgr"
  96. energy_xgr="$node_var$under$en.xgr"
  97.  
  98. throughput_ps="$node_var$under$t.ps"
  99. delay_ps="$node_var$under$d.ps"
  100. deliverRatio_ps="$node_var$under$deli.ps"
  101. dropRatio_ps="$node_var$under$drop.ps"
  102. energy_ps="$node_var$under$en.ps"
  103.  
  104. echo -ne "Number Of Nodes:          $num_node " >> $file
  105. echo -ne "Number Of Flow:          $num_flow " >> $file
  106. echo -ne "Number Of Pcktpersec:          $pckt_per_sec " >> $file
  107. echo -ne "Coverage:          $coverage " >> $file
  108. echo -ne "Throughput:          $thr " >> $file
  109. echo -ne "AverageDelay:         $del " >> $file
  110. echo -ne "PacketDeliveryRatio:      $del_ratio " >> $file
  111. echo -ne "PacketDropRatio:      $dr_ratio " >> $file
  112. echo -ne "Total energy consumption:        $t_energy " >> $file
  113. echo "" >> $file
  114.  
  115. ##### MAKING THROUGHPUT GRAPH
  116.  
  117. echo -ne "$pckt_per_sec " >> $throughput_xgr
  118. echo -ne "$thr\n" >> $throughput_xgr
  119.  
  120. xgraph -device ps -o $throughput_ps $throughput_xgr
  121.  
  122. ##### MAKING DELAY GRAPH
  123.  
  124. echo -ne "$pckt_per_sec " >> $delay_xgr
  125. echo -ne "$del\n" >> $delay_xgr
  126.  
  127. xgraph -device ps -o $delay_ps $delay_xgr
  128.  
  129. ##### MAKING DELIVERY GRAPH
  130.  
  131. echo -ne "$pckt_per_sec " >> $deliverRatio_xgr
  132. echo -ne "$del_ratio\n" >> $deliverRatio_xgr
  133.  
  134. xgraph -device ps -o $deliverRatio_ps $deliverRatio_xgr
  135.  
  136. ##### MAKING DROP GRAPH
  137.  
  138. echo -ne "$pckt_per_sec " >> $dropRatio_xgr
  139. echo -ne "$dr_ratio\n" >> $dropRatio_xgr
  140.  
  141. xgraph -device ps -o $dropRatio_ps $dropRatio_xgr
  142.  
  143. ##### MAKING ENERGY GRAPH
  144.  
  145. echo -ne "$pckt_per_sec " >> $energy_xgr
  146. echo -ne "$t_energy\n" >> $energy_xgr
  147.  
  148. xgraph -device ps -o $energy_ps $energy_xgr
  149.  
  150. r=$(($r+1))
  151. #num_node=`expr $num_node + 20`
  152. #num_flow=`expr $num_flow + 10`
  153. pckt_per_sec=`expr $pckt_per_sec + 100`
  154. #coverage=`expr $coverage + 1`
  155.  
  156. #######################################END A ROUND
  157. done
RAW Paste Data