testChaotic.master.Tsync = 2 To 0.8
sim-time-limit = 3600s To 10000
	//scheduleAt(simTime()+intuniform(Tsync,14*Tsync)+CONSTDELAY, new cMessage("SLtimer"));
void Nodo::handleSelfMessage(cMessage *msg){
	Packet *pck = new Packet("DREQ_TIME_REQ");
	pck->setPckType(PTP);
	pck->setSource(address);
	pck->setDestination(master);
	pck->setPtpType(DREQ);
	pck->setClockType(TIME_REQ);
	send(pck,"outclock");
	scheduleAt(simTime()+intuniform(Tsync,14*Tsync)+CONSTDELAY, new cMessage("SLtimer"));
}
Modify To
void Nodo::handleSelfMessage(cMessage *msg){
	            ProduceT3packet();
				dsmVec.record(dsm);
				dpropVec.record(dprop);
				dmsVec.record(dms);
				offsetVec.record(offset);
}
Delete the following program:
handleSync();
			/*********************************
			 **    Salvataggio valori.      **
			 *********************************/
			dsmVec.record(dsm);
			dpropVec.record(dprop);
			dmsVec.record(dms);
			offsetVec.record(offset);
Delete handleDelayResponse();
void Nodo::handleDelayResponse(){
	ev<<"\nhandleDelayResponse called by handleMasterMessage.\n";
	//error("\nhandleDelayResponse called by handleMasterMessage.\n");
	dsm = ts_m_dreq - ts_s_dreq;
	dprop = (dms + dsm)/2;
}
Delete :
void Nodo::handleSync(){
	ev<<"dsm="<<dsm<<"dms"<<dms<<"dprop"<<dprop<<"\n";
	dms = ts_s_sync - ts_m_sync;
	offset = dms - dprop;
	servo_clock();
}
void Nodo::ProduceT3packet(){
	//ev<<"current simulation time ="<<simTime()<<endl;
	Packet *pck = new Packet("DREQ_TIME_REQ");
	pck->setPckType(PTP);
	pck->setSource(address);
	pck->setDestination(master);
	pck->setPtpType(DREQ);
	pck->setClockType(TIME_REQ);
	send(pck,"outclock");
}
Add To servoclock()
	dms = ts_s_sync - ts_m_sync;
	dsm = ts_m_dreq - ts_s_dreq;
	ev<<"dms="<<dms<<"dsm="<<dsm<<endl;
	dprop = (dms + dsm)/2;
	offset = dms - dprop;
	ev<<"offset="<<offset<<endl;
   double alpha = 1;
   double beta = 64;
   double y =offset/alpha;
	ev<<"y="<<y<<endl;
Delete:
        void handleSync();
	void handleDelayResponse();
Add:
	void Nodo::ProduceT3packet()
Modify handleselfmessage():
//double temp = offset + (1+drift)*(SIMTIME_DBL(simTime())-origine)-SIMTIME_DBL(simTime());
Add:
testChaotic.slave[*].clock.sigma1 = 0E-6
Clock.cc:
Delete variable "noise";
Add variable "sigma1";
Add phyclockupdate():
double Clock::Phyclockupdate(){
	drift = drift + sigma2;
	offset = offset + drift*(SIMTIME_DBL(simTime())-lastupdatatime)+ sigma1;
	phyclock = offset + SIMTIME_DBL(simTime());
	lastupdatatime = SIMTIME_DBL(simTime());
    return phyclock;
}
Modify Clock::getTimestamp() In order to update servoclock
Add:
       volatile double sigma2;
        volatile double sigma3;
        volatile double Tcamp;
double Clock::Phyclockupdate(){
	ev<<"update Phyclock&offset:"<<endl;
	noise2 =  normal(0,sigma2);
	drift = drift + noise2;
	noise1 =  normal(0,sigma1);
	offset = offset + drift*(SIMTIME_DBL(simTime())-lastupdatetime)+ noise1;
	phyclock = offset + SIMTIME_DBL(simTime());
	lastupdatetime = SIMTIME_DBL(simTime());
	ev<<"simTime=lastupdatetime="<<SIMTIME_DBL(simTime())<<endl;
    return phyclock;
}
double Clock::getTimestamp(){
	//TODO:Modify
	double clock;
	ev<<"getTimestamp:"<<endl;
	ev<<"simTime="<<SIMTIME_DBL(simTime())<<" lastupdatetime="<<lastupdatetime<<endl;
	if(lastupdatetime == SIMTIME_DBL(simTime()))
	{
		clock = phyclock;
	}
	else
	{
		noise1 = normal(0,sigma1);
		//TODO:Error or Right?
		clock = offset + drift*(SIMTIME_DBL(simTime())-lastupdatetime)+ noise1 + SIMTIME_DBL(simTime());
	}
	noise3 = normal(0,sigma3);
	softclock = clock + noise3;
	return softclock;
}
Modify：
void Clock::adjtimex(double value, int type){
offset = offset + drift*(SIMTIME_DBL(simTime())-lastupdatetime)+ noise1 -value;
}
1.Define two globle variables:
double softclock_t2;
double softclock_t3;
2.ADD to Clock::handleMessage(cMessage *msg):
switch(((Packet *)msg)->getPtpType()){
				case SYNC:
					ev<<"T2 gettimestamp"<<endl;
					softclock_t2 = getTimestamp();
					msg->setTimestamp(softclock_t2);
					softclock_t2Vec.record(softclock_t2);
					break;
				case DREQ:
					ev<<"T3 gettimestamp"<<endl;
				    softclock_t3 = getTimestamp();
					msg->setTimestamp(softclock_t3);
					softclock_t3Vec.record(softclock_t3);
					break;
				}
Add configs TO omnetpp.ini
[Config run1]
testChaotic.slave[*].clock.sigma3 = sqrt((1/2))*(0.1E-6)

[Config run2]
testChaotic.slave[*].clock.sigma3 = sqrt((1/2))*(1E-6)

[Config run3]
testChaotic.slave[*].clock.sigma3 = sqrt((1/2))*(10E-6)

[Config run4]
testChaotic.slave[*].clock.sigma3 = sqrt((1/2))*(100E-6)

[Config run5]
testChaotic.slave[*].clock.sigma3 = sqrt((1/2))*(0E-6)