[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Propagtion fault



Hello,

I am trying to add a new propagation model. the source code as following:
**************
diffuse.cc
*************
#include <math.h>
 
#include <delay.h>
#include <packet.h>
 
#include <packet-stamp.h>
#include <antenna.h>
#include <mobilenode.h>
#include <propagation.h>
#include <wireless-phy.h>
#include <diffuse.h>
 
static class DiffuseClass: public TclClass {
public:
        DiffuseClass() : TclClass("Propagation/Diffuse") {}
        TclObject* create(int, const char*const*) {
                return (new Diffuse);
        }
} class_diffuse;
 
 
Diffuse::Diffuse()
{
        H=1.5;        //Height of Tx & Rx
        s=0;                //d/TR
        double Length=3.00;        //Length of the room
}
 
 
static double
diffuse(double Pt, double A, double q, double s, double H)
{
        /*
         * Unshadow diffuse free space equation for n=1.00:
         *
         *        0.18+1.00s      q*A*Pt
 
         *   P =10           *(-------------)
         *                      3*PI*H*H
 double M=pow(10, 0.18+1.00*s);
return M* Pt * A * q  /(3*PI*H(*) ;
                        //return (pow(10, 0.18+1.00*s)) * Pt * A * q
/(3*PI*H*H) ;
printf("M %e\n", M);
}
double
Diffuse::Pr(PacketStamp *t, PacketStamp *r,  double Length)
     {
  double rX, rY, rZ;            // loc of receiver
  double tX, tY, tZ;            // loc of xmitter
  double s;                     // dist/TR
  double Pr;
  double A=1.00;
  double q=0.8;
  r->getNode()->getLoc(&rX, &rY, &rZ);
  t->getNode()->getLoc(&tX, &tY, &tZ);
 
   rX += r->getAntenna()->getX();
  rY += r->getAntenna()->getY();
  tX += t->getAntenna()->getX();
  tY += t->getAntenna()->getY();
 
  s=sqrt((rY-tY)*(rY-tY))/3.00;      //L is the length of the room
  printf("diffuse %e\n", s);
  /*#if DEBUG > 3
  printf("TRG %.9f %d(%d,%d)@%d(%d,%d) xo=%f :",
         Scheduler::instance().clock(),
         t->getNode()->index(), (int)tX, (int)tY,
         r->getNode()->index(), (int)rX, (int)rY,
          s);
#endif*/
 printf("diffuse %e\n", s);
    Pr = diffuse(t->getTxPr(), A , q, s, H);
    //#if DEBUG > 3
    printf("diffuse %e\n",Pr);
    //#endif
    return Pr;
  }

**************************************
diffuse.h
*************************************************
#ifndef __diffuse_h__
#define __diffuse_h__
#include <packet-stamp.h>
#include <wireless-phy.h>
#include <propagation.h>
 
class Diffuse : public Propagation {
public:
  Diffuse();
        virtual double Pr(PacketStamp *tx, PacketStamp *rx, WirelessPhy
*ifp)
    {return Pr(tx, rx, ifp->getL());}
 
protected:
  virtual double Pr(PacketStamp *tx, PacketStamp *rx, double Length);
 
  double H;
  double s;
 
 
};
 
 
#endif /* __diffuse_h__ */

******************************************
I didn't change any value set in wireless-phy.cc.

After make successfully, I change the command in simple-wireles.tcl
set val(prop)           Propagation/TwoRayGround      ;

to set val(prop)        Propagation/Diffuse      ;

Then I did : ns simple-wireless.tcl

The information shown are:
Starting Simulation...
Propagation model Segmentation fault

I think that I might change some parametres, but just can't finger
out what I shall do.

Any information would be very helpful.

Z Sun