|
NS2 ภาค Energy Model
class EnergyModel : public TclObject{ public: EnergyModel(double energy) energy_ = energy; inline double energy() return energy_; inline void setenergy(double e) energy_ = e; virtual void DecrTxEnergy(double txtime, double P_tx) energy_ -= (P_tx * txtime); virtual void DecrRcvEnergy(double rcvtime, double P_rcv) energy_ -= (P_rcv * rcvtime); protected: double energy_;};
จาก Class ข้างบน มีตัวแปรที่สำคัญคือ energy_ ซึ่งเก็บระดับพลังงานปัจจุบันไว้
และมี function ที่สำคัญ 2 functions คือ DecrTxEnergy ที่จะลดพลังงานเมื่อมีการส่งข้อมูล(transmit) โดย พลังงานที่ลดไป ก็มีค่าเท่ากับ พลังงานที่ใช้ส่ง(J/sec) x transmit Time
DecrRxEnergy ที่จะลดพลังงานเมื่อมีการรับข้อมูล(transmit) โดย พลังงานที่ลดไป ก็มีค่าเท่ากับ พลังงานที่ใช้ส่ง(J/sec) x recieveTime
ซึ่งตาม construtor ต้องกำหนดพลังงานเริ่มต้นด้วย และต้องกำหนด พลังานที่ใช้รับส่ง โดยใช้คำสั่ง $ns_ node-config -energyModel $energymodel \\\\ -rxPower $p_rx \\\\ -txPower $p_tx \\\\ -initialEnergy $initialenergy
มีแค่นี้เองหรอวะเนี่ย แง๋วๆๆ...@#$#_^$
Create Date : 16 พฤษภาคม 2548 |
Last Update : 17 พฤษภาคม 2548 15:55:53 น. |
|
1 comments
|
Counter : 983 Pageviews. |
|
|
|
โดย: DM IP: 165.123.138.192 วันที่: 7 เมษายน 2549 เวลา:2:20:15 น. |
|
|
|
| |
|
|
I have seen that you have done a lot of work in NS2 :) I have some question krub. In the energy model, there is the variables p_tx and p_rcv which specify energy consumption in transmitting and receiving packets. Is p_tx relate to Pt_ ? where Pt_ is the transmitted power. Also since Pt_ depends on the communication range of the nodes. So does p_tx? and p_rcv should be the energy consumption of the node when it operates in receive mode and should not depend on the distance between the sender and receiver right?
Please let me know if you have answers on these questions na krub. Thank you very much.