otcl and c++ linkages in ns2
TRANSCRIPT
SimpleAgent
classTSPAgent:publicAgent{public:TSPAgent();protected:intcommand(intargc,constchar*const*argv);private:inttsp_var1;doubletsp_var2;voidTSPPrivFunc(void);};
SimpleAgent
staticclassTSPAgentClass:publicTclClass{public:TSPAgentClass():TclClass("Agent/TSPAgentOtcl"){}TclObject*create(int,constchar*const*){return(newTSPAgent());}}class_tsp_agent;
TSPAgent::TSPAgent():Agent(PT_UDP){bind("tsp_var1_otcl",&tsp_var1);bind("tsp_var2_otcl",&tsp_var2);}
SimpleAgent
intTSPAgent::command(intargc,constchar*const*argv){if(argc==2){if(strcmp(argv[1],"call-tsp-priv-func")==0){TSPPrivFunc();return(TCL_OK);}}return(Agent::command(argc,argv));}
SimpleAgent
voidTSPAgent::TSPPrivFunc(void){Tcl&tcl=Tcl::instance();tcl.eval("puts\"MessageFromTSPPrivFunc\"");tcl.evalf("puts\"tsp_var1=%d\"",tsp_var1);tcl.evalf("puts\"tsp_var2=%f\"",tsp_var2);}
CreationofaSimpleAgent
#nameitas.tclfile#CreateTSPAgentsetmyagent[newAgent/TSPAgentOtcl]
#SetconfigurableparametersofTSPAgent$myagentsettsp_var1_otcl2$myagentsettsp_var2_otcl3.14
#GiveacommandtoTSPAgent$myagentcall-tsp-priv-fun
Casestudy–2–Multimediaoverudp
• tobuildamultimediaapplicationthatrunsoveraUDPconnection,
• fiveratemediascaling• bychangingencodingandtransmissionpolicypairsassociatedwithscaleparametervalues.
Casestudy–2–Multimediaoverudp
• Basedon5rate– 0 0.3mb– 1 0.6mb– 2 0.9mb– 3 1.2mb– 4 1.5mb– Packetsize 1000– Random false
Casestudy–2–Multimediaoverudp
ÒWhenconnectionestablished,Sender/receiveragreeon5differentsetsofencodingandtransmissionpolicypairs.
ÒSendersendswithscale0butchangesthetransmissionratesaccordingtothevaluethatthereceivernotifies.
ÒThereceiverisresponsibleformonitoringthenetworkcongestionanddeterminethescalefactor.Ifcongestion,thenthereceiverreducesthescalefactor.
Wheretomodify
• ~ns-2.34isthefolderwherealltheccmodulesarelocatedTopic Wheretomodify
RoutingProtocol(AODV,DSDV,DSR)
~ns-2.34/aodv/aodv.cc,aodv_rtable.cc,etc
MobileNode(Energy,Propagation,Antenna)
~ns-2.34/mobile/*.ccand*.h
TCP(Vegas,Reno,NewReno,etc) ~ns-2.34/tcp/*.cc
Newpacket,agenttobeadded ~ns-2.34/common/packet.h,agent.h
WirelessPhysicallayerorMACLayermodification
~ns-2.34/mac/*.cc