'Network/Simulation'에 해당되는 글 9건

  1. 2009.02.03 NS2의 802_11에 대한 의문점..
  2. 2009.02.03 모니터링 시스템 구현을 위한 동작
  3. 2009.02.03 재전송 수를 구간별로 적용시키기 위해 NS2 WLAN
  4. 2009.02.03 필요하면 어디서든 선언해 놓아야 한다... ns2 WLAN
  5. 2009.02.03 DIFS제어 방법 ns2
  6. 2009.02.03 NS2에서 802_11의 재전송 수 포기에 따른 카운터를 세고 싶을 때
  7. 2009.02.03 ns2 코드에서 재전송 수를 직접 제어할 때!
  8. 2009.02.03 지금까지 실험한 결과들의 엑셀 파일
  9. 2009.02.02 WLAN에서 업스트림과 다운스트림의 시뮬레이션을 위한 강좌

NS2의 802_11에 대한 의문점..

|
왜 BS를 선언할 수 있도록 tcl에 만들어 놓고..
소스 상에서는 AP라던지 BS에 관한 함수를 동작시키지 않는 것일까?
덤프 파일을 만들어 디버스 할 시간이 부족하고 귀찮어서
많은 부분이 프린트를 찍어봤다.
ㅡㅡㅋ
데이터가 들어가는 곳이 한군데도 없었다.
깨끗하게 새로 설치한 시스템에서도.. 오로지 프린트만 찍어봤는데도...
뭐냐.....
복잡하기만 하면 다냐..

기능상.. 웃기다 거참..

그리고 NAV 실험을 하던중..
왜 ACK를 전송할 때 듀레이션 필드에  궂이 0으로 다시 설정하고 보내는 이유가 뭐냐?
누가 듣는다고!!!!

ㅡㅡㅋ 사실 핸들러를 통한 수신된 단말들의 NAV동안의 Idle 상태로 들어가는 구문을 확인하지 못했다.
set하는 곳은 확인했지만....
아직 모르는게 너무 많네.. .쩝..

참고로  sefer 함수에 무언가 정의 되어 있을거라고 예상한다.
And

모니터링 시스템 구현을 위한 동작

|

현재 flow를 확인하고 배열상으로 저장한다. 벡터를 사용할려다 실패했다..
ㅡㅡㅋ 거참 프로그래밍 실력 하고는
하긴 필요 없다 생각하고 100개의 구조체 배열을 만들었다.
그리고 모두 0으로 초기화 하고 패킷이 들어오면 식별 번호를 부여했다.
그러면 만사 오케이~ ㅋㅋ

 flow 식별 및 첫 기준 데이타 입력
############################################################################
if(addr()==0)
   {
   if (strcmp(check_name,"ack")==0){ 
      if ( ETHER_ADDR(dh->dh_ta)== 0){
         if(flow_num == 0)
      {  
        d_an[0].old_ack_num=seq;
       d_an[0].ip_addr=dst1;
       d_an[0].port_num=dport;
    // printf("\nseq %d dst1 %d dport %d \n",d_an[0].old_ack_num,d_an[0].ip_addr,d_an[0].port_num);
     flow_num++;
     }
     else
     {
      for(i=0; i<flow_num;i++)
     {
      if(d_an[i].ip_addr == dst1&&d_an[i].port_num == dport)
      {
       break;
      }
     }
    // printf("\ni %d flow_num %d\n",i,flow_num);
     if(i==flow_num)
     {
      d_an[flow_num].old_ack_num=seq;
        d_an[flow_num].ip_addr=dst1;
        d_an[flow_num].port_num=dport;
     // printf("\nseq %d dst1 %d dport %d \n",d_an[flow_num].old_ack_num,d_an[flow_num].ip_addr,d_an[flow_num].port_num);
     // printf("\ni %d flow_num %d\n",i,flow_num);
      flow_num++; 
      
     }    
     }
   }
   }
 }

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

해당 flow의 식별 번호가 있을 경우 데이터는 저장 된다.만약을 위해 ip주소와 목적지 주소를 비교하고 포트 번호를 확인 하였다.
##########################################################################

if(addr()==0)
  if (strcmp(check_name,"ack")==0)
     if ( ETHER_ADDR(dh->dh_ta)== 0){//printf("\ntest2\n");
    for(j=0; j<flow_num;j++)
    {
     if(d_an[j].ip_addr == dst1&&d_an[j].port_num == dport&& flow_num != 0)
     {
      
       d_an[j].last_ack_num=seq;
     
     }
    }
 } 
#########################################################################
recvDATA(packet *p) 함수안에 위와 같은 메커니즘을 구현하도록 한다.
#########################################################################
//======================================================================
//fix this
   //    if(addr()==0) printf("\ntest111111 ch->langth_of_q %d\t",ch->langth_of_q); 
  int i,j,t;
 double up_sum,down_sum;
 struct hdr_tcp *dh2 = HDR_TCP(p);
 struct hdr_ip *iph =HDR_IP(p); 
 int src1 = Address::instance().get_nodeaddr(iph->saddr());       
 int dst1 = Address::instance().get_nodeaddr(iph->daddr());  
 int sport = Address::instance().get_nodeaddr(iph->sport());       
 int dport = Address::instance().get_nodeaddr(iph->dport()); 
 int seq=dh2->seqno();
 char *check_name = (char *)packet_info.name(ch->ptype());
        double now = Scheduler::instance().clock();
 
        if(now<=time_monitor)
  if(addr()==0)
   if (strcmp(check_name,"ack")==0){   
      if ( ETHER_ADDR(dh->dh_ra)== 0){
          if(flow_num1 == 0)
       {  
         u_an[0].old_ack_num=seq;
        u_an[0].ip_addr=dst1;
        u_an[0].port_num=dport;
        //printf("\nseq %d dst %d dport %d \n",u_an[0].old_ack_num,u_an[0].ip_addr,u_an[0].port_num);
      flow_num1++;
      }
      else
      {
       for(i=0; i<flow_num1;i++)
      {
       if(u_an[i].ip_addr == dst1&&u_an[i].port_num == dport)
       {
        break;
       }
      }
     // printf("\ni %d flow_num1 %d\n",i,flow_num1);
      if(i==flow_num1)
      {
       u_an[flow_num1].old_ack_num=seq;
         u_an[flow_num1].ip_addr=dst1;
         u_an[flow_num1].port_num=dport;
      // printf("\nseq %d dst %d dport %d \n",u_an[flow_num1].old_ack_num,u_an[flow_num1].ip_addr,u_an[flow_num1].port_num);
       flow_num1++; 
      }    
      }
    }
   }
//================================================================================================
 if(addr()==0)
  if (strcmp(check_name,"ack")==0)
     if ( ETHER_ADDR(dh->dh_ra)== 0){//printf("\ntest2\n");
    for(j=0; j<flow_num;j++)
    {
     if(u_an[j].ip_addr == dst1&&u_an[j].port_num == dport&& flow_num1 != 0)
     {
      
       u_an[j].last_ack_num=seq;
     
     }
    }
 } 
//================================================================================================ 
##########################################################################
마지막이다.  모니터링 시간이 넘고 체크가 한번도 되지 않았으며 flow 개수가 0이 아닐경우
모니터링의 마지막 동작이 움직인다.
##########################################################################
//======================================================================

if(time_monitor<=now&&R_chek==false&&flow_num !=0)
{
//printf("\nif(time_monitor<=now&&R_chek==false&&flow_num !=0)\n");
// printf("\n\nflow_num %d check_last_ack_time %d\n\n",(flow_num*2),check_last_ack_time);
//double up_d,down_d,f_d;
 time_monitor =now;
 time_monitor+=200;
  check_last_ack_time=0;
  up_d=0.0;
 down_d=0.0;
 f_d=0.0;
   for(k=0; k<flow_num;k++)
   {
    up_d+=(u_an[k].last_ack_num - u_an[k].old_ack_num);
    down_d+=(d_an[k].last_ack_num - d_an[k].old_ack_num);
     printf("\nuplast %d upold %d dlast %d dold %d \n",u_an[k].last_ack_num,u_an[k].old_ack_num,d_an[k].last_ack_num,d_an[k].old_ack_num);
   }   
    R=down_d/up_d;
    time=now;
   printf("\n\ntest3 %lf time %lf\n\n",R,time);
 //   if(check_over<=R) printf("\ntest %lf %lf \n",R,check_over);
 //   if(R<=check_under) printf("\ntest1 %lf %lf \n",R,check_under);
   //R_chek=true;
   for(t=0; t<flow_num;t++)
   {
    d_an[t].old_ack_num=d_an[t].last_ack_num;
    u_an[t].old_ack_num=u_an[t].last_ack_num;     
   }   
}
 
//======================================================================



이 모니터링의 큰 유의 사항은 시뮬레이션 시간과 비교해서 너무 큰 모니터링 시간이 걸리면 안된다는 것인데.. 노드 수가 많을 수록 모든 flow의 수에 대한 데이터를 채우기 어렵다. 원래는 초기화 한수 무한 반복이었는데..
후엔 이전 마지막 값을 초기값으로 다시 저장.. 혹 데이터가 갱신되지 않더라도 오류는 없게 만들었다.
또한 노드가 많고 트래픽이 많을 수록 모니터링의 적응 기간이 길어진다.
동작을 크게 해야할 필요가 있으며..
실험상 1500초를 넘어가면 세그먼트 에러가 뜨는것 같다.
ㅡㅡㅋ
거참...
현재 새로 NS2를 우분투를 새로 설치하여 실행하였으나..
모니터링 실험은 이전 몇번 뿐이었으니...
지금은... 잘 모르겠다.
진실인지..
곧 모니터링을 다시 만들어야 할 것 같으니.. 정확한 실험은 이내 다시 해 봐야 겠다.


And

재전송 수를 구간별로 적용시키기 위해 NS2 WLAN

|

각 인터페이스 큐를 찾아보면 해당 인터페이스 큐는 항상 Queue를 참조한다는 것을 알 수 있다.
결국 Queue에 선언해 놓으면 어떤 인터페이스 큐든 적용된다는 것이다.
그리고 직접 인터페이스 큐에 인큐 디큐를 재정의 해 놓지 않는한 대부분 Queue의 인큐 디큐를 사용한다.
만약 현재 패킷이 들어갔을 때의 큐 길이를 보고 싶다면...
독시즌으로 만든 파일에서 hdr_cmn을 따라가라... 그리고 임의의 변수를 선언하고..
패킷이 들어갈때 저장해라
그러면 맥에서 항상 그 당시의 큐 길이를 확인할 수 있다.
재미있는 방법이다.

RED 방식을 조금 적용해 봤다.
//ssrc_=0;  
//slrc_=0;
/*
if(addr()==0)
{
if (strcmp(check_name,"tcp")==0){ 
  ssrc_=7;  
 slrc_=4;   
 //printf("\nslrc_ %d ssrc_ %d ch->limit_of_q %d\n",slrc_,ssrc_,ch->langth_of_q);
}

/*

if (strcmp(check_name,"ack")==0){ 
   ssrc_=5;  
 slrc_=2;   
 //printf("\nslrc_ %d ssrc_ %d ch->limit_of_q %d\n",slrc_,ssrc_,ch->langth_of_q);
}
/* 
 if( ch->langth_of_q != 0)
 {
  block_rt=ch->limit_of_q/7;
  cur_q=ch->langth_of_q;
 
   if(0<=cur_q&&cur_q<7)
   {
    if (strcmp(check_name,"ack")==0)
    {
     ssrc_=0;  
   slrc_=0;   
//   printf("\nACK 7 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
  if(strcmp(check_name,"tcp")==0)
  { 
   ssrc_=0;  
   slrc_=0;   
//   printf("\nTCP 7 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
   }
   else if(7<=cur_q&&cur_q<14)
   {
    if (strcmp(check_name,"ack")==0)
    {
     ssrc_=3;  
   slrc_=2;   
//   printf("\nACK 14 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
  if(strcmp(check_name,"tcp")==0)
  { 
   ssrc_=0;  
   slrc_=0;   
//   printf("\nTCP 14 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
   }
   if(14<=cur_q&&cur_q<21)
   {
    if (strcmp(check_name,"ack")==0)
    {
     ssrc_=6;  
   slrc_=3;   
//   printf("\nACK 21 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
  if(strcmp(check_name,"tcp")==0)
  { 
   ssrc_=0;  
   slrc_=0;   
//   printf("\nTCP 21 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
   }
   else if(21<=cur_q&&cur_q<28)
   {
    if (strcmp(check_name,"ack")==0)
    {
     ssrc_=7;  
   slrc_=4;   
//   printf("\nACK 28 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
  if(strcmp(check_name,"tcp")==0)
  { 
   ssrc_=0;  
   slrc_=0;   
//   printf("\nTCP 28 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
   }
   else if(28<=cur_q&&cur_q<35)
   {
    if (strcmp(check_name,"ack")==0)
    {
     ssrc_=7;  
   slrc_=4;   
//   printf("\nACK 35 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
  if(strcmp(check_name,"tcp")==0)
  { 
   ssrc_=2;  
   slrc_=1;   
//   printf("\nTCP 35 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
   }
   else if(35<=cur_q&&cur_q<42)
   {
    if (strcmp(check_name,"ack")==0)
    {
     ssrc_=7;  
   slrc_=4;   
//   printf("\nACK 42 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
  if(strcmp(check_name,"tcp")==0)
  { 
   ssrc_=4;  
   slrc_=2;   
//   printf("\nTCP 42 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
   }
   else if(42<=cur_q&&cur_q<49)
   {
    if (strcmp(check_name,"ack")==0)
    {
     ssrc_=7;  
   slrc_=4;   
//   printf("\nACK 49 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
  if(strcmp(check_name,"tcp")==0)
  { 
   ssrc_=6;  
   slrc_=3;   
//   printf("\nTCP 49 avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
   }
   else if(49<=cur_q)
   {
    if (strcmp(check_name,"ack")==0)
    {
     ssrc_=7;  
   slrc_=4;   
//   printf("\nACK over avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
  if(strcmp(check_name,"tcp")==0)
  { 
   ssrc_=7;  
   slrc_=4;   
//   printf("\nTCP over avr_ssrc_ %d avr_slrc_slrc_ %d ch->limit_of_q %d\n",ssrc_,slrc_,cur_q);
  }
   }

}
}*/

And

필요하면 어디서든 선언해 놓아야 한다... ns2 WLAN

|

double up_sum,down_sum;
  struct hdr_cmn *ch = HDR_CMN(p);//패킷 정보
  struct hdr_mac802_11* dh = HDR_MAC802_11(p);//맥 정보
 struct hdr_tcp *dh2 = HDR_TCP(p); //tcp 정보
 struct hdr_ip *iph =HDR_IP(p); //ip 정보
//접근자에 정보를 직접 수정할 수 있게 만들어 나가는 작업은 힘들다..
해당 단말만 되는것인지에 대한 신뢰를 하기도 힘들다.
하지만 항상 디테일한 테스트 범위를 구성해 나가면 이러한 문제는 시간이
해결해 준다.

 int src = Address::instance().get_nodeaddr(iph->saddr());       
 int dst1 = Address::instance().get_nodeaddr(iph->daddr());  
 int sport = Address::instance().get_nodeaddr(iph->sport());       
 int dport = Address::instance().get_nodeaddr(iph->dport()); 
 int seq=dh2->seqno();
 char *check_name = (char *)packet_info.name(ch->ptype()); //패킷 종류
        double now = Scheduler::instance().clock();
        //시뮬레이션 시간 가져온다 알뜰 살뜰 참 다양하게 썼다.
And

DIFS제어 방법 ns2

|
귀찮은... 작업이다.. ㅡㅡㅋ
802_11헤더의 class PHY_MIB를 확인하면
getDIFS()가 있다. 나는 AP의 DIFS만을 변경해주기 위해
해당 함수를 하나더 만들었다.
SIFSTime은 10마이크로 세컨드..
슬롯타임은 20마이크로 세컨드..
DIFS는 슬롯타임 * 2 + SIFS 시간이다. 즉 50마이크로 세컨드....
테스트 할 때는 그냥 수작업하였지만..
모니터링을 만들기 위해 파라미터를 선언했다. APDIFS 더블형으로..
초기화 할때 같이 밀어넣어준다. 일단 초기값으로..

문제는...
cc파일 안의 내용이다.
getDIFS()호출부를 그대로 찾아서..
add() 결과시 0 즉 AP이면 GETDIFS1()를 호출하고 아니면 일반적인 함수를
호출하도록 만들었다.
귀찮다 ㅡㅡㅋ
And

NS2에서 802_11의 재전송 수 포기에 따른 카운터를 세고 싶을 때

|
두 군데에 입력한다.
retransmitRTS()
retransmitDATA()

구문을 읽다보면 retrylimit나 쓰레숄더 값과 비교하는 구문이 있다.
디스카드 하기 전에 입력한다.

double now = Scheduler::instance().clock();
 if(200.0 <= now)
 {
  if(addr()==0)
  {
  AP++;
  printf("%lf AP : %d\n",now,AP);
  }
  else
  {
  client++;
  printf("%lf client : %d client number %d\n",now,addr(),client);
  }
 }

헤더파일에 802 클래스를 찾아서
퍼블릭 선언부에 AP와 client를 선언하고
cc파일에서 초기화 할때 같이 0으로 선언해 줄 수 있도록 하자.
And

ns2 코드에서 재전송 수를 직접 제어할 때!

|
class PHY_MIB의
public 선언부에

u_int32_t CWMin;
 u_int32_t CWMax;
각각 선언한다. 물론 다른 위치에 존재하는 동일 선언자는 삭제하거나 주석처리..

send() 함수에 아래와 같이 구현한다.
화면이 미치도록 올라가는 것을 확인할 수 있다
참고로 AP는 Node 넘버가 0번이다. 훗..
if(addr()==0)
{
 phymib_.CWMin=7;
 phymib_.CWMax=7;
}
printf("\nnode number= %d cwmin= %d cwmax= %d ",addr(),phymib_.CWMin,phymib_.CWMax);
And

지금까지 실험한 결과들의 엑셀 파일

|
And

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
prev | 1 | next