	*******Installation procedure for PLM********

To install PLM you need the 4 following files: plm-ns.tcl, plm-topo.tcl, plm.tcl,
and cbr_PP_traffic.cc.
There is scenario examples in test-plm.tcl and a validation
test in validate_plm.tcl.

You can install the PLM code for ns v2.1b6 and higher 
(currently ns v2.1b7 daily snapshot). 


-add the file cbr_PP_traffic.cc in the ~ns directory. 
 Add cbr_PP_traffic.o in the Makefile (at the end of the OBJ_CC list).

-make a ~ns/tcl/plm directory

-copy the file plm-ns.tcl, plm-topo.tcl, plm.tcl, and test-plm.tcl in ~ns/tcl/plm

-add in ~ns/tcl/lib/ns-lib.tcl the lines (add the new lines source at the end 
of the other line source):

	source ../plm/plm.tcl
	source ../plm/plm-ns.tcl
	source ../plm/plm-topo.tcl


-add in the file ~ns/tcl/lib/ns-default.tcl the following lines (add 
the new Agent/LossMonitor lines after the other Agent/LossMonitor lines, and 
add the Application/Traffic/CBR_PP lines after the Application/Traffic/CBR lines):

	Agent/LossMonitor set flag_PP_ 0
	Agent/LossMonitor set packet_time_PP 0
	Agent/LossMonitor set fid_PP_ 0
	Agent/LossMonitor set seqno_ 0

	Application/Traffic/CBR_PP set rate_ 448Kb    ;# corresponds to interval of 3.75ms
	Application/Traffic/CBR_PP set packetSize_ 210
	Application/Traffic/CBR_PP set random_ 0
	Application/Traffic/CBR_PP set maxpkts_ 268435456; # 0x10000000
	Application/Traffic/CBR_PP set PBM_ 2;

-add in the file ~ns/tcl/lib/ns-source.tcl the following procedure (add this
instproc after the Application/Traffic/CBR instproc set):

	Application/Traffic/CBR_PP instproc set args {
     	 $self instvar packet_size_ rate_ 
   	   if { [lindex $args 0] == "interval_" } {
      	     puts "Cannot use CBR_PP with interval_, specify rate_ instead"
    	  }
     	 eval $self next $args
	}

-add in the file ~ns/tcl/lib/ns-agent.tcl the following procedure (add this 
instproc after the Agent/LossMonitor instproc log-loss):

Agent/LossMonitor instproc log-PP {} {
}


-add in the file ~ns/loss-monitor.cc the following lines (just add the lines 
annotated with ****add**** in the following code): 
	class LossMonitor : public Agent {
	.....
	protected:
	.....
		int seqno_;
		int flag_PP_;               /********add*******/
		double packet_time_PP;	    /*******add*******/
		double last_packet_time_;
		int off_rtp_;
		int fid_PP_;		    /********add*******/
	};


	LossMonitor::LossMonitor() : Agent(PT_NTYPE)
	{
	.....
		npkts_ = 0;
		flag_PP_ = 0; 					/********add*******/
	.....
		bind("off_rtp_", &off_rtp_);
		bind("flag_PP_", &flag_PP_);			/********add*******/
		bind("packet_time_PP", &packet_time_PP);	/********add*******/	
		bind("fid_PP_", &fid_PP_);			/********add*******/
		bind("seqno_", &seqno_);			/********add*******/
	}


	void LossMonitor::recv(Packet* pkt, Handler*)
	{
		packet_time_PP = Scheduler::instance().clock();   /********add*******/
		hdr_ip* iph = (hdr_ip*)pkt->access(off_ip_);	  /********add*******/
		fid_PP_ = iph->flowid();			  /********add*******/
		hdr_rtp* p = (hdr_rtp*)pkt->access(off_rtp_);
		seqno_ = p->seqno();
		bytes_ += ((hdr_cmn*)pkt->access(off_cmn_))->size();
		flag_PP_=p->flags();				  /********add*******/
	.....
		if (expected_ >= 0) {
	.....
		}
		Tcl::instance().evalf("%s log-PP", name());	  /********add*******/
		last_packet_time_ = Scheduler::instance().clock();
		expected_ = seqno_ + 1;
		Packet::free(pkt);
	}


-recompile ns

Remarks: If you consider a large number of flows, do not forget to increase the MAXFLOW in fq.cc