WLAN에서 업스트림과 다운스트림의 시뮬레이션을 위한 강좌

|


여태 만든것이 다 날라가고...
새로이 실험으로 증빙된 올바른 소스와 정보만을 올리기로 한다.

NS2 실험을 위한 과정..

NS2는 본래 trace 파일을 가지고 원하는 데이터를 추출하기 위해 여러 동작을 하게 된다.
이러한 동작에 있어서 많은 노동의 고통이 따르기 때문에 나는 up_down_stream2.sh라는 쉘 스크립트 파일을 만들어 사용하였다.

아래는 up_down-stream2.sh 파일 내용이다.
###########################################################################
#!/bin/sh
echo "Awk ShellScript"
num=1
num1=1
num2=1
rm -rf *~ *.*~ data/check_retry_*~ data/buffer_50_up_down_th_*~ data/drop_*~ data/check_retry_* data/buffer_50_up_down_th_* data/drop_* *.tr
#한번 생성한 파일위로 다시 실험한 데이터가 쌓이면 매우 피곤하다. 이에 삭제를 먼저 하고 실행할 수 있도록 만들었다.


for Tcl_file in 40 #노드 수
do
for Tcl_file1 in 7 #CWmin
do
for Tcl_file2 in 7 #CWmax
do
   echo "###################### TCL" $num "\t "$Tcl_file
   ns data$Tcl_file.tcl $Tcl_file1 $Tcl_file2 > data/check_retry_$Tcl_file-$Tcl_file1-$Tcl_file2
   num=`expr $num + 1` #나는 MAC에서 재전송 포기에 의한 패킷 수를 세기위한 소스를 만들어 따로  trace파일을 만들 필요가 있었다. 다른 살마들은 안해도 되며, 실행 위치의 data 폴더에 저장되도록 만들었다.
done
done
done

for Tcl_file in 40
do
for Tcl_file1 in 7
do
for PacketSize in 7
do
 echo "###################### TCL_Mobile_change" $num1
 echo "awk -f awk-ack_rec_wire  up_down_stream_$Tcl_file-$Tcl_file-$Tcl_file1-$PacketSize.tr >> testbook"
 sed 's/_/ /' up_down_stream_$Tcl_file-$Tcl_file-$Tcl_file1-$PacketSize.tr > testbook
 sed 's/_/ /' testbook > up_down_stream_$Tcl_file-$Tcl_file-$Tcl_file1-$PacketSize.tr
 rm -rf testbook
#아주 중요한 구문이다. trace 파일의 무선 노드의 식별 넘버에는 양쪽에 언더바가 생성된다. 
이 언더바를 지우는 과정이다.
 num1=`expr $num1 + 1`
done
done
done

for Tcl_file in 40
do
for Tcl_file1 in 7
do
for PacketSize in 7
do
  echo "###################### Throughput" $num2
  echo "awk -f awk-throughput -v nn=$PacketSize up_down_stream_$Tcl_file-$Tcl_file-$Tcl_file1-$PacketSize.tr  >> up_down_Th"  
  awk -f drop nn=$Tcl_file nn1=$Tcl_file1 nn2=$PacketSize up_down_stream_$Tcl_file-$Tcl_file-$Tcl_file1-$PacketSize.tr  >> data/drop_$Tcl_file-$Tcl_file-$Tcl_file1-$PacketSize
  awk -f awk-throughput nn=$Tcl_file nn1=$Tcl_file1 nn2=$PacketSize #드롭률 data 폴더의 해당 이름으로 생성시킨다.
up_down_stream_$Tcl_file-$Tcl_file-$Tcl_file1-$PacketSize.tr  >> data/buffer_50_up_down_th_$Tcl_file-$Tcl_file-$Tcl_file1-$PacketSize#처리량을 data폴더의 해당 이름으로 생성 시킨다.
  
done
done
done

###########################################################################


위의 실험에 있어서
trace 파일은 drop이란 awk 스크립트 파일을 호출하여 재 필터링 된다.
##########################################################################
BEGIN {
sum1=0;
sum2=0;
sum3=0;
sum4=0;
}
{
if(200<$2)#500초의 실험 시간 중 200초의 안정화 시간을 기다린후 이후값만 측정한다.
{
     if (($1 == "D")&&($4 =="IFQ")&&($7=="tcp" )&&($5!="END")&&($3 == (nn+1))) {
 sum1++;
 } #nn은 외부 입력 값이다. 쉘 스크립트를 확인하면 된다.
    if (($1 == "D")&&($4 =="IFQ")&&($7=="ack" )&&($5!="END")&&($3 == (nn+1))) {
 sum2++;
 } 
 
    if (($1 == "D")&&($4 =="IFQ")&&($7=="tcp" )&&($5!="END")&&($3 != (nn+1))) {
 sum3++;
 } 
    if (($1 == "D")&&($4 =="IFQ")&&($7=="ack" )&&($5!="END")&&($3 != (nn+1))) {
 sum4++;
 }
}
}

END {  

      print (nn+1); 
             print nn,":",nn,"_",nn1,"_",nn2," AP_ACK drop number : ",sum2,"\t","AP_DATA drop number : ",sum1
             print nn,":",nn,"_",nn1,"_",nn2," CLI_ACK drop number : ",sum4,"\t","CLI_DATA drop number : ",sum3,"\n"
       }
##########################################################################

drop을 필터링 하고 나면
총 처리량과 공평성 상태를 측정해야 한다.
처리량은 먼저 업스트림과 다운스트림을 측정한뒤 나머지를 산출한다.
awk-throughput이란 파일 명으로 생성된다.
##########################################################################
BEGIN {
total_byte1=0;
total_byte_th1=0;
first_time1=0;
last_time1=0;

total_byte2=0;
total_byte_th2=0;
first_time2=0;
last_time2=0;
sum1=0;
sum2=0;
  node = $3;
}
{
if(200<$2)
{
     if ( ($1 == "r")&&($5 =="tcp")&&($4 != nn)&&($4 != (nn+1))) {   
       if(first_time1=="0") first_time1=$2;
       last_time1=$2;
 total_byte1 += $6;
 sum1++;
 }
     if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 != (nn+1))) {
       if(first_time2=="0") first_time2=$2;
       last_time2=$2;
 total_byte2 += $8;
 sum2++;
 } 

   }
}

END {  

             fairness_index=total_byte1/total_byte2
     total=total_byte1+total_byte2
#  fairness_index=sum1/sum2
#  print "fairness index = ",fairness_index, "time 1 = ", last_time1,"time 2 = ",last_time2;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte1\t",((total_byte1*8/300)/1000000) ,"\t down: total_byte2\t",((total_byte2*8/300)/1000000) ,"\tfairness_index: ",fairness_index,"\t","total = ",((total*8/300)/1000000);
       }
 
############################################################################

 혹시나 플로우별 처리량이 필요하다면.....

10개 단위시(필요한 파일명으로 저장하면 된다)
사용방법은 쉘 스크립트 참조
###########################################################################
 BEGIN {

}
{
if(200<$2)
{
        if ( ($1 == "r")&&($5 =="tcp")&&($4 == 0)) {   
 total_byte0 += $6;
 sum0++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 1)) {   
 total_byte1 += $6;
 sum1++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 2)) {   
 total_byte2 += $6;
 sum2++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 3)) {   
 total_byte3 += $6;
 sum3++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 4)) {   
 total_byte4 += $6;
 sum4++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 5)) {   
 total_byte5 += $6;
 sum5++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 6)) {   
 total_byte6 += $6;
 sum6++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 7)) {   
 total_byte7 += $6;
 sum7++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 8)) {   
 total_byte8 += $6;
 sum8++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 9)) {   
 total_byte9 += $6;
 sum9++;
 }
 
 
  
      
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==12 )) {
 total_byte12 += $8;
 sum12++;
 } 
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==13 )) {
 total_byte13 += $8;
 sum13++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==14 )) {
 total_byte14 += $8;
 sum14++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==15 )) {
 total_byte15 += $8;
 sum15++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==16 )) {
 total_byte16 += $8;
 sum16++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==17 )) {
 total_byte17 += $8;
 sum17++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==18 )) {
 total_byte18 += $8;
 sum18++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==19 )) {
 total_byte19 += $8;
 sum19++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==20 )) {
 total_byte20 += $8;
 sum20++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==21 )) {
 total_byte21 += $8;
 sum21++;
 }
 
 
 
 
   }
}

END {  

             fairness_index=total_byte1/total_byte2
     total=total_byte1+total_byte2
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte0*8/300)/1000000),"up: NUM\t", sum0;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte1*8/300)/1000000),"up: NUM\t", sum1;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte2*8/300)/1000000),"up: NUM\t", sum2;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte3*8/300)/1000000),"up: NUM\t", sum3;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte4*8/300)/1000000),"up: NUM\t", sum4;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte5*8/300)/1000000),"up: NUM\t", sum5;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte6*8/300)/1000000),"up: NUM\t", sum6;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte7*8/300)/1000000),"up: NUM\t", sum7;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte8*8/300)/1000000),"up: NUM\t", sum8;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte9*8/300)/1000000),"up: NUM\t", sum9,"\n";
            
 
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte12*8/300)/1000000),"down: NUM\t", sum12;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte13*8/300)/1000000),"down: NUM\t", sum13;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte14*8/300)/1000000),"down: NUM\t", sum14;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte15*8/300)/1000000),"down: NUM\t", sum15;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte16*8/300)/1000000),"down: NUM\t", sum16;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte17*8/300)/1000000),"down: NUM\t", sum17;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte18*8/300)/1000000),"down: NUM\t", sum18;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte19*8/300)/1000000),"down: NUM\t", sum19;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte20*8/300)/1000000),"down: NUM\t", sum20;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte21*8/300)/1000000),"down: NUM\t", sum21;
           
       }
  ##########################################################################
30개의 노드일 때 플로우별 처리량
##########################################################################
BEGIN {

}
{
if(200<$2)
{
        if ( ($1 == "r")&&($5 =="tcp")&&($4 == 0)) {   
 total_byte0 += $6;
 sum0++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 1)) {   
 total_byte1 += $6;
 sum1++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 2)) {   
 total_byte2 += $6;
 sum2++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 3)) {   
 total_byte3 += $6;
 sum3++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 4)) {   
 total_byte4 += $6;
 sum4++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 5)) {   
 total_byte5 += $6;
 sum5++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 6)) {   
 total_byte6 += $6;
 sum6++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 7)) {   
 total_byte7 += $6;
 sum7++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 8)) {   
 total_byte8 += $6;
 sum8++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 9)) {   
 total_byte9 += $6;
 sum9++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 10)) {   
 total_byte10 += $6;
 sum10++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 11)) {   
 total_byte11 += $6;
 sum11++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 12)) {   
 total_byte12 += $6;
 sum12++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 13)) {   
 total_byte13 += $6;
 sum13++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 14)) {   
 total_byte14 += $6;
 sum14++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 15)) {   
 total_byte15 += $6;
 sum15++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 16)) {   
 total_byte16 += $6;
 sum16++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 17)) {   
 total_byte17 += $6;
 sum17++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 18)) {   
 total_byte18 += $6;
 sum18++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 19)) {   
 total_byte19 += $6;
 sum19++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 20)) {   
 total_byte20 += $6;
 sum20++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 21)) {   
 total_byte21 += $6;
 sum21++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 22)) {   
 total_byte22 += $6;
 sum22++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 23)) {   
 total_byte23 += $6;
 sum23++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 24)) {   
 total_byte24 += $6;
 sum24++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 25)) {   
 total_byte25 += $6;
 sum25++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 26)) {   
 total_byte26 += $6;
 sum26++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 27)) {   
 total_byte27 += $6;
 sum27++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 28)) {   
 total_byte28 += $6;
 sum28++;
 }
 if ( ($1 == "r")&&($5 =="tcp")&&($4 == 29)) {   
 total_byte29 += $6;
 sum29++;
 }
 
  
      if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 32)) {
 total_byte32 += $8;
 sum32++;
 } 
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==33)) {
 total_byte33 += $8;
 sum33++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 34)) {
 total_byte34 += $8;
 sum34++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==35)) {
 total_byte35 += $8;
 sum35++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 36)) {
 total_byte36 += $8;
 sum36++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==37)) {
 total_byte37 += $8;
 sum37++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==38)) {
 total_byte38 += $8;
 sum38++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 39)) {
 total_byte39 += $8;
 sum39++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 40)) {
 total_byte40 += $8;
 sum40++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==41 )) {
 total_byte41 += $8;
 sum41++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 42)) {
 total_byte42 += $8;
 sum42++;
 } 
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==43)) {
 total_byte43+= $8;
 sum43++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 44)) {
 total_byte44 += $8;
 sum44++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==45 )) {
 total_byte45 += $8;
 sum45++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==46)) {
 total_byte46 += $8;
 sum46++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==47 )) {
 total_byte47 += $8;
 sum47++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==48 )) {
 total_byte48 += $8;
 sum48++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==49 )) {
 total_byte49 += $8;
 sum49++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 50)) {
 total_byte50 += $8;
 sum50++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==51 )) {
 total_byte51 += $8;
 sum51++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 52)) {
 total_byte52 += $8;
 sum52++;
 } 
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==53 )) {
 total_byte53 += $8;
 sum53++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==54 )) {
 total_byte54 += $8;
 sum54++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==55 )) {
 total_byte55 += $8;
 sum55++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==56 )) {
 total_byte56 += $8;
 sum56++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==57 )) {
 total_byte57 += $8;
 sum57++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 == 58)) {
 total_byte58 += $8;
 sum58++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==59 )) {
 total_byte59 += $8;
 sum59++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==60 )) {
 total_byte60 += $8;
 sum60++;
 }
 if ( ($1 == "r")&&($4 =="AGT")&&($7=="tcp" )&&($3 ==61 )) {
 total_byte61 += $8;
 sum61++;
 }
 
 
   }
}

END {  

             fairness_index=total_byte1/total_byte2
     total=total_byte1+total_byte2
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte0*8/300)/1000000),"up: NUM\t", sum0;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte1*8/300)/1000000),"up: NUM\t", sum1;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte2*8/300)/1000000),"up: NUM\t", sum2;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte3*8/300)/1000000),"up: NUM\t", sum3;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte4*8/300)/1000000),"up: NUM\t", sum4;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte5*8/300)/1000000),"up: NUM\t", sum5;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte6*8/300)/1000000),"up: NUM\t", sum6;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte7*8/300)/1000000),"up: NUM\t", sum7;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte8*8/300)/1000000),"up: NUM\t", sum8;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte9*8/300)/1000000),"up: NUM\t", sum9;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte10*8/300)/1000000),"up: NUM\t", sum10;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte11*8/300)/1000000),"up: NUM\t", sum11;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte12*8/300)/1000000),"up: NUM\t", sum12;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte13*8/300)/1000000),"up: NUM\t", sum13;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte14*8/300)/1000000),"up: NUM\t", sum14;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte15*8/300)/1000000),"up: NUM\t", sum15;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte16*8/300)/1000000),"up: NUM\t", sum16;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte17*8/300)/1000000),"up: NUM\t", sum17;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte18*8/300)/1000000),"up: NUM\t", sum18;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte19*8/300)/1000000),"up: NUM\t", sum19;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte20*8/300)/1000000),"up: NUM\t", sum20;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte21*8/300)/1000000),"up: NUM\t", sum21;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte22*8/300)/1000000),"up: NUM\t", sum22;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte23*8/300)/1000000),"up: NUM\t", sum23;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte24*8/300)/1000000),"up: NUM\t", sum24;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte25*8/300)/1000000),"up: NUM\t", sum25;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte26*8/300)/1000000),"up: NUM\t", sum26;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte27*8/300)/1000000),"up: NUM\t", sum27;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte28*8/300)/1000000),"up: NUM\t", sum28;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","up: total_byte\t", ((total_byte29*8/300)/1000000),"up: NUM\t", sum29,"\n";

             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte32*8/300)/1000000),"down: NUM\t", sum32;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte33*8/300)/1000000),"down: NUM\t", sum33;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte34*8/300)/1000000),"down: NUM\t", sum34;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte35*8/300)/1000000),"down: NUM\t", sum35;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte36*8/300)/1000000),"down: NUM\t", sum36;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte37*8/300)/1000000),"down: NUM\t", sum37;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte38*8/300)/1000000),"down: NUM\t", sum38;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte39*8/300)/1000000),"down: NUM\t", sum39;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte40*8/300)/1000000),"down: NUM\t", sum40;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte41*8/300)/1000000),"down: NUM\t", sum41;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte42*8/300)/1000000),"down: NUM\t", sum42;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte43*8/300)/1000000),"down: NUM\t", sum43;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte44*8/300)/1000000),"down: NUM\t", sum44;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte45*8/300)/1000000),"down: NUM\t", sum45;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte46*8/300)/1000000),"down: NUM\t", sum46;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte47*8/300)/1000000),"down: NUM\t", sum47;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte48*8/300)/1000000),"down: NUM\t", sum48;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte49*8/300)/1000000),"down: NUM\t", sum49;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte50*8/300)/1000000),"down: NUM\t", sum50;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte51*8/300)/1000000),"down: NUM\t", sum51;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte52*8/300)/1000000),"down: NUM\t", sum52;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte53*8/300)/1000000),"down: NUM\t", sum53;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte54*8/300)/1000000),"down: NUM\t", sum54;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte55*8/300)/1000000),"down: NUM\t", sum55;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte56*8/300)/1000000),"down: NUM\t", sum56;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte57*8/300)/1000000),"down: NUM\t", sum57;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte58*8/300)/1000000),"down: NUM\t", sum58;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte59*8/300)/1000000),"down: NUM\t", sum59;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte60*8/300)/1000000),"down: NUM\t", sum60;
             print nn,":",nn,"_",nn1,"_",nn2,"\t","down: total_byte\t", ((total_byte61*8/300)/1000000),"down: NUM\t", sum61;
       }
 

 

 

 

###########################################################################

 30개 노드에 대한 tcl소스이다.
데이터 명은 data30.tcl이다.
###########################################################################
### This simulation is an example of combination of wired and wireless
### topologies.


global opt
set opt(chan)       Channel/WirelessChannel
set opt(prop)       Propagation/TwoRayGround
set opt(netif)      Phy/WirelessPhy
set opt(mac)        Mac/802_11
set opt(ifq)        Queue/DropTail/PriQueue
set opt(ll)         LL
set opt(ant)        Antenna/OmniAntenna
set opt(x)             500 
set opt(y)              500  
set opt(ifqlen)         50
set opt(adhocRouting)   DSDV;#AODV ;#DSDV, DSR                     
set opt(cp)             ""                       
set opt(sc)             "../mobility/scene/scen-3-test"  
set opt(stop)         500             
set num_wired_nodes      2
set num_bs_nodes         1
set opt(mn) 30 #노드 총 개수이다.
set cmin [lindex $argv 0]
set cmax [lindex $argv 1]

set opt(nm)           31 #AP 혹은 라우터를 포함한 개수

Agent/TCP set packetSize_ 1480
#  Mac/802_11 set RTSThreshold_ 99999 #RTS CTS 사용 안할시 주석처리 풀어준다.

   Mac/802_11 set dataRate_          11.0e6          ;# 11Mbps
   Mac/802_11 set basicRate_         11.0e6           ;# 1Mbps

# ===========================================================
# 802.11b value
#The Antenna height of transmitter and receiver is 1.5m.

Phy/WirelessPhy set bandwidth_ 11Mb


#===============================================================
set ns_   [new Simulator]
# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 2          ;# number of domains
lappend cluster_num 1 1                ;# number of clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel $opt(nm) $opt(nm)                 ;# number of nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;# of each domain
set tracefd  [open up_down_stream_$opt(mn)-$opt(mn)-$cmin-$cmax.tr w]
$ns_ trace-all $tracefd

# Create topography object
set topo   [new Topography]
# define topology
$topo load_flatgrid $opt(x) $opt(y)
# create God
create-god $opt(nm)

set temp {0.0.0 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 0.0.10 0.0.11 0.0.12 0.0.13 0.0.14 0.0.15 0.0.16 0.0.17 0.0.18 0.0.19 0.0.20  0.0.21 0.0.22 0.0.23 0.0.24 0.0.25 0.0.26 0.0.27 0.0.28 0.0.29 0.0.30 0.0.31 0.0.32 0.0.33 0.0.34 0.0.35 0.0.36 0.0.37 0.0.38 0.0.39 0.0.40 0.0.41 0.0.42 0.0.43 0.0.44 0.0.45 0.0.46 0.0.47 0.0.48 0.0.49 0.0.50 0.0.51 0.0.52 0.0.53 0.0.54 0.0.55 0.0.56  0.0.57 0.0.58 0.0.59 0.0.60 0.0.61 0.0.62 0.0.63 0.0.64 0.0.65 0.0.66 0.0.67 0.0.68 0.0.69 0.0.70 0.0.71 0.0.72 0.0.73 0.0.74 0.0.75 0.0.76 0.0.77 0.0.78 0.0.79 0.0.80}        ;# hierarchical addresses for wired domain
for {set i 0} {$i < $opt(nm)} {incr i} {
    set W($i) [$ns_ node [lindex $temp $i]]
}
Mac/802_11 set CWMin_ $cmin
Mac/802_11 set CWMax_ $cmax

#Mac/802_11 set ShortRetryLimit_         7            ;# retransmittions
#Mac/802_11 set LongRetryLimit_         4            ;# retransmissions
#재전송 수 제한을 풀어줄 때는 주석처리 제거 후 조절

$ns_ node-config -adhocRouting $opt(adhocRouting) \
                 -llType $opt(ll) \
                 -macType $opt(mac) \
                 -ifqType $opt(ifq) \
                 -ifqLen $opt(ifqlen) \
                 -antType $opt(ant) \
                 -propType $opt(prop) \
                 -phyType $opt(netif) \
                 -channelType $opt(chan) \
                 -topoInstance $topo \
                 -wiredRouting ON \
                 -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF \
  
 
 
     set temp {1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.47 1.0.48 1.0.49 1.0.50 1.0.51 1.0.52 1.0.53 1.0.54 1.0.55 1.0.56  1.0.57 1.0.58 1.0.59 1.0.60 1.0.61 1.0.62 1.0.63 1.0.64 1.0.65 1.0.66 1.0.67 1.0.68 1.0.69 1.0.70 1.0.71 1.0.72 1.0.73 1.0.74 1.0.75 1.0.76 1.0.77 1.0.78 1.0.79 1.0.80}  ;# hier address to be used for wireless
  
             set BS(0) [$ns_ node [lindex $temp 0]]
             $BS(0) random-motion 0
  #무선 AP에만 특정한 CWmin과 CWmax만을 적용해야 했으므로 무선 단말기 선언시에는 새로운 정보를 입력후 무선 환경을 재설정 한다.
 
Mac/802_11 set CWMin_ 31
Mac/802_11 set CWMax_ 1023

# Mac/802_11 set ShortRetryLimit_       7              ;# retransmittions
# Mac/802_11 set LongRetryLimit_        4               ;# retransmissions

$ns_ node-config -adhocRouting $opt(adhocRouting) \
                 -llType $opt(ll) \
                 -macType $opt(mac) \
                 -ifqType $opt(ifq) \
                 -ifqLen $opt(ifqlen) \
                 -antType $opt(ant) \
                 -propType $opt(prop) \
                 -phyType $opt(netif) \
                 -channelType $opt(chan) \
   -topoInstance $topo \
                 -wiredRouting ON \
   -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF \
  
          for {set j 0} {$j < $opt(mn)} {incr j} {
     set node_($j) [ $ns_ node [lindex $temp \
            [expr $j+1]] ]
      $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]]
        } 
       

 $ns_ duplex-link $W(0) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(1) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(2) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(3) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(4) $W(30) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(5) $W(30) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(6) $W(30) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(7) $W(30) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(8) $W(30) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(9) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(10) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(11) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(12) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(13) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(14) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(15) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(16) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(17) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(18) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(19) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(20) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(21) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(22) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(23) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(24) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(25) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(26) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(27) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(28) $W(30) 100Mb 100ms DropTail
 $ns_ duplex-link $W(29) $W(30) 100Mb 100ms DropTail

 

 $ns_ duplex-link $W(30) $BS(0)  100Mb 100ms DropTail 
      
   #중요한 내용... 각 라우터와 AP간의 전파 딜레이가 너무 짧으면 세그먼트 에러 출력될 가능성이 높다. 이유는 그냥 추측만.... 또한 for문을 사용하여 스크립트 작성시 세그먼트 에러 출력될 가능성이 높다. 물론 문제없이 작성하더라도 말이다. 이유는 전혀 모르겠다. ㅎ

#===============================================================
#down strem for TCP

 set tcp_(0) [new Agent/TCP/Reno]
 $tcp_(0) set class_ 2
 set sink_(0) [new Agent/TCPSink]
 $ns_ attach-agent $W(0) $tcp_(0)
 $ns_ attach-agent $node_(0) $sink_(0)
 $ns_ connect $tcp_(0) $sink_(0)
 set ftp_(0) [new Application/FTP]
 $ftp_(0) attach-agent $tcp_(0)
 $ns_ at 100 "$ftp_(0) start" 
 
 set tcp_(1) [new Agent/TCP/Reno]
 $tcp_(1) set class_ 2
 set sink_(1) [new Agent/TCPSink]
 $ns_ attach-agent $W(1) $tcp_(1)
 $ns_ attach-agent $node_(1) $sink_(1)
 $ns_ connect $tcp_(1) $sink_(1)
 set ftp_(1) [new Application/FTP]
 $ftp_(1) attach-agent $tcp_(1)
 $ns_ at 100 "$ftp_(1) start" 
 
 set tcp_(2) [new Agent/TCP/Reno]
 $tcp_(2) set class_ 2
 set sink_(2) [new Agent/TCPSink]
 $ns_ attach-agent $W(2) $tcp_(2)
 $ns_ attach-agent $node_(2) $sink_(2)
 $ns_ connect $tcp_(2) $sink_(2)
 set ftp_(2) [new Application/FTP]
 $ftp_(2) attach-agent $tcp_(2)
 $ns_ at 100 "$ftp_(2) start" 
 
 set tcp_(3) [new Agent/TCP/Reno]
 $tcp_(3) set class_ 2
 set sink_(3) [new Agent/TCPSink]
 $ns_ attach-agent $W(3) $tcp_(3)
 $ns_ attach-agent $node_(3) $sink_(3)
 $ns_ connect $tcp_(3) $sink_(3)
 set ftp_(3) [new Application/FTP]
 $ftp_(3) attach-agent $tcp_(3)
 $ns_ at 100 "$ftp_(3) start" 
 
 set tcp_(4) [new Agent/TCP/Reno]
 $tcp_(4) set class_ 2
 set sink_(4) [new Agent/TCPSink]
 $ns_ attach-agent $W(4) $tcp_(4)
 $ns_ attach-agent $node_(4) $sink_(4)
 $ns_ connect $tcp_(4) $sink_(4)
 set ftp_(4) [new Application/FTP]
 $ftp_(4) attach-agent $tcp_(4)
 $ns_ at 100 "$ftp_(4) start" 
 
 set tcp_(5) [new Agent/TCP/Reno]
 $tcp_(5) set class_ 2
 set sink_(5) [new Agent/TCPSink]
 $ns_ attach-agent $W(5) $tcp_(5)
 $ns_ attach-agent $node_(5) $sink_(5)
 $ns_ connect $tcp_(5) $sink_(5)
 set ftp_(5) [new Application/FTP]
 $ftp_(5) attach-agent $tcp_(5)
 $ns_ at 100 "$ftp_(5) start" 
 
 set tcp_(6) [new Agent/TCP/Reno]
 $tcp_(6) set class_ 2
 set sink_(6) [new Agent/TCPSink]
 $ns_ attach-agent $W(6) $tcp_(6)
 $ns_ attach-agent $node_(6) $sink_(6)
 $ns_ connect $tcp_(6) $sink_(6)
 set ftp_(6) [new Application/FTP]
 $ftp_(6) attach-agent $tcp_(6)
 $ns_ at 100 "$ftp_(6) start" 
 
 set tcp_(7) [new Agent/TCP/Reno]
 $tcp_(7) set class_ 2
 set sink_(7) [new Agent/TCPSink]
 $ns_ attach-agent $W(7) $tcp_(7)
 $ns_ attach-agent $node_(7) $sink_(7)
 $ns_ connect $tcp_(7) $sink_(7)
 set ftp_(7) [new Application/FTP]
 $ftp_(7) attach-agent $tcp_(7)
 $ns_ at 100 "$ftp_(7) start" 
 
 set tcp_(8) [new Agent/TCP/Reno]
 $tcp_(8) set class_ 2
 set sink_(8) [new Agent/TCPSink]
 $ns_ attach-agent $W(8) $tcp_(8)
 $ns_ attach-agent $node_(8) $sink_(8)
 $ns_ connect $tcp_(8) $sink_(8)
 set ftp_(8) [new Application/FTP]
 $ftp_(8) attach-agent $tcp_(8)
 $ns_ at 100 "$ftp_(8) start" 
 
 set tcp_(9) [new Agent/TCP/Reno]
 $tcp_(9) set class_ 2
 set sink_(9) [new Agent/TCPSink]
 $ns_ attach-agent $W(9) $tcp_(9)
 $ns_ attach-agent $node_(9) $sink_(9)
 $ns_ connect $tcp_(9) $sink_(9)
 set ftp_(9) [new Application/FTP]
 $ftp_(9) attach-agent $tcp_(9)
 $ns_ at 100 "$ftp_(9) start" 
 
 set tcp_(10) [new Agent/TCP/Reno]
 $tcp_(10) set class_ 2
 set sink_(10) [new Agent/TCPSink]
 $ns_ attach-agent $W(10) $tcp_(10)
 $ns_ attach-agent $node_(10) $sink_(10)
 $ns_ connect $tcp_(10) $sink_(10)
 set ftp_(10) [new Application/FTP]
 $ftp_(10) attach-agent $tcp_(10)
 $ns_ at 100 "$ftp_(10) start" 
 
 set tcp_(11) [new Agent/TCP/Reno]
 $tcp_(11) set class_ 2
 set sink_(11) [new Agent/TCPSink]
 $ns_ attach-agent $W(11) $tcp_(11)
 $ns_ attach-agent $node_(11) $sink_(11)
 $ns_ connect $tcp_(11) $sink_(11)
 set ftp_(11) [new Application/FTP]
 $ftp_(11) attach-agent $tcp_(11)
 $ns_ at 100 "$ftp_(11) start" 
 
 set tcp_(12) [new Agent/TCP/Reno]
 $tcp_(12) set class_ 2
 set sink_(12) [new Agent/TCPSink]
 $ns_ attach-agent $W(12) $tcp_(12)
 $ns_ attach-agent $node_(12) $sink_(12)
 $ns_ connect $tcp_(12) $sink_(12)
 set ftp_(12) [new Application/FTP]
 $ftp_(12) attach-agent $tcp_(12)
 $ns_ at 100 "$ftp_(12) start" 
 
 set tcp_(13) [new Agent/TCP/Reno]
 $tcp_(13) set class_ 2
 set sink_(13) [new Agent/TCPSink]
 $ns_ attach-agent $W(13) $tcp_(13)
 $ns_ attach-agent $node_(13) $sink_(13)
 $ns_ connect $tcp_(13) $sink_(13)
 set ftp_(13) [new Application/FTP]
 $ftp_(13) attach-agent $tcp_(13)
 $ns_ at 100 "$ftp_(13) start" 
 
 set tcp_(14) [new Agent/TCP/Reno]
 $tcp_(14) set class_ 2
 set sink_(14) [new Agent/TCPSink]
 $ns_ attach-agent $W(14) $tcp_(14)
 $ns_ attach-agent $node_(14) $sink_(14)
 $ns_ connect $tcp_(14) $sink_(14)
 set ftp_(14) [new Application/FTP]
 $ftp_(14) attach-agent $tcp_(14)
 $ns_ at 100 "$ftp_(14) start" 
 
 set tcp_(15) [new Agent/TCP/Reno]
 $tcp_(15) set class_ 2
 set sink_(15) [new Agent/TCPSink]
 $ns_ attach-agent $W(15) $tcp_(15)
 $ns_ attach-agent $node_(15) $sink_(15)
 $ns_ connect $tcp_(15) $sink_(15)
 set ftp_(15) [new Application/FTP]
 $ftp_(15) attach-agent $tcp_(15)
 $ns_ at 100 "$ftp_(15) start" 
 
 set tcp_(16) [new Agent/TCP/Reno]
 $tcp_(16) set class_ 2
 set sink_(16) [new Agent/TCPSink]
 $ns_ attach-agent $W(16) $tcp_(16)
 $ns_ attach-agent $node_(16) $sink_(16)
 $ns_ connect $tcp_(16) $sink_(16)
 set ftp_(16) [new Application/FTP]
 $ftp_(16) attach-agent $tcp_(16)
 $ns_ at 100 "$ftp_(16) start" 
 
 set tcp_(17) [new Agent/TCP/Reno]
 $tcp_(17) set class_ 2
 set sink_(17) [new Agent/TCPSink]
 $ns_ attach-agent $W(17) $tcp_(17)
 $ns_ attach-agent $node_(17) $sink_(17)
 $ns_ connect $tcp_(17) $sink_(17)
 set ftp_(17) [new Application/FTP]
 $ftp_(17) attach-agent $tcp_(17)
 $ns_ at 100 "$ftp_(17) start" 
 
 set tcp_(18) [new Agent/TCP/Reno]
 $tcp_(18) set class_ 2
 set sink_(18) [new Agent/TCPSink]
 $ns_ attach-agent $W(18) $tcp_(18)
 $ns_ attach-agent $node_(18) $sink_(18)
 $ns_ connect $tcp_(18) $sink_(18)
 set ftp_(18) [new Application/FTP]
 $ftp_(18) attach-agent $tcp_(18)
 $ns_ at 100 "$ftp_(18) start" 
 
 set tcp_(19) [new Agent/TCP/Reno]
 $tcp_(19) set class_ 2
 set sink_(19) [new Agent/TCPSink]
 $ns_ attach-agent $W(19) $tcp_(19)
 $ns_ attach-agent $node_(19) $sink_(19)
 $ns_ connect $tcp_(19) $sink_(19)
 set ftp_(19) [new Application/FTP]
 $ftp_(19) attach-agent $tcp_(19)
 $ns_ at 100 "$ftp_(19) start" 
 
 set tcp_(20) [new Agent/TCP/Reno]
 $tcp_(20) set class_ 2
 set sink_(20) [new Agent/TCPSink]
 $ns_ attach-agent $W(20) $tcp_(20)
 $ns_ attach-agent $node_(20) $sink_(20)
 $ns_ connect $tcp_(20) $sink_(20)
 set ftp_(20) [new Application/FTP]
 $ftp_(20) attach-agent $tcp_(20)
 $ns_ at 100 "$ftp_(20) start" 
 
 set tcp_(21) [new Agent/TCP/Reno]
 $tcp_(21) set class_ 2
 set sink_(21) [new Agent/TCPSink]
 $ns_ attach-agent $W(21) $tcp_(21)
 $ns_ attach-agent $node_(21) $sink_(21)
 $ns_ connect $tcp_(21) $sink_(21)
 set ftp_(21) [new Application/FTP]
 $ftp_(21) attach-agent $tcp_(21)
 $ns_ at 100 "$ftp_(21) start" 
 
 set tcp_(22) [new Agent/TCP/Reno]
 $tcp_(22) set class_ 2
 set sink_(22) [new Agent/TCPSink]
 $ns_ attach-agent $W(22) $tcp_(22)
 $ns_ attach-agent $node_(22) $sink_(22)
 $ns_ connect $tcp_(22) $sink_(22)
 set ftp_(22) [new Application/FTP]
 $ftp_(22) attach-agent $tcp_(22)
 $ns_ at 100 "$ftp_(22) start" 
 
 set tcp_(23) [new Agent/TCP/Reno]
 $tcp_(23) set class_ 2
 set sink_(23) [new Agent/TCPSink]
 $ns_ attach-agent $W(23) $tcp_(23)
 $ns_ attach-agent $node_(23) $sink_(23)
 $ns_ connect $tcp_(23) $sink_(23)
 set ftp_(23) [new Application/FTP]
 $ftp_(23) attach-agent $tcp_(23)
 $ns_ at 100 "$ftp_(23) start" 
 
 set tcp_(24) [new Agent/TCP/Reno]
 $tcp_(24) set class_ 2
 set sink_(24) [new Agent/TCPSink]
 $ns_ attach-agent $W(24) $tcp_(24)
 $ns_ attach-agent $node_(24) $sink_(24)
 $ns_ connect $tcp_(24) $sink_(24)
 set ftp_(24) [new Application/FTP]
 $ftp_(24) attach-agent $tcp_(24)
 $ns_ at 100 "$ftp_(24) start" 
 
 set tcp_(25) [new Agent/TCP/Reno]
 $tcp_(25) set class_ 2
 set sink_(25) [new Agent/TCPSink]
 $ns_ attach-agent $W(25) $tcp_(25)
 $ns_ attach-agent $node_(25) $sink_(25)
 $ns_ connect $tcp_(25) $sink_(25)
 set ftp_(25) [new Application/FTP]
 $ftp_(25) attach-agent $tcp_(25)
 $ns_ at 100 "$ftp_(25) start" 
 
 set tcp_(26) [new Agent/TCP/Reno]
 $tcp_(26) set class_ 2
 set sink_(26) [new Agent/TCPSink]
 $ns_ attach-agent $W(26) $tcp_(26)
 $ns_ attach-agent $node_(26) $sink_(26)
 $ns_ connect $tcp_(26) $sink_(26)
 set ftp_(26) [new Application/FTP]
 $ftp_(26) attach-agent $tcp_(26)
 $ns_ at 100 "$ftp_(26) start" 
 
 set tcp_(27) [new Agent/TCP/Reno]
 $tcp_(27) set class_ 2
 set sink_(27) [new Agent/TCPSink]
 $ns_ attach-agent $W(27) $tcp_(27)
 $ns_ attach-agent $node_(27) $sink_(27)
 $ns_ connect $tcp_(27) $sink_(27)
 set ftp_(27) [new Application/FTP]
 $ftp_(27) attach-agent $tcp_(27)
 $ns_ at 100 "$ftp_(27) start" 
 
 set tcp_(28) [new Agent/TCP/Reno]
 $tcp_(28) set class_ 2
 set sink_(28) [new Agent/TCPSink]
 $ns_ attach-agent $W(28) $tcp_(28)
 $ns_ attach-agent $node_(28) $sink_(28)
 $ns_ connect $tcp_(28) $sink_(28)
 set ftp_(28) [new Application/FTP]
 $ftp_(28) attach-agent $tcp_(28)
 $ns_ at 100 "$ftp_(28) start" 
 
 set tcp_(29) [new Agent/TCP/Reno]
 $tcp_(29) set class_ 2
 set sink_(29) [new Agent/TCPSink]
 $ns_ attach-agent $W(29) $tcp_(29)
 $ns_ attach-agent $node_(29) $sink_(29)
 $ns_ connect $tcp_(29) $sink_(29)
 set ftp_(29) [new Application/FTP]
 $ftp_(29) attach-agent $tcp_(29)
 $ns_ at 100 "$ftp_(29) start" 
 
 
 
 

#up stream for TCP
 
 set tcp_(60) [new Agent/TCP/Reno]
 $tcp_(60) set class_ 2
 set sink_(60) [new Agent/TCPSink]
 $ns_ attach-agent $node_(0) $tcp_(60)
 $ns_ attach-agent $W(0) $sink_(60)
 $ns_ connect $tcp_(60) $sink_(60)
 set ftp_(60) [new Application/FTP]
 $ftp_(60) attach-agent $tcp_(60)
 $ns_ at 100 "$ftp_(60) start" 
 
 set tcp_(61) [new Agent/TCP/Reno]
 $tcp_(61) set class_ 2
 set sink_(61) [new Agent/TCPSink]
 $ns_ attach-agent $node_(1) $tcp_(61)
 $ns_ attach-agent $W(1) $sink_(61)
 $ns_ connect $tcp_(61) $sink_(61)
 set ftp_(61) [new Application/FTP]
 $ftp_(61) attach-agent $tcp_(61)
 $ns_ at 100 "$ftp_(61) start" 
 
 set tcp_(62) [new Agent/TCP/Reno]
 $tcp_(62) set class_ 2
 set sink_(62) [new Agent/TCPSink]
 $ns_ attach-agent $node_(2) $tcp_(62)
 $ns_ attach-agent $W(2) $sink_(62)
 $ns_ connect $tcp_(62) $sink_(62)
 set ftp_(62) [new Application/FTP]
 $ftp_(62) attach-agent $tcp_(62)
 $ns_ at 100 "$ftp_(62) start" 
 
 set tcp_(63) [new Agent/TCP/Reno]
 $tcp_(63) set class_ 2
 set sink_(63) [new Agent/TCPSink]
 $ns_ attach-agent $node_(3) $tcp_(63)
 $ns_ attach-agent $W(3) $sink_(63)
 $ns_ connect $tcp_(63) $sink_(63)
 set ftp_(63) [new Application/FTP]
 $ftp_(63) attach-agent $tcp_(63)
 $ns_ at 100 "$ftp_(63) start" 
 
 set tcp_(64) [new Agent/TCP/Reno]
 $tcp_(64) set class_ 2
 set sink_(64) [new Agent/TCPSink]
 $ns_ attach-agent $node_(4) $tcp_(64)
 $ns_ attach-agent $W(4) $sink_(64)
 $ns_ connect $tcp_(64) $sink_(64)
 set ftp_(64) [new Application/FTP]
 $ftp_(64) attach-agent $tcp_(64)
 $ns_ at 100 "$ftp_(64) start" 
 
 set tcp_(65) [new Agent/TCP/Reno]
 $tcp_(65) set class_ 2
 set sink_(65) [new Agent/TCPSink]
 $ns_ attach-agent $node_(5) $tcp_(65)
 $ns_ attach-agent $W(5) $sink_(65)
 $ns_ connect $tcp_(65) $sink_(65)
 set ftp_(65) [new Application/FTP]
 $ftp_(65) attach-agent $tcp_(65)
 $ns_ at 100 "$ftp_(65) start" 
 
 set tcp_(66) [new Agent/TCP/Reno]
 $tcp_(66) set class_ 2
 set sink_(66) [new Agent/TCPSink]
 $ns_ attach-agent $node_(6) $tcp_(66)
 $ns_ attach-agent $W(6) $sink_(66)
 $ns_ connect $tcp_(66) $sink_(66)
 set ftp_(66) [new Application/FTP]
 $ftp_(66) attach-agent $tcp_(66)
 $ns_ at 100 "$ftp_(66) start" 
 
 set tcp_(67) [new Agent/TCP/Reno]
 $tcp_(67) set class_ 2
 set sink_(67) [new Agent/TCPSink]
 $ns_ attach-agent $node_(7) $tcp_(67)
 $ns_ attach-agent $W(7) $sink_(67)
 $ns_ connect $tcp_(67) $sink_(67)
 set ftp_(67) [new Application/FTP]
 $ftp_(67) attach-agent $tcp_(67)
 $ns_ at 100 "$ftp_(67) start" 
 
 set tcp_(68) [new Agent/TCP/Reno]
 $tcp_(68) set class_ 2
 set sink_(68) [new Agent/TCPSink]
 $ns_ attach-agent $node_(8) $tcp_(68)
 $ns_ attach-agent $W(8) $sink_(68)
 $ns_ connect $tcp_(68) $sink_(68)
 set ftp_(68) [new Application/FTP]
 $ftp_(68) attach-agent $tcp_(68)
 $ns_ at 100 "$ftp_(68) start" 
 
 set tcp_(69) [new Agent/TCP/Reno]
 $tcp_(69) set class_ 2
 set sink_(69) [new Agent/TCPSink]
 $ns_ attach-agent $node_(9) $tcp_(69)
 $ns_ attach-agent $W(9) $sink_(69)
 $ns_ connect $tcp_(69) $sink_(69)
 set ftp_(69) [new Application/FTP]
 $ftp_(69) attach-agent $tcp_(69)
 $ns_ at 100 "$ftp_(69) start" 
 
 set tcp_(70) [new Agent/TCP/Reno]
 $tcp_(70) set class_ 2
 set sink_(70) [new Agent/TCPSink]
 $ns_ attach-agent $node_(10) $tcp_(70)
 $ns_ attach-agent $W(10) $sink_(70)
 $ns_ connect $tcp_(70) $sink_(70)
 set ftp_(70) [new Application/FTP]
 $ftp_(70) attach-agent $tcp_(70)
 $ns_ at 100 "$ftp_(70) start"
 
 set tcp_(71) [new Agent/TCP/Reno]
 $tcp_(71) set class_ 2
 set sink_(71) [new Agent/TCPSink]
 $ns_ attach-agent $node_(11) $tcp_(71)
 $ns_ attach-agent $W(11) $sink_(71)
 $ns_ connect $tcp_(71) $sink_(71)
 set ftp_(71) [new Application/FTP]
 $ftp_(71) attach-agent $tcp_(71)
 $ns_ at 100 "$ftp_(71) start"
 
 set tcp_(72) [new Agent/TCP/Reno]
 $tcp_(72) set class_ 2
 set sink_(72) [new Agent/TCPSink]
 $ns_ attach-agent $node_(12) $tcp_(72)
 $ns_ attach-agent $W(12) $sink_(72)
 $ns_ connect $tcp_(72) $sink_(72)
 set ftp_(72) [new Application/FTP]
 $ftp_(72) attach-agent $tcp_(72)
 $ns_ at 100 "$ftp_(72) start"
 
 set tcp_(73) [new Agent/TCP/Reno]
 $tcp_(73) set class_ 2
 set sink_(73) [new Agent/TCPSink]
 $ns_ attach-agent $node_(13) $tcp_(73)
 $ns_ attach-agent $W(13) $sink_(73)
 $ns_ connect $tcp_(73) $sink_(73)
 set ftp_(73) [new Application/FTP]
 $ftp_(73) attach-agent $tcp_(73)
 $ns_ at 100 "$ftp_(73) start"
 
 set tcp_(74) [new Agent/TCP/Reno]
 $tcp_(74) set class_ 2
 set sink_(74) [new Agent/TCPSink]
 $ns_ attach-agent $node_(14) $tcp_(74)
 $ns_ attach-agent $W(14) $sink_(74)
 $ns_ connect $tcp_(74) $sink_(74)
 set ftp_(74) [new Application/FTP]
 $ftp_(74) attach-agent $tcp_(74)
 $ns_ at 100 "$ftp_(74) start"
 
 set tcp_(75) [new Agent/TCP/Reno]
 $tcp_(75) set class_ 2
 set sink_(75) [new Agent/TCPSink]
 $ns_ attach-agent $node_(15) $tcp_(75)
 $ns_ attach-agent $W(15) $sink_(75)
 $ns_ connect $tcp_(75) $sink_(75)
 set ftp_(75) [new Application/FTP]
 $ftp_(75) attach-agent $tcp_(75)
 $ns_ at 100 "$ftp_(75) start"
 
 set tcp_(76) [new Agent/TCP/Reno]
 $tcp_(76) set class_ 2
 set sink_(76) [new Agent/TCPSink]
 $ns_ attach-agent $node_(16) $tcp_(76)
 $ns_ attach-agent $W(16) $sink_(76)
 $ns_ connect $tcp_(76) $sink_(76)
 set ftp_(76) [new Application/FTP]
 $ftp_(76) attach-agent $tcp_(76)
 $ns_ at 100 "$ftp_(76) start"
 
 set tcp_(77) [new Agent/TCP/Reno]
 $tcp_(77) set class_ 2
 set sink_(77) [new Agent/TCPSink]
 $ns_ attach-agent $node_(17) $tcp_(77)
 $ns_ attach-agent $W(17) $sink_(77)
 $ns_ connect $tcp_(77) $sink_(77)
 set ftp_(77) [new Application/FTP]
 $ftp_(77) attach-agent $tcp_(77)
 $ns_ at 100 "$ftp_(77) start"
 
 set tcp_(78) [new Agent/TCP/Reno]
 $tcp_(78) set class_ 2
 set sink_(78) [new Agent/TCPSink]
 $ns_ attach-agent $node_(18) $tcp_(78)
 $ns_ attach-agent $W(18) $sink_(78)
 $ns_ connect $tcp_(78) $sink_(78)
 set ftp_(78) [new Application/FTP]
 $ftp_(78) attach-agent $tcp_(78)
 $ns_ at 100 "$ftp_(78) start"
 
 set tcp_(79) [new Agent/TCP/Reno]
 $tcp_(79) set class_ 2
 set sink_(79) [new Agent/TCPSink]
 $ns_ attach-agent $node_(19) $tcp_(79)
 $ns_ attach-agent $W(19) $sink_(79)
 $ns_ connect $tcp_(79) $sink_(79)
 set ftp_(79) [new Application/FTP]
 $ftp_(79) attach-agent $tcp_(79)
 $ns_ at 100 "$ftp_(79) start"
 
 set tcp_(80) [new Agent/TCP/Reno]
 $tcp_(80) set class_ 2
 set sink_(80) [new Agent/TCPSink]
 $ns_ attach-agent $node_(20) $tcp_(80)
 $ns_ attach-agent $W(20) $sink_(80)
 $ns_ connect $tcp_(80) $sink_(80)
 set ftp_(80) [new Application/FTP]
 $ftp_(80) attach-agent $tcp_(80)
 $ns_ at 100 "$ftp_(80) start"
 
 set tcp_(81) [new Agent/TCP/Reno]
 $tcp_(81) set class_ 2
 set sink_(81) [new Agent/TCPSink]
 $ns_ attach-agent $node_(21) $tcp_(81)
 $ns_ attach-agent $W(21) $sink_(81)
 $ns_ connect $tcp_(81) $sink_(81)
 set ftp_(81) [new Application/FTP]
 $ftp_(81) attach-agent $tcp_(81)
 $ns_ at 100 "$ftp_(81) start"
 
 set tcp_(82) [new Agent/TCP/Reno]
 $tcp_(82) set class_ 2
 set sink_(82) [new Agent/TCPSink]
 $ns_ attach-agent $node_(22) $tcp_(82)
 $ns_ attach-agent $W(22) $sink_(82)
 $ns_ connect $tcp_(82) $sink_(82)
 set ftp_(82) [new Application/FTP]
 $ftp_(82) attach-agent $tcp_(82)
 $ns_ at 100 "$ftp_(82) start"
 
 set tcp_(83) [new Agent/TCP/Reno]
 $tcp_(83) set class_ 2
 set sink_(83) [new Agent/TCPSink]
 $ns_ attach-agent $node_(23) $tcp_(83)
 $ns_ attach-agent $W(23) $sink_(83)
 $ns_ connect $tcp_(83) $sink_(83)
 set ftp_(83) [new Application/FTP]
 $ftp_(83) attach-agent $tcp_(83)
 $ns_ at 100 "$ftp_(83) start"
 
 set tcp_(84) [new Agent/TCP/Reno]
 $tcp_(84) set class_ 2
 set sink_(84) [new Agent/TCPSink]
 $ns_ attach-agent $node_(24) $tcp_(84)
 $ns_ attach-agent $W(24) $sink_(84)
 $ns_ connect $tcp_(84) $sink_(84)
 set ftp_(84) [new Application/FTP]
 $ftp_(84) attach-agent $tcp_(84)
 $ns_ at 100 "$ftp_(84) start"
 
 set tcp_(85) [new Agent/TCP/Reno]
 $tcp_(85) set class_ 2
 set sink_(85) [new Agent/TCPSink]
 $ns_ attach-agent $node_(25) $tcp_(85)
 $ns_ attach-agent $W(25) $sink_(85)
 $ns_ connect $tcp_(85) $sink_(85)
 set ftp_(85) [new Application/FTP]
 $ftp_(85) attach-agent $tcp_(85)
 $ns_ at 100 "$ftp_(85) start"
 
 set tcp_(86) [new Agent/TCP/Reno]
 $tcp_(86) set class_ 2
 set sink_(86) [new Agent/TCPSink]
 $ns_ attach-agent $node_(26) $tcp_(86)
 $ns_ attach-agent $W(26) $sink_(86)
 $ns_ connect $tcp_(86) $sink_(86)
 set ftp_(86) [new Application/FTP]
 $ftp_(86) attach-agent $tcp_(86)
 $ns_ at 100 "$ftp_(86) start"
 
 set tcp_(87) [new Agent/TCP/Reno]
 $tcp_(87) set class_ 2
 set sink_(87) [new Agent/TCPSink]
 $ns_ attach-agent $node_(27) $tcp_(87)
 $ns_ attach-agent $W(27) $sink_(87)
 $ns_ connect $tcp_(87) $sink_(87)
 set ftp_(87) [new Application/FTP]
 $ftp_(87) attach-agent $tcp_(87)
 $ns_ at 100 "$ftp_(87) start"
 
 set tcp_(88) [new Agent/TCP/Reno]
 $tcp_(88) set class_ 2
 set sink_(88) [new Agent/TCPSink]
 $ns_ attach-agent $node_(28) $tcp_(88)
 $ns_ attach-agent $W(28) $sink_(88)
 $ns_ connect $tcp_(88) $sink_(88)
 set ftp_(88) [new Application/FTP]
 $ftp_(88) attach-agent $tcp_(88)
 $ns_ at 100 "$ftp_(88) start"
 
 set tcp_(89) [new Agent/TCP/Reno]
 $tcp_(89) set class_ 2
 set sink_(89) [new Agent/TCPSink]
 $ns_ attach-agent $node_(29) $tcp_(89)
 $ns_ attach-agent $W(29) $sink_(89)
 $ns_ connect $tcp_(89) $sink_(89)
 set ftp_(89) [new Application/FTP]
 $ftp_(89) attach-agent $tcp_(89)
 $ns_ at 100 "$ftp_(89) start"
 
 
 
 
 
 
 
  #================================================

     $ns_ at $opt(stop).0 "$BS(0) reset";
      for {set t 0} {$t < $opt(mn)} {incr t} {
       $ns_ at $opt(stop).0000010 "$node_($t) reset";
        } 
 


$ns_ at $opt(stop).1 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"
proc stop {} {
    global ns_ tracefd
#    global ns_ namtracefd
    close $tracefd
#    close $namtracefd
}

# informative headers for CMUTracefile
#puts $tracefd "M 0.0 nn $opt(nm) x $opt(x) y $opt(y) rp \
# $opt(adhocRouting)"
#puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed $opt(seed)"
#puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)"

puts "Starting Simulation..."
$ns_ run

 
############################################################################
다음은 40개의 노드에 대한 tcl 파일이다.
파일명은 data40.tcl이다.

 ###########################################################################

### This simulation is an example of combination of wired and wireless
### topologies.


global opt
set opt(chan)       Channel/WirelessChannel
set opt(prop)       Propagation/TwoRayGround
set opt(netif)      Phy/WirelessPhy
set opt(mac)        Mac/802_11
set opt(ifq)        Queue/DropTail/PriQueue
set opt(ll)         LL
set opt(ant)        Antenna/OmniAntenna
set opt(x)             500 
set opt(y)              500  
set opt(ifqlen)         50
set opt(adhocRouting)   DSDV;#AODV ;#DSDV, DSR                     
set opt(cp)             ""                       
set opt(sc)             "../mobility/scene/scen-3-test"  
set opt(stop)         500             
set num_wired_nodes      2
set num_bs_nodes         1
set opt(mn) 40
set cmin [lindex $argv 0]
set cmax [lindex $argv 1]

set opt(nm)           41

Agent/TCP set packetSize_ 1480
#  Mac/802_11 set RTSThreshold_ 99999

   Mac/802_11 set dataRate_          11.0e6          ;# 11Mbps
   Mac/802_11 set basicRate_         11.0e6           ;# 1Mbps

# ===========================================================
# 802.11b value
#The Antenna height of transmitter and receiver is 1.5m.

Phy/WirelessPhy set bandwidth_ 11Mb


#===============================================================
set ns_   [new Simulator]
# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 2          ;# number of domains
lappend cluster_num 1 1                ;# number of clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel $opt(nm) $opt(nm)                 ;# number of nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;# of each domain
set tracefd  [open up_down_stream_$opt(mn)-$opt(mn)-$cmin-$cmax.tr w]
$ns_ trace-all $tracefd

# Create topography object
set topo   [new Topography]
# define topology
$topo load_flatgrid $opt(x) $opt(y)
# create God
create-god $opt(nm)

set temp {0.0.0 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 0.0.10 0.0.11 0.0.12 0.0.13 0.0.14 0.0.15 0.0.16 0.0.17 0.0.18 0.0.19 0.0.20  0.0.21 0.0.22 0.0.23 0.0.24 0.0.25 0.0.26 0.0.27 0.0.28 0.0.29 0.0.30 0.0.31 0.0.32 0.0.33 0.0.34 0.0.35 0.0.36 0.0.37 0.0.38 0.0.39 0.0.40 0.0.41 0.0.42 0.0.43 0.0.44 0.0.45 0.0.46 0.0.47 0.0.48 0.0.49 0.0.50 0.0.51 0.0.52 0.0.53 0.0.54 0.0.55 0.0.56  0.0.57 0.0.58 0.0.59 0.0.60 0.0.61 0.0.62 0.0.63 0.0.64 0.0.65 0.0.66 0.0.67 0.0.68 0.0.69 0.0.70 0.0.71 0.0.72 0.0.73 0.0.74 0.0.75 0.0.76 0.0.77 0.0.78 0.0.79 0.0.80}        ;# hierarchical addresses for wired domain
for {set i 0} {$i < $opt(nm)} {incr i} {
    set W($i) [$ns_ node [lindex $temp $i]]
}
Mac/802_11 set CWMin_ $cmin
Mac/802_11 set CWMax_ $cmax
puts "CW value : $cmin $cmax"

#Mac/802_11 set ShortRetryLimit_         7            ;# retransmittions
#Mac/802_11 set LongRetryLimit_         4            ;# retransmissions

$ns_ node-config -adhocRouting $opt(adhocRouting) \
                 -llType $opt(ll) \
                 -macType $opt(mac) \
                 -ifqType $opt(ifq) \
                 -ifqLen $opt(ifqlen) \
                 -antType $opt(ant) \
                 -propType $opt(prop) \
                 -phyType $opt(netif) \
                 -channelType $opt(chan) \
   -topoInstance $topo \
                 -wiredRouting ON \
   -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF \
  
 
 
     set temp {1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.47 1.0.48 1.0.49 1.0.50 1.0.51 1.0.52 1.0.53 1.0.54 1.0.55 1.0.56  1.0.57 1.0.58 1.0.59 1.0.60 1.0.61 1.0.62 1.0.63 1.0.64 1.0.65 1.0.66 1.0.67 1.0.68 1.0.69 1.0.70 1.0.71 1.0.72 1.0.73 1.0.74 1.0.75 1.0.76 1.0.77 1.0.78 1.0.79 1.0.80}  ;# hier address to be used for wireless
  
             set BS(0) [$ns_ node [lindex $temp 0]]
             $BS(0) random-motion 0
 
 
Mac/802_11 set CWMin_ 31
Mac/802_11 set CWMax_ 1023

# Mac/802_11 set ShortRetryLimit_       7              ;# retransmittions
# Mac/802_11 set LongRetryLimit_        4               ;# retransmissions

$ns_ node-config -adhocRouting $opt(adhocRouting) \
                 -llType $opt(ll) \
                 -macType $opt(mac) \
                 -ifqType $opt(ifq) \
                 -ifqLen $opt(ifqlen) \
                 -antType $opt(ant) \
                 -propType $opt(prop) \
                 -phyType $opt(netif) \
                 -channelType $opt(chan) \
   -topoInstance $topo \
                 -wiredRouting ON \
   -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF \
  
          for {set j 0} {$j < $opt(mn)} {incr j} {
     set node_($j) [ $ns_ node [lindex $temp \
            [expr $j+1]] ]
      $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]]
        } 
       

 $ns_ duplex-link $W(0) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(1) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(2) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(3) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(4) $W(40) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(5) $W(40) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(6) $W(40) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(7) $W(40) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(8) $W(40) 100Mb 100ms DropTail  
 $ns_ duplex-link $W(9) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(10) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(11) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(12) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(13) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(14) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(15) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(16) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(17) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(18) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(19) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(20) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(21) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(22) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(23) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(24) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(25) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(26) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(27) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(28) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(29) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(30) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(31) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(32) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(33) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(34) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(35) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(36) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(37) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(38) $W(40) 100Mb 100ms DropTail
 $ns_ duplex-link $W(39) $W(40) 100Mb 100ms DropTail
 
 

 

 $ns_ duplex-link $W(40) $BS(0)  100Mb 100ms DropTail 
      
  

#===============================================================
#down strem for TCP

 set tcp_(0) [new Agent/TCP/Reno]
 $tcp_(0) set class_ 2
 set sink_(0) [new Agent/TCPSink]
 $ns_ attach-agent $W(0) $tcp_(0)
 $ns_ attach-agent $node_(0) $sink_(0)
 $ns_ connect $tcp_(0) $sink_(0)
 set ftp_(0) [new Application/FTP]
 $ftp_(0) attach-agent $tcp_(0)
 $ns_ at 100 "$ftp_(0) start" 
 
 set tcp_(1) [new Agent/TCP/Reno]
 $tcp_(1) set class_ 2
 set sink_(1) [new Agent/TCPSink]
 $ns_ attach-agent $W(1) $tcp_(1)
 $ns_ attach-agent $node_(1) $sink_(1)
 $ns_ connect $tcp_(1) $sink_(1)
 set ftp_(1) [new Application/FTP]
 $ftp_(1) attach-agent $tcp_(1)
 $ns_ at 100 "$ftp_(1) start" 
 
 set tcp_(2) [new Agent/TCP/Reno]
 $tcp_(2) set class_ 2
 set sink_(2) [new Agent/TCPSink]
 $ns_ attach-agent $W(2) $tcp_(2)
 $ns_ attach-agent $node_(2) $sink_(2)
 $ns_ connect $tcp_(2) $sink_(2)
 set ftp_(2) [new Application/FTP]
 $ftp_(2) attach-agent $tcp_(2)
 $ns_ at 100 "$ftp_(2) start" 
 
 set tcp_(3) [new Agent/TCP/Reno]
 $tcp_(3) set class_ 2
 set sink_(3) [new Agent/TCPSink]
 $ns_ attach-agent $W(3) $tcp_(3)
 $ns_ attach-agent $node_(3) $sink_(3)
 $ns_ connect $tcp_(3) $sink_(3)
 set ftp_(3) [new Application/FTP]
 $ftp_(3) attach-agent $tcp_(3)
 $ns_ at 100 "$ftp_(3) start" 
 
 set tcp_(4) [new Agent/TCP/Reno]
 $tcp_(4) set class_ 2
 set sink_(4) [new Agent/TCPSink]
 $ns_ attach-agent $W(4) $tcp_(4)
 $ns_ attach-agent $node_(4) $sink_(4)
 $ns_ connect $tcp_(4) $sink_(4)
 set ftp_(4) [new Application/FTP]
 $ftp_(4) attach-agent $tcp_(4)
 $ns_ at 100 "$ftp_(4) start" 
 
 set tcp_(5) [new Agent/TCP/Reno]
 $tcp_(5) set class_ 2
 set sink_(5) [new Agent/TCPSink]
 $ns_ attach-agent $W(5) $tcp_(5)
 $ns_ attach-agent $node_(5) $sink_(5)
 $ns_ connect $tcp_(5) $sink_(5)
 set ftp_(5) [new Application/FTP]
 $ftp_(5) attach-agent $tcp_(5)
 $ns_ at 100 "$ftp_(5) start" 
 
 set tcp_(6) [new Agent/TCP/Reno]
 $tcp_(6) set class_ 2
 set sink_(6) [new Agent/TCPSink]
 $ns_ attach-agent $W(6) $tcp_(6)
 $ns_ attach-agent $node_(6) $sink_(6)
 $ns_ connect $tcp_(6) $sink_(6)
 set ftp_(6) [new Application/FTP]
 $ftp_(6) attach-agent $tcp_(6)
 $ns_ at 100 "$ftp_(6) start" 
 
 set tcp_(7) [new Agent/TCP/Reno]
 $tcp_(7) set class_ 2
 set sink_(7) [new Agent/TCPSink]
 $ns_ attach-agent $W(7) $tcp_(7)
 $ns_ attach-agent $node_(7) $sink_(7)
 $ns_ connect $tcp_(7) $sink_(7)
 set ftp_(7) [new Application/FTP]
 $ftp_(7) attach-agent $tcp_(7)
 $ns_ at 100 "$ftp_(7) start" 
 
 set tcp_(8) [new Agent/TCP/Reno]
 $tcp_(8) set class_ 2
 set sink_(8) [new Agent/TCPSink]
 $ns_ attach-agent $W(8) $tcp_(8)
 $ns_ attach-agent $node_(8) $sink_(8)
 $ns_ connect $tcp_(8) $sink_(8)
 set ftp_(8) [new Application/FTP]
 $ftp_(8) attach-agent $tcp_(8)
 $ns_ at 100 "$ftp_(8) start" 
 
 set tcp_(9) [new Agent/TCP/Reno]
 $tcp_(9) set class_ 2
 set sink_(9) [new Agent/TCPSink]
 $ns_ attach-agent $W(9) $tcp_(9)
 $ns_ attach-agent $node_(9) $sink_(9)
 $ns_ connect $tcp_(9) $sink_(9)
 set ftp_(9) [new Application/FTP]
 $ftp_(9) attach-agent $tcp_(9)
 $ns_ at 100 "$ftp_(9) start" 
 
 set tcp_(10) [new Agent/TCP/Reno]
 $tcp_(10) set class_ 2
 set sink_(10) [new Agent/TCPSink]
 $ns_ attach-agent $W(10) $tcp_(10)
 $ns_ attach-agent $node_(10) $sink_(10)
 $ns_ connect $tcp_(10) $sink_(10)
 set ftp_(10) [new Application/FTP]
 $ftp_(10) attach-agent $tcp_(10)
 $ns_ at 100 "$ftp_(10) start" 
 
 set tcp_(11) [new Agent/TCP/Reno]
 $tcp_(11) set class_ 2
 set sink_(11) [new Agent/TCPSink]
 $ns_ attach-agent $W(11) $tcp_(11)
 $ns_ attach-agent $node_(11) $sink_(11)
 $ns_ connect $tcp_(11) $sink_(11)
 set ftp_(11) [new Application/FTP]
 $ftp_(11) attach-agent $tcp_(11)
 $ns_ at 100 "$ftp_(11) start" 
 
 set tcp_(12) [new Agent/TCP/Reno]
 $tcp_(12) set class_ 2
 set sink_(12) [new Agent/TCPSink]
 $ns_ attach-agent $W(12) $tcp_(12)
 $ns_ attach-agent $node_(12) $sink_(12)
 $ns_ connect $tcp_(12) $sink_(12)
 set ftp_(12) [new Application/FTP]
 $ftp_(12) attach-agent $tcp_(12)
 $ns_ at 100 "$ftp_(12) start" 
 
 set tcp_(13) [new Agent/TCP/Reno]
 $tcp_(13) set class_ 2
 set sink_(13) [new Agent/TCPSink]
 $ns_ attach-agent $W(13) $tcp_(13)
 $ns_ attach-agent $node_(13) $sink_(13)
 $ns_ connect $tcp_(13) $sink_(13)
 set ftp_(13) [new Application/FTP]
 $ftp_(13) attach-agent $tcp_(13)
 $ns_ at 100 "$ftp_(13) start" 
 
 set tcp_(14) [new Agent/TCP/Reno]
 $tcp_(14) set class_ 2
 set sink_(14) [new Agent/TCPSink]
 $ns_ attach-agent $W(14) $tcp_(14)
 $ns_ attach-agent $node_(14) $sink_(14)
 $ns_ connect $tcp_(14) $sink_(14)
 set ftp_(14) [new Application/FTP]
 $ftp_(14) attach-agent $tcp_(14)
 $ns_ at 100 "$ftp_(14) start" 
 
 set tcp_(15) [new Agent/TCP/Reno]
 $tcp_(15) set class_ 2
 set sink_(15) [new Agent/TCPSink]
 $ns_ attach-agent $W(15) $tcp_(15)
 $ns_ attach-agent $node_(15) $sink_(15)
 $ns_ connect $tcp_(15) $sink_(15)
 set ftp_(15) [new Application/FTP]
 $ftp_(15) attach-agent $tcp_(15)
 $ns_ at 100 "$ftp_(15) start" 
 
 set tcp_(16) [new Agent/TCP/Reno]
 $tcp_(16) set class_ 2
 set sink_(16) [new Agent/TCPSink]
 $ns_ attach-agent $W(16) $tcp_(16)
 $ns_ attach-agent $node_(16) $sink_(16)
 $ns_ connect $tcp_(16) $sink_(16)
 set ftp_(16) [new Application/FTP]
 $ftp_(16) attach-agent $tcp_(16)
 $ns_ at 100 "$ftp_(16) start" 
 
 set tcp_(17) [new Agent/TCP/Reno]
 $tcp_(17) set class_ 2
 set sink_(17) [new Agent/TCPSink]
 $ns_ attach-agent $W(17) $tcp_(17)
 $ns_ attach-agent $node_(17) $sink_(17)
 $ns_ connect $tcp_(17) $sink_(17)
 set ftp_(17) [new Application/FTP]
 $ftp_(17) attach-agent $tcp_(17)
 $ns_ at 100 "$ftp_(17) start" 
 
 set tcp_(18) [new Agent/TCP/Reno]
 $tcp_(18) set class_ 2
 set sink_(18) [new Agent/TCPSink]
 $ns_ attach-agent $W(18) $tcp_(18)
 $ns_ attach-agent $node_(18) $sink_(18)
 $ns_ connect $tcp_(18) $sink_(18)
 set ftp_(18) [new Application/FTP]
 $ftp_(18) attach-agent $tcp_(18)
 $ns_ at 100 "$ftp_(18) start" 
 
 set tcp_(19) [new Agent/TCP/Reno]
 $tcp_(19) set class_ 2
 set sink_(19) [new Agent/TCPSink]
 $ns_ attach-agent $W(19) $tcp_(19)
 $ns_ attach-agent $node_(19) $sink_(19)
 $ns_ connect $tcp_(19) $sink_(19)
 set ftp_(19) [new Application/FTP]
 $ftp_(19) attach-agent $tcp_(19)
 $ns_ at 100 "$ftp_(19) start" 
 
 set tcp_(20) [new Agent/TCP/Reno]
 $tcp_(20) set class_ 2
 set sink_(20) [new Agent/TCPSink]
 $ns_ attach-agent $W(20) $tcp_(20)
 $ns_ attach-agent $node_(20) $sink_(20)
 $ns_ connect $tcp_(20) $sink_(20)
 set ftp_(20) [new Application/FTP]
 $ftp_(20) attach-agent $tcp_(20)
 $ns_ at 100 "$ftp_(20) start" 
 
 set tcp_(21) [new Agent/TCP/Reno]
 $tcp_(21) set class_ 2
 set sink_(21) [new Agent/TCPSink]
 $ns_ attach-agent $W(21) $tcp_(21)
 $ns_ attach-agent $node_(21) $sink_(21)
 $ns_ connect $tcp_(21) $sink_(21)
 set ftp_(21) [new Application/FTP]
 $ftp_(21) attach-agent $tcp_(21)
 $ns_ at 100 "$ftp_(21) start" 
 
 set tcp_(22) [new Agent/TCP/Reno]
 $tcp_(22) set class_ 2
 set sink_(22) [new Agent/TCPSink]
 $ns_ attach-agent $W(22) $tcp_(22)
 $ns_ attach-agent $node_(22) $sink_(22)
 $ns_ connect $tcp_(22) $sink_(22)
 set ftp_(22) [new Application/FTP]
 $ftp_(22) attach-agent $tcp_(22)
 $ns_ at 100 "$ftp_(22) start" 
 
 set tcp_(23) [new Agent/TCP/Reno]
 $tcp_(23) set class_ 2
 set sink_(23) [new Agent/TCPSink]
 $ns_ attach-agent $W(23) $tcp_(23)
 $ns_ attach-agent $node_(23) $sink_(23)
 $ns_ connect $tcp_(23) $sink_(23)
 set ftp_(23) [new Application/FTP]
 $ftp_(23) attach-agent $tcp_(23)
 $ns_ at 100 "$ftp_(23) start" 
 
 set tcp_(24) [new Agent/TCP/Reno]
 $tcp_(24) set class_ 2
 set sink_(24) [new Agent/TCPSink]
 $ns_ attach-agent $W(24) $tcp_(24)
 $ns_ attach-agent $node_(24) $sink_(24)
 $ns_ connect $tcp_(24) $sink_(24)
 set ftp_(24) [new Application/FTP]
 $ftp_(24) attach-agent $tcp_(24)
 $ns_ at 100 "$ftp_(24) start" 
 
 set tcp_(25) [new Agent/TCP/Reno]
 $tcp_(25) set class_ 2
 set sink_(25) [new Agent/TCPSink]
 $ns_ attach-agent $W(25) $tcp_(25)
 $ns_ attach-agent $node_(25) $sink_(25)
 $ns_ connect $tcp_(25) $sink_(25)
 set ftp_(25) [new Application/FTP]
 $ftp_(25) attach-agent $tcp_(25)
 $ns_ at 100 "$ftp_(25) start" 
 
 set tcp_(26) [new Agent/TCP/Reno]
 $tcp_(26) set class_ 2
 set sink_(26) [new Agent/TCPSink]
 $ns_ attach-agent $W(26) $tcp_(26)
 $ns_ attach-agent $node_(26) $sink_(26)
 $ns_ connect $tcp_(26) $sink_(26)
 set ftp_(26) [new Application/FTP]
 $ftp_(26) attach-agent $tcp_(26)
 $ns_ at 100 "$ftp_(26) start" 
 
 set tcp_(27) [new Agent/TCP/Reno]
 $tcp_(27) set class_ 2
 set sink_(27) [new Agent/TCPSink]
 $ns_ attach-agent $W(27) $tcp_(27)
 $ns_ attach-agent $node_(27) $sink_(27)
 $ns_ connect $tcp_(27) $sink_(27)
 set ftp_(27) [new Application/FTP]
 $ftp_(27) attach-agent $tcp_(27)
 $ns_ at 100 "$ftp_(27) start" 
 
 set tcp_(28) [new Agent/TCP/Reno]
 $tcp_(28) set class_ 2
 set sink_(28) [new Agent/TCPSink]
 $ns_ attach-agent $W(28) $tcp_(28)
 $ns_ attach-agent $node_(28) $sink_(28)
 $ns_ connect $tcp_(28) $sink_(28)
 set ftp_(28) [new Application/FTP]
 $ftp_(28) attach-agent $tcp_(28)
 $ns_ at 100 "$ftp_(28) start" 
 
 set tcp_(29) [new Agent/TCP/Reno]
 $tcp_(29) set class_ 2
 set sink_(29) [new Agent/TCPSink]
 $ns_ attach-agent $W(29) $tcp_(29)
 $ns_ attach-agent $node_(29) $sink_(29)
 $ns_ connect $tcp_(29) $sink_(29)
 set ftp_(29) [new Application/FTP]
 $ftp_(29) attach-agent $tcp_(29)
 $ns_ at 100 "$ftp_(29) start" 
 
 set tcp_(30) [new Agent/TCP/Reno]
 $tcp_(30) set class_ 2
 set sink_(30) [new Agent/TCPSink]
 $ns_ attach-agent $W(30) $tcp_(30)
 $ns_ attach-agent $node_(30) $sink_(30)
 $ns_ connect $tcp_(30) $sink_(30)
 set ftp_(30) [new Application/FTP]
 $ftp_(30) attach-agent $tcp_(30)
 $ns_ at 100 "$ftp_(30) start"
 
 set tcp_(31) [new Agent/TCP/Reno]
 $tcp_(31) set class_ 2
 set sink_(31) [new Agent/TCPSink]
 $ns_ attach-agent $W(31) $tcp_(31)
 $ns_ attach-agent $node_(31) $sink_(31)
 $ns_ connect $tcp_(31) $sink_(31)
 set ftp_(31) [new Application/FTP]
 $ftp_(31) attach-agent $tcp_(31)
 $ns_ at 100 "$ftp_(31) start"
 
 set tcp_(32) [new Agent/TCP/Reno]
 $tcp_(32) set class_ 2
 set sink_(32) [new Agent/TCPSink]
 $ns_ attach-agent $W(32) $tcp_(32)
 $ns_ attach-agent $node_(32) $sink_(32)
 $ns_ connect $tcp_(32) $sink_(32)
 set ftp_(32) [new Application/FTP]
 $ftp_(32) attach-agent $tcp_(32)
 $ns_ at 100 "$ftp_(32) start"
 
 set tcp_(33) [new Agent/TCP/Reno]
 $tcp_(33) set class_ 2
 set sink_(33) [new Agent/TCPSink]
 $ns_ attach-agent $W(33) $tcp_(33)
 $ns_ attach-agent $node_(33) $sink_(33)
 $ns_ connect $tcp_(33) $sink_(33)
 set ftp_(33) [new Application/FTP]
 $ftp_(33) attach-agent $tcp_(33)
 $ns_ at 100 "$ftp_(33) start"
 
 set tcp_(34) [new Agent/TCP/Reno]
 $tcp_(34) set class_ 2
 set sink_(34) [new Agent/TCPSink]
 $ns_ attach-agent $W(34) $tcp_(34)
 $ns_ attach-agent $node_(34) $sink_(34)
 $ns_ connect $tcp_(34) $sink_(34)
 set ftp_(34) [new Application/FTP]
 $ftp_(34) attach-agent $tcp_(34)
 $ns_ at 100 "$ftp_(34) start"
 
 set tcp_(35) [new Agent/TCP/Reno]
 $tcp_(35) set class_ 2
 set sink_(35) [new Agent/TCPSink]
 $ns_ attach-agent $W(35) $tcp_(35)
 $ns_ attach-agent $node_(35) $sink_(35)
 $ns_ connect $tcp_(35) $sink_(35)
 set ftp_(35) [new Application/FTP]
 $ftp_(35) attach-agent $tcp_(35)
 $ns_ at 100 "$ftp_(35) start"
 
 set tcp_(36) [new Agent/TCP/Reno]
 $tcp_(36) set class_ 2
 set sink_(36) [new Agent/TCPSink]
 $ns_ attach-agent $W(36) $tcp_(36)
 $ns_ attach-agent $node_(36) $sink_(36)
 $ns_ connect $tcp_(36) $sink_(36)
 set ftp_(36) [new Application/FTP]
 $ftp_(36) attach-agent $tcp_(36)
 $ns_ at 100 "$ftp_(36) start"
 
 set tcp_(37) [new Agent/TCP/Reno]
 $tcp_(37) set class_ 2
 set sink_(37) [new Agent/TCPSink]
 $ns_ attach-agent $W(37) $tcp_(37)
 $ns_ attach-agent $node_(37) $sink_(37)
 $ns_ connect $tcp_(37) $sink_(37)
 set ftp_(37) [new Application/FTP]
 $ftp_(37) attach-agent $tcp_(37)
 $ns_ at 100 "$ftp_(37) start"
 
 set tcp_(38) [new Agent/TCP/Reno]
 $tcp_(38) set class_ 2
 set sink_(38) [new Agent/TCPSink]
 $ns_ attach-agent $W(38) $tcp_(38)
 $ns_ attach-agent $node_(38) $sink_(38)
 $ns_ connect $tcp_(38) $sink_(38)
 set ftp_(38) [new Application/FTP]
 $ftp_(38) attach-agent $tcp_(38)
 $ns_ at 100 "$ftp_(38) start"
 
 set tcp_(39) [new Agent/TCP/Reno]
 $tcp_(39) set class_ 2
 set sink_(39) [new Agent/TCPSink]
 $ns_ attach-agent $W(39) $tcp_(39)
 $ns_ attach-agent $node_(39) $sink_(39)
 $ns_ connect $tcp_(39) $sink_(39)
 set ftp_(39) [new Application/FTP]
 $ftp_(39) attach-agent $tcp_(39)
 $ns_ at 100 "$ftp_(39) start"
 
 
 
 

#up stream for TCP
 
 set tcp_(60) [new Agent/TCP/Reno]
 $tcp_(60) set class_ 2
 set sink_(60) [new Agent/TCPSink]
 $ns_ attach-agent $node_(0) $tcp_(60)
 $ns_ attach-agent $W(0) $sink_(60)
 $ns_ connect $tcp_(60) $sink_(60)
 set ftp_(60) [new Application/FTP]
 $ftp_(60) attach-agent $tcp_(60)
 $ns_ at 100 "$ftp_(60) start" 
 
 set tcp_(61) [new Agent/TCP/Reno]
 $tcp_(61) set class_ 2
 set sink_(61) [new Agent/TCPSink]
 $ns_ attach-agent $node_(1) $tcp_(61)
 $ns_ attach-agent $W(1) $sink_(61)
 $ns_ connect $tcp_(61) $sink_(61)
 set ftp_(61) [new Application/FTP]
 $ftp_(61) attach-agent $tcp_(61)
 $ns_ at 100 "$ftp_(61) start" 
 
 set tcp_(62) [new Agent/TCP/Reno]
 $tcp_(62) set class_ 2
 set sink_(62) [new Agent/TCPSink]
 $ns_ attach-agent $node_(2) $tcp_(62)
 $ns_ attach-agent $W(2) $sink_(62)
 $ns_ connect $tcp_(62) $sink_(62)
 set ftp_(62) [new Application/FTP]
 $ftp_(62) attach-agent $tcp_(62)
 $ns_ at 100 "$ftp_(62) start" 
 
 set tcp_(63) [new Agent/TCP/Reno]
 $tcp_(63) set class_ 2
 set sink_(63) [new Agent/TCPSink]
 $ns_ attach-agent $node_(3) $tcp_(63)
 $ns_ attach-agent $W(3) $sink_(63)
 $ns_ connect $tcp_(63) $sink_(63)
 set ftp_(63) [new Application/FTP]
 $ftp_(63) attach-agent $tcp_(63)
 $ns_ at 100 "$ftp_(63) start" 
 
 set tcp_(64) [new Agent/TCP/Reno]
 $tcp_(64) set class_ 2
 set sink_(64) [new Agent/TCPSink]
 $ns_ attach-agent $node_(4) $tcp_(64)
 $ns_ attach-agent $W(4) $sink_(64)
 $ns_ connect $tcp_(64) $sink_(64)
 set ftp_(64) [new Application/FTP]
 $ftp_(64) attach-agent $tcp_(64)
 $ns_ at 100 "$ftp_(64) start" 
 
 set tcp_(65) [new Agent/TCP/Reno]
 $tcp_(65) set class_ 2
 set sink_(65) [new Agent/TCPSink]
 $ns_ attach-agent $node_(5) $tcp_(65)
 $ns_ attach-agent $W(5) $sink_(65)
 $ns_ connect $tcp_(65) $sink_(65)
 set ftp_(65) [new Application/FTP]
 $ftp_(65) attach-agent $tcp_(65)
 $ns_ at 100 "$ftp_(65) start" 
 
 set tcp_(66) [new Agent/TCP/Reno]
 $tcp_(66) set class_ 2
 set sink_(66) [new Agent/TCPSink]
 $ns_ attach-agent $node_(6) $tcp_(66)
 $ns_ attach-agent $W(6) $sink_(66)
 $ns_ connect $tcp_(66) $sink_(66)
 set ftp_(66) [new Application/FTP]
 $ftp_(66) attach-agent $tcp_(66)
 $ns_ at 100 "$ftp_(66) start" 
 
 set tcp_(67) [new Agent/TCP/Reno]
 $tcp_(67) set class_ 2
 set sink_(67) [new Agent/TCPSink]
 $ns_ attach-agent $node_(7) $tcp_(67)
 $ns_ attach-agent $W(7) $sink_(67)
 $ns_ connect $tcp_(67) $sink_(67)
 set ftp_(67) [new Application/FTP]
 $ftp_(67) attach-agent $tcp_(67)
 $ns_ at 100 "$ftp_(67) start" 
 
 set tcp_(68) [new Agent/TCP/Reno]
 $tcp_(68) set class_ 2
 set sink_(68) [new Agent/TCPSink]
 $ns_ attach-agent $node_(8) $tcp_(68)
 $ns_ attach-agent $W(8) $sink_(68)
 $ns_ connect $tcp_(68) $sink_(68)
 set ftp_(68) [new Application/FTP]
 $ftp_(68) attach-agent $tcp_(68)
 $ns_ at 100 "$ftp_(68) start" 
 
 set tcp_(69) [new Agent/TCP/Reno]
 $tcp_(69) set class_ 2
 set sink_(69) [new Agent/TCPSink]
 $ns_ attach-agent $node_(9) $tcp_(69)
 $ns_ attach-agent $W(9) $sink_(69)
 $ns_ connect $tcp_(69) $sink_(69)
 set ftp_(69) [new Application/FTP]
 $ftp_(69) attach-agent $tcp_(69)
 $ns_ at 100 "$ftp_(69) start" 
 
 set tcp_(70) [new Agent/TCP/Reno]
 $tcp_(70) set class_ 2
 set sink_(70) [new Agent/TCPSink]
 $ns_ attach-agent $node_(10) $tcp_(70)
 $ns_ attach-agent $W(10) $sink_(70)
 $ns_ connect $tcp_(70) $sink_(70)
 set ftp_(70) [new Application/FTP]
 $ftp_(70) attach-agent $tcp_(70)
 $ns_ at 100 "$ftp_(70) start"
 
 set tcp_(71) [new Agent/TCP/Reno]
 $tcp_(71) set class_ 2
 set sink_(71) [new Agent/TCPSink]
 $ns_ attach-agent $node_(11) $tcp_(71)
 $ns_ attach-agent $W(11) $sink_(71)
 $ns_ connect $tcp_(71) $sink_(71)
 set ftp_(71) [new Application/FTP]
 $ftp_(71) attach-agent $tcp_(71)
 $ns_ at 100 "$ftp_(71) start"
 
 set tcp_(72) [new Agent/TCP/Reno]
 $tcp_(72) set class_ 2
 set sink_(72) [new Agent/TCPSink]
 $ns_ attach-agent $node_(12) $tcp_(72)
 $ns_ attach-agent $W(12) $sink_(72)
 $ns_ connect $tcp_(72) $sink_(72)
 set ftp_(72) [new Application/FTP]
 $ftp_(72) attach-agent $tcp_(72)
 $ns_ at 100 "$ftp_(72) start"
 
 set tcp_(73) [new Agent/TCP/Reno]
 $tcp_(73) set class_ 2
 set sink_(73) [new Agent/TCPSink]
 $ns_ attach-agent $node_(13) $tcp_(73)
 $ns_ attach-agent $W(13) $sink_(73)
 $ns_ connect $tcp_(73) $sink_(73)
 set ftp_(73) [new Application/FTP]
 $ftp_(73) attach-agent $tcp_(73)
 $ns_ at 100 "$ftp_(73) start"
 
 set tcp_(74) [new Agent/TCP/Reno]
 $tcp_(74) set class_ 2
 set sink_(74) [new Agent/TCPSink]
 $ns_ attach-agent $node_(14) $tcp_(74)
 $ns_ attach-agent $W(14) $sink_(74)
 $ns_ connect $tcp_(74) $sink_(74)
 set ftp_(74) [new Application/FTP]
 $ftp_(74) attach-agent $tcp_(74)
 $ns_ at 100 "$ftp_(74) start"
 
 set tcp_(75) [new Agent/TCP/Reno]
 $tcp_(75) set class_ 2
 set sink_(75) [new Agent/TCPSink]
 $ns_ attach-agent $node_(15) $tcp_(75)
 $ns_ attach-agent $W(15) $sink_(75)
 $ns_ connect $tcp_(75) $sink_(75)
 set ftp_(75) [new Application/FTP]
 $ftp_(75) attach-agent $tcp_(75)
 $ns_ at 100 "$ftp_(75) start"
 
 set tcp_(76) [new Agent/TCP/Reno]
 $tcp_(76) set class_ 2
 set sink_(76) [new Agent/TCPSink]
 $ns_ attach-agent $node_(16) $tcp_(76)
 $ns_ attach-agent $W(16) $sink_(76)
 $ns_ connect $tcp_(76) $sink_(76)
 set ftp_(76) [new Application/FTP]
 $ftp_(76) attach-agent $tcp_(76)
 $ns_ at 100 "$ftp_(76) start"
 
 set tcp_(77) [new Agent/TCP/Reno]
 $tcp_(77) set class_ 2
 set sink_(77) [new Agent/TCPSink]
 $ns_ attach-agent $node_(17) $tcp_(77)
 $ns_ attach-agent $W(17) $sink_(77)
 $ns_ connect $tcp_(77) $sink_(77)
 set ftp_(77) [new Application/FTP]
 $ftp_(77) attach-agent $tcp_(77)
 $ns_ at 100 "$ftp_(77) start"
 
 set tcp_(78) [new Agent/TCP/Reno]
 $tcp_(78) set class_ 2
 set sink_(78) [new Agent/TCPSink]
 $ns_ attach-agent $node_(18) $tcp_(78)
 $ns_ attach-agent $W(18) $sink_(78)
 $ns_ connect $tcp_(78) $sink_(78)
 set ftp_(78) [new Application/FTP]
 $ftp_(78) attach-agent $tcp_(78)
 $ns_ at 100 "$ftp_(78) start"
 
 set tcp_(79) [new Agent/TCP/Reno]
 $tcp_(79) set class_ 2
 set sink_(79) [new Agent/TCPSink]
 $ns_ attach-agent $node_(19) $tcp_(79)
 $ns_ attach-agent $W(19) $sink_(79)
 $ns_ connect $tcp_(79) $sink_(79)
 set ftp_(79) [new Application/FTP]
 $ftp_(79) attach-agent $tcp_(79)
 $ns_ at 100 "$ftp_(79) start"
 
 set tcp_(80) [new Agent/TCP/Reno]
 $tcp_(80) set class_ 2
 set sink_(80) [new Agent/TCPSink]
 $ns_ attach-agent $node_(20) $tcp_(80)
 $ns_ attach-agent $W(20) $sink_(80)
 $ns_ connect $tcp_(80) $sink_(80)
 set ftp_(80) [new Application/FTP]
 $ftp_(80) attach-agent $tcp_(80)
 $ns_ at 100 "$ftp_(80) start"
 
 set tcp_(81) [new Agent/TCP/Reno]
 $tcp_(81) set class_ 2
 set sink_(81) [new Agent/TCPSink]
 $ns_ attach-agent $node_(21) $tcp_(81)
 $ns_ attach-agent $W(21) $sink_(81)
 $ns_ connect $tcp_(81) $sink_(81)
 set ftp_(81) [new Application/FTP]
 $ftp_(81) attach-agent $tcp_(81)
 $ns_ at 100 "$ftp_(81) start"
 
 set tcp_(82) [new Agent/TCP/Reno]
 $tcp_(82) set class_ 2
 set sink_(82) [new Agent/TCPSink]
 $ns_ attach-agent $node_(22) $tcp_(82)
 $ns_ attach-agent $W(22) $sink_(82)
 $ns_ connect $tcp_(82) $sink_(82)
 set ftp_(82) [new Application/FTP]
 $ftp_(82) attach-agent $tcp_(82)
 $ns_ at 100 "$ftp_(82) start"
 
 set tcp_(83) [new Agent/TCP/Reno]
 $tcp_(83) set class_ 2
 set sink_(83) [new Agent/TCPSink]
 $ns_ attach-agent $node_(23) $tcp_(83)
 $ns_ attach-agent $W(23) $sink_(83)
 $ns_ connect $tcp_(83) $sink_(83)
 set ftp_(83) [new Application/FTP]
 $ftp_(83) attach-agent $tcp_(83)
 $ns_ at 100 "$ftp_(83) start"
 
 set tcp_(84) [new Agent/TCP/Reno]
 $tcp_(84) set class_ 2
 set sink_(84) [new Agent/TCPSink]
 $ns_ attach-agent $node_(24) $tcp_(84)
 $ns_ attach-agent $W(24) $sink_(84)
 $ns_ connect $tcp_(84) $sink_(84)
 set ftp_(84) [new Application/FTP]
 $ftp_(84) attach-agent $tcp_(84)
 $ns_ at 100 "$ftp_(84) start"
 
 set tcp_(85) [new Agent/TCP/Reno]
 $tcp_(85) set class_ 2
 set sink_(85) [new Agent/TCPSink]
 $ns_ attach-agent $node_(25) $tcp_(85)
 $ns_ attach-agent $W(25) $sink_(85)
 $ns_ connect $tcp_(85) $sink_(85)
 set ftp_(85) [new Application/FTP]
 $ftp_(85) attach-agent $tcp_(85)
 $ns_ at 100 "$ftp_(85) start"
 
 set tcp_(86) [new Agent/TCP/Reno]
 $tcp_(86) set class_ 2
 set sink_(86) [new Agent/TCPSink]
 $ns_ attach-agent $node_(26) $tcp_(86)
 $ns_ attach-agent $W(26) $sink_(86)
 $ns_ connect $tcp_(86) $sink_(86)
 set ftp_(86) [new Application/FTP]
 $ftp_(86) attach-agent $tcp_(86)
 $ns_ at 100 "$ftp_(86) start"
 
 set tcp_(87) [new Agent/TCP/Reno]
 $tcp_(87) set class_ 2
 set sink_(87) [new Agent/TCPSink]
 $ns_ attach-agent $node_(27) $tcp_(87)
 $ns_ attach-agent $W(27) $sink_(87)
 $ns_ connect $tcp_(87) $sink_(87)
 set ftp_(87) [new Application/FTP]
 $ftp_(87) attach-agent $tcp_(87)
 $ns_ at 100 "$ftp_(87) start"
 
 set tcp_(88) [new Agent/TCP/Reno]
 $tcp_(88) set class_ 2
 set sink_(88) [new Agent/TCPSink]
 $ns_ attach-agent $node_(28) $tcp_(88)
 $ns_ attach-agent $W(28) $sink_(88)
 $ns_ connect $tcp_(88) $sink_(88)
 set ftp_(88) [new Application/FTP]
 $ftp_(88) attach-agent $tcp_(88)
 $ns_ at 100 "$ftp_(88) start"
 
 set tcp_(89) [new Agent/TCP/Reno]
 $tcp_(89) set class_ 2
 set sink_(89) [new Agent/TCPSink]
 $ns_ attach-agent $node_(29) $tcp_(89)
 $ns_ attach-agent $W(29) $sink_(89)
 $ns_ connect $tcp_(89) $sink_(89)
 set ftp_(89) [new Application/FTP]
 $ftp_(89) attach-agent $tcp_(89)
 $ns_ at 100 "$ftp_(89) start"
 
 set tcp_(90) [new Agent/TCP/Reno]
 $tcp_(90) set class_ 2
 set sink_(90) [new Agent/TCPSink]
 $ns_ attach-agent $node_(30) $tcp_(90)
 $ns_ attach-agent $W(30) $sink_(90)
 $ns_ connect $tcp_(90) $sink_(90)
 set ftp_(90) [new Application/FTP]
 $ftp_(90) attach-agent $tcp_(90)
 $ns_ at 100 "$ftp_(90) start"
 
 set tcp_(91) [new Agent/TCP/Reno]
 $tcp_(91) set class_ 2
 set sink_(91) [new Agent/TCPSink]
 $ns_ attach-agent $node_(31) $tcp_(91)
 $ns_ attach-agent $W(31) $sink_(91)
 $ns_ connect $tcp_(91) $sink_(91)
 set ftp_(91) [new Application/FTP]
 $ftp_(91) attach-agent $tcp_(91)
 $ns_ at 100 "$ftp_(91) start"
 
 set tcp_(92) [new Agent/TCP/Reno]
 $tcp_(92) set class_ 2
 set sink_(92) [new Agent/TCPSink]
 $ns_ attach-agent $node_(32) $tcp_(92)
 $ns_ attach-agent $W(32) $sink_(92)
 $ns_ connect $tcp_(92) $sink_(92)
 set ftp_(92) [new Application/FTP]
 $ftp_(92) attach-agent $tcp_(92)
 $ns_ at 100 "$ftp_(92) start"
 
 set tcp_(93) [new Agent/TCP/Reno]
 $tcp_(93) set class_ 2
 set sink_(93) [new Agent/TCPSink]
 $ns_ attach-agent $node_(33) $tcp_(93)
 $ns_ attach-agent $W(33) $sink_(93)
 $ns_ connect $tcp_(93) $sink_(93)
 set ftp_(93) [new Application/FTP]
 $ftp_(93) attach-agent $tcp_(93)
 $ns_ at 100 "$ftp_(93) start"
 
 set tcp_(94) [new Agent/TCP/Reno]
 $tcp_(94) set class_ 2
 set sink_(94) [new Agent/TCPSink]
 $ns_ attach-agent $node_(34) $tcp_(94)
 $ns_ attach-agent $W(34) $sink_(94)
 $ns_ connect $tcp_(94) $sink_(94)
 set ftp_(94) [new Application/FTP]
 $ftp_(94) attach-agent $tcp_(94)
 $ns_ at 100 "$ftp_(94) start"
 
 set tcp_(95) [new Agent/TCP/Reno]
 $tcp_(95) set class_ 2
 set sink_(95) [new Agent/TCPSink]
 $ns_ attach-agent $node_(35) $tcp_(95)
 $ns_ attach-agent $W(35) $sink_(95)
 $ns_ connect $tcp_(95) $sink_(95)
 set ftp_(95) [new Application/FTP]
 $ftp_(95) attach-agent $tcp_(95)
 $ns_ at 100 "$ftp_(95) start"
 
 set tcp_(96) [new Agent/TCP/Reno]
 $tcp_(96) set class_ 2
 set sink_(96) [new Agent/TCPSink]
 $ns_ attach-agent $node_(36) $tcp_(96)
 $ns_ attach-agent $W(36) $sink_(96)
 $ns_ connect $tcp_(96) $sink_(96)
 set ftp_(96) [new Application/FTP]
 $ftp_(96) attach-agent $tcp_(96)
 $ns_ at 100 "$ftp_(96) start"
 
 set tcp_(97) [new Agent/TCP/Reno]
 $tcp_(97) set class_ 2
 set sink_(97) [new Agent/TCPSink]
 $ns_ attach-agent $node_(37) $tcp_(97)
 $ns_ attach-agent $W(37) $sink_(97)
 $ns_ connect $tcp_(97) $sink_(97)
 set ftp_(97) [new Application/FTP]
 $ftp_(97) attach-agent $tcp_(97)
 $ns_ at 100 "$ftp_(97) start"
 
 set tcp_(98) [new Agent/TCP/Reno]
 $tcp_(98) set class_ 2
 set sink_(98) [new Agent/TCPSink]
 $ns_ attach-agent $node_(38) $tcp_(98)
 $ns_ attach-agent $W(38) $sink_(98)
 $ns_ connect $tcp_(98) $sink_(98)
 set ftp_(98) [new Application/FTP]
 $ftp_(98) attach-agent $tcp_(98)
 $ns_ at 100 "$ftp_(98) start"
 
 set tcp_(99) [new Agent/TCP/Reno]
 $tcp_(99) set class_ 2
 set sink_(99) [new Agent/TCPSink]
 $ns_ attach-agent $node_(39) $tcp_(99)
 $ns_ attach-agent $W(39) $sink_(99)
 $ns_ connect $tcp_(99) $sink_(99)
 set ftp_(99) [new Application/FTP]
 $ftp_(99) attach-agent $tcp_(99)
 $ns_ at 100 "$ftp_(99) start"
 
 
 
 
 
 
 
  #================================================

     $ns_ at $opt(stop).0 "$BS(0) reset";
      for {set t 0} {$t < $opt(mn)} {incr t} {
       $ns_ at $opt(stop).0000010 "$node_($t) reset";
        } 
 


$ns_ at $opt(stop).1 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"
proc stop {} {
    global ns_ tracefd
#    global ns_ namtracefd
    close $tracefd
#    close $namtracefd
}

# informative headers for CMUTracefile
#puts $tracefd "M 0.0 nn $opt(nm) x $opt(x) y $opt(y) rp \
# $opt(adhocRouting)"
#puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed $opt(seed)"
#puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)"

puts "Starting Simulation..."
$ns_ run

 
 

 

 




 

 

And