⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scheduler.html

📁 相关搜索: ns2仿真结果分析 all-awk ns2 ns2 无限网络中awk文件 ... [2.tcl.rar] - 在ns2平台上实现对AODV协议的模拟
💻 HTML
字号:
<html><head><title>Event Scheduler</title></head><body background="parchment.gif" tppabs="http://nile.wpi.edu/NS/Icons/parchment.gif" text="#000000" link="#0000FF"vlink="#000080" alink="#FF0000"><br><center><h2>Event Scheduler</h2></center><br><br><dl><p> This section talks about the discrete event schedulers of NS. Asdescribed in the Overview section, the main users of an eventscheduler are network components that simulate packet-handling delayor that need timers. Figure 5 shows each network object using an eventscheduler. Note that a network object that issues an event is the onewho handles the event later at scheduled time. Also note that the datapath between network objects is different from the eventpath. Actually, packets are handed from one network object to anotherusing <font color=GREEN><I>send(Packet* p){target_->recv(p)};</I></font> method of the sender and <fontcolor=GREEN><I>recv(Packet*, Handler* h = 0)</I></font> method of thereceiver.<p><p align="center"><img src="fig5.gif" tppabs="http://nile.wpi.edu/NS/Figure/fig5.gif"><br><br><b>Figure 5.</b> Discrete Event Scheduler</p><p>NS has two different types of event scheduler implemented.  Theseare real-time and non-real-time schedulers.  For a non-real-timescheduler, three implementations (List, Heap and Calendar) areavailable, even though they are all logically perform the same.  Thisis because of backward compatibility: some early implementation ofnetwork components added by a user (not the original ones included ina package) may use a specific type of scheduler not through publicfunctions but hacking around the internals. The Calendar non-real-timescheduler is set as the default.  The real-time scheduler is foremulation, which allow the simulator to interact with a real network.Currently, emulation is under development although an experimentalversion is available. The following is an example of selecting aspecific event scheduler: </p><table align=CENTER><tr><td>   <b>. . .</b><br>   set ns [new Simulator]<br>   $ns use-scheduler Heap<br>   <b>. . .</b></td></tr></table><p>Another use of an event scheduler is to schedule simulation events,such as when to start an FTP application, when to finish a simulation,or for simulation scenario generation prior to a simulation run. Anevent scheduler object itself has simulation scheduling memberfunctions such as <font color=GREEN>at <i>time "string"</i></font>that issue a special event called AtEvent at a specified simulation<font color=GREEN><I>time</I></font>. An "AtEvent" is actually a childclass of "Event", which has an additional variable to hold the given<font color=GREEN><I>string</I></font>. However, it is treated thesame as a normal (packet related) event within the eventscheduler. When a simulation is started, and as the scheduled time foran AtEvent in the event queue comes, the AtEvent is passed to an"AtEvent handler" that is created once and handles all AtEvents, andthe OTcl command specified by the <fontcolor=GREEN><I>string</I></font> field of the AtEvent is executed. Thefollowing is a simulation event scheduling line added version of theabove example.</p><table align=CENTER><tr><td>   <b>. . .</b><br>   set ns [new Simulator]<br>   $ns use-scheduler Heap<br>   $ns at 300.5 "complete_sim"<br>   <b>. . .</b><br><br>   proc complete_sim {} {<br>   <b>. . .</b><br>   }</td></tr></table><p>You might noticed from the above example that <font color=GREEN>at<i>time "string"</i></font> is a member function of the Simulatorobject (<font color=GREEN>set <I>ns</I> [new Simulator]</font>). Butremember that the Simulator object just acts as a user interface, andit actually calls the member functions of network objects or ascheduler object that does the real job. Followings are a partial listand brief description of Simulator object member functions thatinterface with scheduler member functions: </p><table align=CENTER><tr><td>Simulator instproc <font color=GREEN>now</font></td><td>&nbsp;</td>    <td><font color=RED># return scheduler's notion of current         time</font></td></tr><tr><td>Simulator instproc <font color=GREEN>at args</font></td><td>&nbsp;</td>    <td><font color=RED># schedule execution of code at specified         time</font></td></tr><tr><td>Simulator instproc <font color=GREEN>at-now         args</font></td><td>&nbsp;</td>    <td><font color=RED># schedule execution of code at now</font></td></tr><tr><td>Simulator instproc <font color=GREEN>after n         args</font></td><td>&nbsp;</td>    <td><font color=RED># schedule execution of code after n         secs</font></td></tr><tr><td>Simulator instproc <font color=GREEN>run args</font></td><td>&nbsp;</td>    <td><font color=RED># start scheduler</font></td></tr><tr><td>Simulator instproc <font color=GREEN>halt</font></td><td>&nbsp;</td>    <td><font color=RED># stop (pause) scheduler</font></td></tr></table></dl></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -