E-mail:
NS2代码的分析是很有意思的一件事,因为NS2绝对是一个相当优秀的C++软件,包含了OOP思想的精华; 而OTCL语言是一种简洁、优美、人性化的解释性语言; 另外,我本人对于连接OTCL和C++的tclcl机制,以及分裂对象模型德看法一向是: 软件只要能跑,不管糟糠多少; IT开发者的“牵强附会”能力不可比拟!!
先从NS2的Agent开始吧, 至于Agent的含义和功能,请参考NS2仿真系列的内容,在此,我对NS2代码的分析总是针对代码本身(如何查看到、相互间如何作用、如何验证分析的结论,以及NS2中用于网络模拟的API)。NS 实现了很多的网络协议,这些协议大部分是以Agent的方式来实现的。
(很多“为什么”的问题实际意义不大,因为那是NS的设计者和拓展者最为关心的问题,而此处的阅读对象是NS2网络模拟的使用者。)
查看所有Agent的脚本
# 功能: # 本脚本用于显示NS2中类继承关系的树形结构;
# NS 实现了很多的网络协议,这些协议大部分是以Agent的方式来实现的。 # 通过本脚本,我们可以查看NS中各种协议的Agent
proc showAgent arg { set cl "Agent" foreach cl [$arg info subclass] { puts $cl if {[$cl info subclass]!=""} { showAgent $cl } } } showAgent "Agent"
# showAgent "Agent/TCP" # showAgent "Agent/UDP" |
Agent所有成员的列表:
#直接输出Agent树结构时的结果: Agent/Null AckReconsClass Agent/DiffusionRouting Agent/DiffusionApp Agent/PBC Agent/LMS Agent/LMS/Sender Agent/LMS/Receiver Agent/PGM Agent/PGM/Receiver Agent/PGM/Sender Agent/Pushback Agent/LDP Agent/Ping Agent/TFRCSink Agent/TFRC Agent/OmniMcast Agent/Flooding Agent/Diff_Sink Agent/Diffusion Agent/Diffusion/ProbGradient Agent/Diffusion/RateGradient Agent/AbsTCP Agent/AbsTCP/TahoeAck Agent/AbsTCP/RenoAck Agent/AbsTCP/TahoeDelAck Agent/AbsTCP/RenoDelAck Agent/AbsTCPSink Agent/AbsTCPSink/DelAck Agent/RAP Agent/SatRoute Agent/AOMDV Agent/AODV Agent/DSRProto Agent/DSRAgent Agent/TORA Agent/IMEP Agent/DSDV Agent/DumbAgent Agent/MIPBS Agent/MIPMH Agent/Encapsulator Agent/Decapsulator Agent/HttpInval Agent/SRM Agent/SRM/Fixed Agent/SRM/Probabilistic Agent/SRM/Deterministic Agent/SRM/SSM Agent/SRM/Adaptive Agent/Mcast Agent/Mcast/Control Agent/CtrMcast Agent/CtrMcast/Encap Agent/CtrMcast/Decap Agent/rtProto Agent/rtProto/Dummy Agent/rtProto/Algorithmic Agent/rtProto/Manual Agent/rtProto/Direct Agent/rtProto/Session Agent/rtProto/Static Agent/rtProto/LS Agent/rtProto/DV Agent/GAF Agent/AckReconsClass Agent/LossMonitor LossTrace Agent/LossMonitor/PLM PLMLossTrace Agent/SCTP Agent/SCTP/CMT Agent/SCTP/MfrTimestamp Agent/SCTP/MfrHbAfterRto Agent/SCTP/MultipleFastRtx Agent/SCTP/HbAfterRto Agent/SCTP/Timestamp Agent/BayTcpApp Agent/BayTcpApp/FtpServer Agent/BayTcpApp/FtpClient Agent/TCPSink Agent/TCPSink/XCPSink Agent/TCPSink/Asym Agent/TCPSink/DelAck Agent/TCPSink/Sack1 Agent/TCPSink/Sack1/DelAck Agent/TCP Agent/TCP/SackRH Agent/TCP/RFC793edu Agent/TCP/SimpleTcp Agent/TCP/Session Agent/TCP/Int Agent/TCP/FS Agent/TCP/Asym Agent/TCP/Linux Agent/TCP/Fack Agent/TCP/Sack1 Agent/TCP/BayFullTcp Agent/TCP/BayFullTcp/Tahoe Agent/TCP/BayFullTcp/Newreno Agent/TCP/BayFullTcp/Sack Agent/TCP/FullTcp Agent/TCP/FullTcp/Tahoe Agent/TCP/FullTcp/Newreno Agent/TCP/FullTcp/Newreno/XCP Agent/TCP/FullTcp/Sack Agent/TCP/Vegas Agent/TCP/Vegas/RBP Agent/TCP/Newreno Agent/TCP/Newreno/FS Agent/TCP/Newreno/Asym Agent/TCP/Newreno/Asym/FS Agent/TCP/Reno Agent/TCP/Reno/XCP Agent/TCP/Reno/FS Agent/TCP/Reno/Asym Agent/TCP/Reno/RBP Agent/TP Agent/MessagePassing Agent/IVS Agent/IVS/Source Agent/IVS/Receiver Agent/RTCP Agent/RTP Agent/CBR/RTP Agent/UDP Agent/CBR/UDP Agent/CBR Agent/Message Agent/ConsRcvr Agent/VatRcvr Agent/SAack Agent/SA Agent/CBR/UDP/SA Agent/QSAgent Agent/SRAgent |
当然,针对该查看脚本,可以稍稍修改,实现以下的输出:
1.仅输出Agent的“儿子”;
2.仅输出有孙子的Agent的“儿子一家”;
3.输出Object、SplitObject和TclObject的整个继承列表;
(由于分裂对象模型的设计,SplitObject和TclObject的继承列表完全一样哦!)
阅读(2809) | 评论(0) | 转发(1) |