Dynamips降低CPU占用率的方法

Calculating Idle-PC values

You may have noticed that the previous lab caused your system’s CPU to peg at 100% and stay there. This is because Dynamips does not know when the virtual router is idle and when it is performing useful work. The “idlepc” command performs analysis on a running image to determine the most likely points in the code that represent an idle loop in IOS. Once applied, Dynamips “sleeps” the virtual router occasionally when this idle loop is executed significantly reducing CPU consumption on the host without reducing the virtual router’s capacity to perform real work.

 

Here is how the process is performed. First, open a lab and make sure only one router instance is running (stop any others in the lab if need be):

 

 

Then, telnet to the running router instance. If you are presented with IOS autoconfig prompt, respond with “no”. Otherwise, do not press anything:

 

 

Wait for all the interfaces to initialize, then wait a bit to ensure that the router is no longer booting and is idle. Your session should look something like this:

 

 

 

Now, switch back to the Dynagen management console, and issue an “idlepc get routername”.  You will see a message that statistics are being gathered, and about 10 seconds later you should see a list of potential idlepc values:

 

 

Values that will most likely provide better results are marked with an asterisk. Select one of the values to try from the menu and press Enter. You should notice your host (the one running the dynamips process) CPU utilization drop dramatically. If so, you’ve found a good idlepc value for this particular IOS image.

 

If your CPU usage did not drop, it’s time to try a different value. Type “idlepc show routername” to show the list of values determined earlier again, and this time select a different one.

 

 

The new idlepc value will take effect dynamically. Once you’ve found a value that works, you can save it to your local idlepc database with “idlepc save routername db”. This stores the idlepc value for this IOS image in the file specified in dynagen.ini with the “idledb” option. The default is a file name “dynagenidledb.ini” in your $HOME or “Documents and Settings” folder (depending on your platform).

 

 

Once an idlepc value is in the database, it will be automatically applied whenever a router in one of your labs uses this image. If Dynagen starts a router without being able to find an idlepc value, it gives the “Warning: Starting xxx with no idle-pc value” message. If you would prefer to store the idlepc value directly in your network file, use “idlepc save routername” to add an “idlepc = xxxx” line to the router definition section (e.g. “[[ROUTER R1]]”) or use “idlepc save rotuername default” to store it in the default section of your network file for that router platform (e.g. “[[7200]]”).

Idle-PC values are are particular to an IOS image. They will be different for different IOS versions, and even for different feature sets of the same IOS version. However Idle-PC values are not particular to your host PC, operating system, or to the version of dynamips. So “dynagenidledb.ini” files from one system can be freely copied, merged, shared with others, etc.

 

The idlepc database is indexed by the name of your IOS image as specified in the “image =” line of your network file (minus the directories), so all your images must have unique names for this to work. I strongly recommend using the convention of keeping the same filename as the downloaded bin file, but replacing “bin” with “image” to indicate that the bin file has been unzipped (e.g. “c7200-jk9o3s-mz.124-7a.image”.) If everyone uses this same convention, it will make sharing databases transparent.

 

It is possible that dynamips will not be able to find and idlepc value for an image, or that the values it does find do not work. If this happens, try repeating the process again. Or you just might be out of luck with that particular image (however running into this situation is rare.)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值