- 1、本文档共40页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
NSLect05
第5章 NS2初步 Primary of NS2 第四次课内容 Tcl/Tk OTcl/NS2对象 仿真网络配置 仿真业务配置 动画展示和数值分析 1.1 Tcl/Tk position Tcl/Tk position (cont.) 1.2 Tcl/tk programming 与Perl, Python同类 采用可读可打印格式命名命令 tk增加了图形接口功能 OTcl 扩展了面向对象功能 脚本语言特点 Tcl语法 tclsh fileName arg arg ... wish fileName arg arg ... 系统变量:argc,argv,argv0=filename 无参数时,进入交互方式 11 条基本规则 command substitution variable substitution Tcl语法:命令格式 cmd args Ex: set a 10 set a incr a unset a Tcl语法:变量及命名 值:字符(串),但expr中可转换为数 变量值为字符! set aa a;set a 3;set aa;set $aa 圆括号,减号为字符 花括号和方括号为关键字 { } 对应于代码行 [ ] 对应于取命令结果 Build-in commands 1.4 A simple scripts 1.4 ?, Monte Carlo simulation A point randomly selected within a square (0,0,1,1) is to be counted if the distance from the origin is smaller then 1. The ratio to the total… ?, cont. 1.5 Dr.COM by tk 2.1 Objects in OTcl 多重继承 2.2 Software components of ns Tcl/tk/Otcl, as CLI for HMI tclcl ns-2.xxx nam (network animator) xgraph 2.3 Class hierarchies of ns Objects in Otcl are named by the interpreted objects, while those in C++ by the compiled objects The term shadow is used to explain the mapping relationship between CO IO The shadow mechanism includes the name, members and hierarchy of class and instance objects 2.4 Shadowing Hierarchy tree 2.5 Programming the Duality 2.6 C++/OTcl Linkage Creation procedures Mirrored by TclClass TclClass: Mechanism Initialization at runtime startup Variable binding, static Link C++ member variables to OTcl object variables C++ TcpAgent::TcpAgent() { bind(“window_”, wnd_); … … } bind_time(), bind_bool(), bind_bw() OTcl set tcp [new Agent/TCP] $tcp set window_ 200 Initial. of Bound Variables Methods binding Implement OTcl methods in C++ Trap point: OTcl method cmd{} Send all arguments after cmd{} call to TclObject::command() Illustration by TclObject OTcl set tcp [new Agent/TCP] $tcp advance 10 C++ int TcpAgent::command(int argc, const char*const* argv) { if (argc == 3) { if (strcmp(argv[1], “advance”) == 0) { int newseq = atoi
文档评论(0)