Top Banner
OTCL/C++ Linkages T S Pradeep Kumar http://www.pradeepkumar.org http://www.nsnam.com [email protected]
14

OTcl and C++ linkages in NS2

Jan 22, 2018

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OTcl and C++ linkages in NS2

OTCL/C++Linkages

TSPradeepKumarhttp://www.pradeepkumar.org

http://[email protected]

Page 2: OTcl and C++ linkages in NS2
Page 3: OTcl and C++ linkages in NS2
Page 4: OTcl and C++ linkages in NS2

TCLCLClasses

Page 5: OTcl and C++ linkages in NS2

SimpleAgent

classTSPAgent:publicAgent{public:TSPAgent();protected:intcommand(intargc,constchar*const*argv);private:inttsp_var1;doubletsp_var2;voidTSPPrivFunc(void);};

Page 6: OTcl and C++ linkages in NS2

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);}

Page 7: OTcl and C++ linkages in NS2

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));}

Page 8: OTcl and C++ linkages in NS2

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);}

Page 9: OTcl and C++ linkages in NS2

CreationofaSimpleAgent

#nameitas.tclfile#CreateTSPAgentsetmyagent[newAgent/TSPAgentOtcl]

#SetconfigurableparametersofTSPAgent$myagentsettsp_var1_otcl2$myagentsettsp_var2_otcl3.14

#GiveacommandtoTSPAgent$myagentcall-tsp-priv-fun

Page 10: OTcl and C++ linkages in NS2

Casestudy–2–Multimediaoverudp

• tobuildamultimediaapplicationthatrunsoveraUDPconnection,

• fiveratemediascaling• bychangingencodingandtransmissionpolicypairsassociatedwithscaleparametervalues.

Page 11: OTcl and C++ linkages in NS2

Casestudy–2–Multimediaoverudp

• Basedon5rate– 0 0.3mb– 1 0.6mb– 2 0.9mb– 3 1.2mb– 4 1.5mb– Packetsize 1000– Random false

Page 12: OTcl and C++ linkages in NS2

Casestudy–2–Multimediaoverudp

ÒWhenconnectionestablished,Sender/receiveragreeon5differentsetsofencodingandtransmissionpolicypairs.

ÒSendersendswithscale0butchangesthetransmissionratesaccordingtothevaluethatthereceivernotifies.

ÒThereceiverisresponsibleformonitoringthenetworkcongestionanddeterminethescalefactor.Ifcongestion,thenthereceiverreducesthescalefactor.

Page 13: OTcl and C++ linkages in NS2

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

Page 14: OTcl and C++ linkages in NS2

Wheretomodify

Topic Wheretomodify

MPLS ~ns-2.34/mpls

AddinganewQueue ~ns-2.34/queue/*.ccand*.h

Addinganewapplication ~ns-2.34/apps/app.h

Sensors ~ns-2.34/sensor-net(stilltobedeveloped)

Examples(morethan100) ~ns-2.34/tcl/ex/

WhatnotlotmoreinNS2