Hello.

I´m working on 802.11g in ns-2.28. I need to make automatic
change in dataRate depending in distance between tow nodes.

I tried to make some changes on the on the mac-802_11.h and
in the mac-802_11.cc but they did not worked for me.

I make some other changes in ns-default.tcl and ns-mac.tcl
for make that the 802.11g standard work in ns-2.28, this
changes were succesful.

In order to make the automatic change in dataRate I tried to
make some changes in mac-802_11.cc:

 Packet *p = Packet::alloc();
 
 struct hdr_cmn *ch = HDR_CMN(p);                       
 struct hdr_mac802_11 *dh = HDR_MAC802_11(p);            
 struct hdr_arp *ah = HDR_ARP(p); 

 double tX_,tY_,tZ_,rX_,rY_,rZ_;
 nsaddr_t txid=index_;
        nsaddr_t rxid;
 
 MobileNode *tx_node= (MobileNode*)(Node::get_node_by_address(txid));
 tx_node->getLoc(&tX_,&tY_,&tZ_); 
         
 ch->tX()=tX_;  
 ch->tY()=tY_;  ch->tZ()=tZ_;
           
 if (strcmp(packet_info.name(ch->ptype()), "ARP") == 0)
  rxid=ah->arp_tpa;    
 else
  rxid=ETHER_ADDR(dh->dh_ra);  
         
 MobileNode *rx_node= (MobileNode*)(Node::get_node_by_address(rxid));
 rx_node->getLoc(&rX_,&rY_,&rZ_); 
 dist = sqrt((rX_ - tX_) * (rX_ - tX_) + (rY_ - tY_) * (rY_ - tY_)  + 
(rZ_ - tZ_) * (rZ_ - tZ_));
                       

 // End of modification


 Tcl& tcl = Tcl::instance();
 tcl.evalf("Mac/802_11 set basicRate_");
         if (strcmp(tcl.result(), "0") != 0) 
          bind_bw("basicRate_", &basicRate_);
  else
   basicRate_ = bandwidth_;


 tcl.evalf("Mac/802_11 set dataRate_");
                if (strcmp(tcl.result(), "0") != 0) 
   bind_bw("dataRate_", &dataRate_);

 //Modification to obtain dataRate VS distance by Jonathan Lopez

  else if (dist<=100 & dist>77)

   dataRate_ = 1*1e6;
  else if (dist<=77 & dist>65)
   dataRate_ = 2*1e6;
  else if (dist<=65 & dist>57)
   dataRate_ = 6*1e6;
  else if (dist<=57 & dist>54)
   dataRate_ = 9*1e6;
  else if (dist<=54 & dist>50)
   dataRate_ = 12*1e6;
  else if (dist<=50 & dist>42)
   dataRate_ = 18*1e6;
  else if (dist<=42 & dist>35)
   dataRate_ = 24*1e6;
  else if (dist<=35 & dist>23)
   dataRate_ = 36*1e6;
  else if (dist<=23 & dist>19)
   dataRate_ = 48*1e6;
  else
   dataRate_ = bandwidth_;
  

 // End of modification

        EOTtarget_ = 0;
        bss_id_ = IBSS_ID;
 //printf("bssid in constructor %d\n",bss_id_);
}


Here I just tried to change dataRate depending the distance
between the nodes, for make the change for every packet that
is send.

However this modification is not working, I see that every
time the
 dataRate is at 54Mbps, including if I comment
every line that define the dataRate, including the lines

 tcl.evalf("Mac/802_11 set dataRate_");
                if (strcmp(tcl.result(), "0") != 0) 
   bind_bw("dataRate_", &dataRate_);

I can modify the dataRate with Mac/802_11 set dataRate_ xMb
in my tcl script. But I need that the dataRate been modified
for every packet that is send denpending in the distance.

Can anyone tell me what is happend or how can I do the
modifications that I need?.

Thanks.
  
 __________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 

Reply via email to