⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 patch.mobile

📁 ns2网络仿真中超宽带的实现
💻 MOBILE
📖 第 1 页 / 共 5 页
字号:
+//         ModulationClass() : TclClass("Modulation") {}+//         TclObject* create(int, const char*const*) {+//                 return (new Modulation);+//         }+// } class_Modulation;++int Modulation::NumErrors(double bitErrorProbability, int packetSize)+{+	double packetErrorProbability;+	double x;+	int numErrors;++	// convert packet size to bits+	packetErrorProbability = 1 - pow(1 - bitErrorProbability, packetSize * 8.0);+	x = Random::uniform();++	//XXX actually we should calculate the # of bit errors (Bernoulli)+	if(x < packetErrorProbability)+		numErrors = 1;		// bit error+	else+		numErrors = 0;		// no bit errors+	return numErrors;+}++static class ModulationBPSKClass: public TclClass {+public:+        ModulationBPSKClass() : TclClass("Modulation/BPSK") {}+        TclObject* create(int, const char*const*) {+                return (new BPSK);+        }+} class_ModulationBPSK;  /* ======================================================================    Binary Phase Shift Keying@@ -45,25 +82,28 @@ BPSK::BPSK() { 	Rs = 0;+	//codeModule= new Coding; }  BPSK::BPSK(int S) { 	Rs = S;+	//codeModule= new Coding; } -int-BPSK::BitError(double Pr)+int BPSK::BitError(double Pr) {+	// XXX old code, unused+ 	double Pe;			// probability of error 	double x; 	int nbit = 0;			// number of bit errors tolerated  	if(nbit == 0) {-		Pe = ProbBitError(Pr);+		Pe = 0; //ProbBitError(Pr); 	} 	else {-		Pe = ProbBitError(Pr, nbit);+		Pe = 0; //ProbBitError(Pr, nbit); 	}  	// quick check@@ -81,20 +121,14 @@ 		return 0;		// no bit errors } -double-BPSK::ProbBitError(double)+int BPSK::BitError(double receivedPower, double interferencePower, double noisePower, Packet* p) {-	double Pe = 0.0;--	return Pe;-}+	hdr_cmn *hdr = HDR_CMN(p); -double-BPSK::ProbBitError(double, int)-{-	double Pe = 0.0;+	double SNR=(receivedPower)/(interferencePower + noisePower);+	double y=sqrt(SNR/2);+	double bitErrorProbability=0.5*erfc(y); -	return Pe;+	int numErrors = NumErrors(bitErrorProbability, hdr->size());+	return numErrors; }--diff -Naur --ignore-matching-lines='Version Date' --ignore-matching-lines=cvsroot --ignore-matching-lines=CVSROOT /home/rmerz/NS/ns-allinone-2.26/ns-2.26/mobile/modulation.h mobile/modulation.h--- /home/rmerz/NS/ns-allinone-2.26/ns-2.26/mobile/modulation.h	2003-02-26 23:08:59.000000000 +0100+++ mobile/modulation.h	2004-01-30 16:22:59.000000000 +0100@@ -36,6 +36,8 @@ #ifndef __modulation_h__ #define __modulation_h__ +#include "packet.h"+ /* ======================================================================    Modulation Schemes @@ -46,34 +48,38 @@     ====================================================================== */ -class Modulation {+class Modulation : public TclObject {  public: 	virtual int BitError(double) = 0;	// success reception?-+	virtual int BitError(double, double, double, Packet*) = 0; protected: 	int Rs;					// symbol rate per second+	int NumErrors(double bitErrorProbability, int packetSize);  private:+	 	// Probability of 1 bit error-	virtual double ProbBitError(double) = 0;--	// Probability of n bit errors-	virtual double ProbBitError(double, int) = 0;+	//virtual double ProbBitError(double) = 0;+	//virtual double ProbBitError(double, int) = 0;+	//virtual double ProbBitError(double, double, double) = 0;     };   class BPSK : public Modulation {  public:-	BPSK(void);+	BPSK(); 	BPSK(int);  	virtual int BitError(double Pr);-+	virtual int BitError(double receivedPower, double interferencePower, double noisePower, Packet* p);+	 private:-	virtual double ProbBitError(double Pr);-	virtual double ProbBitError(double Pr, int n);+	//	Coding *codeModule;+	//virtual double ProbBitError(double Pr);+	//virtual double ProbBitError(double Pr, int n);+	//virtual double ProbBitError(double receivedPower, double interferencePower, double noisePower); };  #endif /* __modulation_h__ */diff -Naur --ignore-matching-lines='Version Date' --ignore-matching-lines=cvsroot --ignore-matching-lines=CVSROOT /home/rmerz/NS/ns-allinone-2.26/ns-2.26/mobile/ppm.cc mobile/ppm.cc--- /home/rmerz/NS/ns-allinone-2.26/ns-2.26/mobile/ppm.cc	1970-01-01 01:00:00.000000000 +0100+++ mobile/ppm.cc	2004-01-30 16:22:59.000000000 +0100@@ -0,0 +1,1263 @@+static double PPM_ber_table[MODULATION_NUM_CODES][PPM_TABLE_ROWS][2] = {+	{	 // code 1+		{-1.0000000000000000e+01,2.9360198974609375e-01},+		{-9.5000000000000000e+00,2.9360198974609375e-01},+		{-9.0000000000000000e+00,2.9360198974609375e-01},+		{-8.5000000000000000e+00,2.9360198974609375e-01},+		{-8.0000000000000000e+00,2.9360198974609375e-01},+		{-7.5000000000000000e+00,2.9360198974609375e-01},+		{-7.0000000000000000e+00,2.9360198974609375e-01},+		{-6.5000000000000000e+00,2.9360198974609375e-01},+		{-6.0000000000000000e+00,2.9360198974609375e-01},+		{-5.5000000000000000e+00,2.9360198974609375e-01},+		{-5.0000000000000000e+00,2.9360198974609375e-01},+		{-4.5000000000000000e+00,2.9360198974609375e-01},+		{-4.0000000000000000e+00,2.9360198974609375e-01},+		{-3.5000000000000000e+00,2.9360198974609375e-01},+		{-3.0000000000000000e+00,2.9360198974609375e-01},+		{-2.5000000000000000e+00,2.9360198974609375e-01},+		{-2.0000000000000000e+00,2.9360198974609375e-01},+		{-1.5000000000000000e+00,2.9360198974609375e-01},+		{-1.0000000000000000e+00,2.9360198974609375e-01},+		{-5.0000000000000000e-01,2.9360198974609375e-01},+		{0.0000000000000000e+00,2.9360198974609375e-01},+		{5.0000000000000000e-01,2.9360198974609375e-01},+		{1.0000000000000000e+00,2.9360198974609375e-01},+		{1.5000000000000000e+00,1.3866424560546875e-01},+		{2.0000000000000000e+00,5.7209014892578125e-02},+		{2.5000000000000000e+00,1.2798309326171875e-02},+		{3.0000000000000000e+00,7.1200844644100892e-04},+		{3.5000000000000000e+00,5.2284589279398575e-05},+		{4.0000000000000000e+00,6.0884633195256151e-06},+		{4.5000000000000000e+00,8.0156315325522049e-07},+		{5.0000000000000000e+00,1.0035288569558527e-07},+		{5.5000000000000000e+00,1.0967998195651818e-08},+		{6.0000000000000000e+00,9.8771308791217215e-10},+		{6.5000000000000000e+00,6.9801285189106780e-11},+		{7.0000000000000000e+00,3.6961098554343383e-12},+		{7.5000000000000000e+00,1.3998796209612230e-13},+		{8.0000000000000000e+00,3.6135445169476202e-15},+		{8.5000000000000000e+00,6.0392144584126289e-17},+		{9.0000000000000000e+00,6.1813548781023684e-19},+		{9.5000000000000000e+00,3.6450353994621524e-21},+		{1.0000000000000000e+01,1.1570957794620637e-23}+	}, {	 // code 2+		{-1.0000000000000000e+01,1.3251113891601562e-01},+		{-9.5000000000000000e+00,1.3251113891601562e-01},+		{-9.0000000000000000e+00,1.3251113891601562e-01},+		{-8.5000000000000000e+00,1.3251113891601562e-01},+		{-8.0000000000000000e+00,1.3251113891601562e-01},+		{-7.5000000000000000e+00,1.3251113891601562e-01},+		{-7.0000000000000000e+00,1.3251113891601562e-01},+		{-6.5000000000000000e+00,1.3251113891601562e-01},+		{-6.0000000000000000e+00,1.3251113891601562e-01},+		{-5.5000000000000000e+00,1.3251113891601562e-01},+		{-5.0000000000000000e+00,1.3251113891601562e-01},+		{-4.5000000000000000e+00,1.3251113891601562e-01},+		{-4.0000000000000000e+00,1.3251113891601562e-01},+		{-3.5000000000000000e+00,1.3251113891601562e-01},+		{-3.0000000000000000e+00,1.3251113891601562e-01},+		{-2.5000000000000000e+00,1.3251113891601562e-01},+		{-2.0000000000000000e+00,1.3251113891601562e-01},+		{-1.5000000000000000e+00,1.3251113891601562e-01},+		{-1.0000000000000000e+00,1.3251113891601562e-01},+		{-5.0000000000000000e-01,1.3251113891601562e-01},+		{0.0000000000000000e+00,1.3251113891601562e-01},+		{5.0000000000000000e-01,4.9621582031250000e-02},+		{1.0000000000000000e+00,1.0375976562500000e-02},+		{1.5000000000000000e+00,1.8806457519531250e-03},+		{2.0000000000000000e+00,1.6876579052693604e-04},+		{2.5000000000000000e+00,1.7415709035479687e-05},+		{3.0000000000000000e+00,2.1844021839358797e-06},+		{3.5000000000000000e+00,2.8143778030101508e-07},+		{4.0000000000000000e+00,3.3459595941417706e-08},+		{4.5000000000000000e+00,3.4497031860627499e-09},+		{5.0000000000000000e+00,2.9476906948759682e-10},+		{5.5000000000000000e+00,2.0024813651745975e-11},+		{6.0000000000000000e+00,1.0358766688312003e-12},+		{6.5000000000000000e+00,3.8947543565835319e-14},+		{7.0000000000000000e+00,1.0121117881030653e-15},+		{7.5000000000000000e+00,1.7221139460674705e-17},+		{8.0000000000000000e+00,1.8102126546670130e-19},+		{8.5000000000000000e+00,1.1038201421502987e-21},+		{9.0000000000000000e+00,3.6447608457129198e-24},+		{9.5000000000000000e+00,6.0395886708808256e-27},+		{1.0000000000000000e+01,4.6147088778831262e-30}+	}, {	 // code 3+		{-1.0000000000000000e+01,1.3749694824218750e-01},+		{-9.5000000000000000e+00,1.3749694824218750e-01},+		{-9.0000000000000000e+00,1.3749694824218750e-01},+		{-8.5000000000000000e+00,1.3749694824218750e-01},+		{-8.0000000000000000e+00,1.3749694824218750e-01},+		{-7.5000000000000000e+00,1.3749694824218750e-01},+		{-7.0000000000000000e+00,1.3749694824218750e-01},+		{-6.5000000000000000e+00,1.3749694824218750e-01},+		{-6.0000000000000000e+00,1.3749694824218750e-01},+		{-5.5000000000000000e+00,1.3749694824218750e-01},+		{-5.0000000000000000e+00,1.3749694824218750e-01},+		{-4.5000000000000000e+00,1.3749694824218750e-01},+		{-4.0000000000000000e+00,1.3749694824218750e-01},+		{-3.5000000000000000e+00,1.3749694824218750e-01},+		{-3.0000000000000000e+00,1.3749694824218750e-01},+		{-2.5000000000000000e+00,1.3749694824218750e-01},+		{-2.0000000000000000e+00,1.3749694824218750e-01},+		{-1.5000000000000000e+00,1.3749694824218750e-01},+		{-1.0000000000000000e+00,1.3749694824218750e-01},+		{-5.0000000000000000e-01,5.0716400146484375e-02},+		{0.0000000000000000e+00,1.1310577392578125e-02},+		{5.0000000000000000e-01,1.6365051269531250e-03},+		{1.0000000000000000e+00,3.6175135808574725e-04},+		{1.5000000000000000e+00,3.9405603646770122e-05},+		{2.0000000000000000e+00,4.9711787327390204e-06},+		{2.5000000000000000e+00,6.6101277077548646e-07},+		{3.0000000000000000e+00,8.3402803371853667e-08},+		{3.5000000000000000e+00,9.2942805723483684e-09},+		{4.0000000000000000e+00,8.6959447940958742e-10},+		{4.5000000000000000e+00,6.5452137720057999e-11},+		{5.0000000000000000e+00,3.8022539500758249e-12},+		{5.5000000000000000e+00,1.6325381573631718e-13},+		{6.0000000000000000e+00,4.9443402063789708e-15},+		{6.5000000000000000e+00,1.0038924367857519e-16},+		{7.0000000000000000e+00,1.2926945202534747e-18},+		{7.5000000000000000e+00,9.9355628313244118e-21},+		{8.0000000000000000e+00,4.2646898402930115e-23},+		{8.5000000000000000e+00,9.5001450881727528e-26},+		{9.0000000000000000e+00,1.0125243740677300e-28},+		{9.5000000000000000e+00,4.7159153985745527e-32},+		{1.0000000000000000e+01,8.6740663162042987e-36}+	}, {	 // code 4+		{-1.0000000000000000e+01,2.4227142333984375e-02},+		{-9.5000000000000000e+00,2.4227142333984375e-02},+		{-9.0000000000000000e+00,2.4227142333984375e-02},+		{-8.5000000000000000e+00,2.4227142333984375e-02},+		{-8.0000000000000000e+00,2.4227142333984375e-02},+		{-7.5000000000000000e+00,2.4227142333984375e-02},+		{-7.0000000000000000e+00,2.4227142333984375e-02},

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -