Running Dynamips takes a lot of CPU and memory and running a full CCIE topology on
a Windows machine can be tough. I do a lot of studying on my commute to my job
and I run some smaller labs but I have not been able to run a full topology on
my laptop until now.

I came across a post on IEOC (Internetwork Experts forum) on how to
dramatically decrease CPU usage. Original credit goes to Journeyofanetworkengineer.

There is a value called idlemax which is related to the famous idle-PC value.
There is not much information on what this value does. According to Greg
at Hacki forum idlemax specifies how many times the address that the idle-PC
value references is used before going to sleep. The default value is 1500.

I’m not sure about the magic behind this, maybe someone with more expertise
in Dynamips can explain this but lowering this value dramatically decreases
the CPU usage.

I was able to run the full INE topology at 20-40% CPU load on my Core2 duo
@ 2.13 GHz and 4 GB RAM. Without idlemax applied my CPU runs at close to
100% load.

This is before idlemax.

This is after idlemax.

This is what a hypervisor entry looks like in the .net file.

[localhost:7200]
udp = 10000
workingdir = C:GNS3Working
 [[3725]]
  image = C:GNS3IOSc3725-adventerprisek9-mz.124-15.T10.extracted.bin
  ram = 128
  ghostios = True
  idlepc = 0x614ac21c
  idlemax = 100

We will need four entries like this with an unique port for localhost and unique port for UDP.
You can download my complete .net file here if you need it for reference.

If you use this tip please post in comments how much your CPU was decreased and if you
have any stability issues when running it at 100.

Drastically decreasing CPU load in Dynamips
Tagged on:         

68 thoughts on “Drastically decreasing CPU load in Dynamips

  • May 16, 2011 at 8:40 pm
    Permalink

    Just added this to my 26-router BGP topology (including route reflectors, confederations, multiple IGPs in different places, etc), and instantly the CPU usage has gone down from about 85% per core to about 40% (on an i5-760).

    This is brilliant, and to think I was wondering about cutting down on the amount of routers in the topology….I may end up ADDING some now!

    Reply
    • May 16, 2011 at 9:13 pm
      Permalink

      Great to hear, thanks for posting Stuart. That is one massive topology you’re running. Almost the same size like the TS part of the lab 🙂

      Reply
      • February 9, 2012 at 7:33 am
        Permalink

        Yes indeed. The versions I’ve seen have many bugs though in the switching code or are built for Solaris. Do you have other experience?

        Reply
    • December 7, 2012 at 5:44 am
      Permalink

      Sounds good, but does not really work…

      Reply
      • December 7, 2012 at 7:25 am
        Permalink

        It does work for me and most others I have talked to. Which version are you running? Did you set a good idle-PC value first?

        Reply
  • May 16, 2011 at 9:49 pm
    Permalink

    I have a 21 router BGP lab I could never get all the routers started at once without dynamips crashing on my Windows box at work. With the idlemax value set they all started and I am averaging about 30% CPU.

    Very nice find!

    Reply
  • May 16, 2011 at 10:11 pm
    Permalink

    wow, just wow. Works for me on linux!

    My quick BGP lab (8 routers, GNS3 local with remote ubuntu Hypervisor) – Was running at 40% CPU across 4 cores now running at near 5%

    CCIE topology running with local dynagen on ubuntu and remove dynamips on ubuntu server. – Was running at 65% across 4 cores, now running at less than 20% across all cores. (posted from the forum, but wanted to show CPU values here too)

    Reply
    • May 16, 2011 at 10:20 pm
      Permalink

      Great. Seems very promising so far, feels weird that this is not widely known and why the people writing the code for Dynamips wouldn’t optimize this automatically. I hope we don’t run into any funky stuff that would keep us from running this. Get back to me when you’ve done some more testing. Thanks Darren.

      Reply
  • May 16, 2011 at 11:08 pm
    Permalink

    After some tinkering I too can report a drop in the same percentile as you guys are getting. 18 routers and NP level BGP with Confederations and Communities.
    I to am puzzled as to why this isn’t a more widely known feature too.

    Reply
    • March 8, 2014 at 2:45 am
      Permalink

      Discussed on the GNS3.net website during their updates for 8.4, 8.5 and 8.6. Ran a very large topology of 32 routers, 2 ASAs and 10 of the generic switches on my AMD Athlon II 64 bit. Used about 11 GBs including Win 7 Prof. Before idlemax=100 setting I was unable to get this to run past 12 routers and was never able to run it past 6 routers with the ASAs.
      Mikeb

      Reply
  • May 16, 2011 at 11:20 pm
    Permalink

    CPU is ok but my memory usage goes beyond 4 giga and dynamips crashes.
    I have 32 bits WXP with 4G of memory and despite I have used all ways I know from the GNS3 document to save memory still I am not allowed to run more than 10 machines because of the memory.Any suggestion ?

    Reply
    • May 17, 2011 at 6:28 am
      Permalink

      Hi GIO,

      Without knowing your setup my guess is that you are only running one hypervisor. There is a limit in Windows how much memory one process can use and it sounds like your hitting this limit. I’m using four hypervisors in Windows. Also, you should know that if you are running 32-bit Windows you can only used about 3 GB of your 4 GB RAM since this is a limit in 32-bit systems. Try increasing the number of hypervisors and if you still have issues come back to me.

      Reply
      • May 17, 2011 at 12:33 pm
        Permalink

        Thanks.
        Increasing the hypervisors did not make a difference to the memory problem,but including sparsemem = True directly into the net file made all the difference.
        Also the merit of including idlemax remained !

        Reply
      • February 18, 2012 at 3:24 am
        Permalink

        increase virtual memory you can look it up

        Reply
  • May 17, 2011 at 4:25 am
    Permalink

    Why on earth was this “fix” just found now?

    Reply
    • May 17, 2011 at 6:26 am
      Permalink

      I’m not sure. It’s very difficult to find documentation on this and I’ve heard that it could potentially decrease stability. So far so good though and we’ll have to see what the true effect is. When I found out I wouldn’t want to keep the secret for myself so I posted it here.

      Reply
  • May 19, 2011 at 12:18 am
    Permalink

    For those that are only used to GNS3, you can change this value by editing the .net file of an already created topology.

    Reply
  • May 25, 2011 at 11:47 am
    Permalink

    Daniel, thanks for sharing this tip. It works great so far on my Ubuntu machine. I have 13 routers set up, cpu used to be around 35-40% ..now its like under 20%! awesome..

    Reply
    • May 25, 2011 at 12:16 pm
      Permalink

      Great, I’ve heard from some people that it can cause some flapping of interfaces etc but I hope everything works out for you.

      Reply
  • June 2, 2011 at 7:27 am
    Permalink

    I am facing the same problem. I will try it. Thanks!

    Reply
  • June 4, 2011 at 1:27 pm
    Permalink

    Great write up! I’ll try this out on my Win 7 machine. I’m a *nix newbie, please, can you point me in the right direction on how to use dynagen for the INE CCIE lab in ubuntu 10.10. I’ve already installed dynagen, but I have a hard time pointing it to the ine .net file. Thanks and keep up the good works…

    Reply
    • June 6, 2011 at 7:19 am
      Permalink

      Download the .net file from http://www.ine.com/resources/iosonpc.htm. Then you need to modify the .net with your IOS image and working dir. Now you need to start the hypervisor with “dynamips -H 7200 &” for the first one and -h 7201 for the second one depending on how many hypervisors you want to run. You then run “dynagen INE.net” if INE.net is the name of your .net file. Then you just telnet to localhost on port 2000 and up to connect to the routers. Here is a basic tutorial on Dynagen: http://7200emu.hacki.at/viewtopic.php?t=5025 If you want to run vol1 you need to modify the startup configs, you can use my script from an earlier blog post for that.

      Reply
  • July 4, 2011 at 9:04 am
    Permalink

    help, how to used this idle max? im new. thanks

    Reply
    • July 4, 2011 at 12:42 pm
      Permalink

      Hi,

      Welcome to the site. I showed how to use it in my post. You put the idlemax = 100 in the .net file. Then you open the .net in either GNS3 or Dynamips depending on your setup. If you still have issues you need to be more specific. Good luck.

      Reply
  • Pingback:Ultimate Hybrid Dynamips CCIE Lab - TechExams.net IT Certification Forums

  • August 8, 2011 at 2:36 pm
    Permalink

    Hi!

    Great tip!
    I always been struggling with high cpu using GNS3, but this helped a lot.
    My 14 router mpls lab went from 100% to 25-30%. Now it´s time to see if it´s stabile…

    Thanks a lot!

    Reply
  • August 27, 2011 at 5:21 pm
    Permalink

    Reaper I have one problem …
    How can i open any saved topology in GNS3…

    Reply
    • August 27, 2011 at 7:52 pm
      Permalink

      Go to file -> open and then browse to the directory where you have saved the .net file. If you have saved configs as well you can go to file -> import and then browse to the dir where the configs are saved. Tell me if you need further support.

      Reply
  • September 13, 2011 at 11:37 pm
    Permalink

    hi reaper,

    this procedure didnt work for me and i’m only using 3 routers, do you have any idea why it is not working?

    regards

    Reply
    • September 14, 2011 at 8:26 am
      Permalink

      Hi,

      What IOS version are you using and have you set the idle-PC values first? How high is your CPU load?

      Reply
      • September 14, 2011 at 8:13 pm
        Permalink

        Hi,

        Im using c3745-spservicesk9-mz.124-15.T14.bin and i already set my idle-PC values before modyfing the .net file, also my cpu load is at 50-60% with the changes made, is it because of the IOS image? do you recommend me to use another IOS ?

        regards

        Reply
        • September 14, 2011 at 8:51 pm
          Permalink

          I’m using 3725. Try if you get better results with it.

          Reply
  • September 15, 2011 at 1:00 am
    Permalink

    Hi, I tried using 3725 and its better now i’m at maximun 25% thanks for your help

    regards

    Reply
  • January 1, 2012 at 7:36 pm
    Permalink

    I use same model and IOS (3725-adventerprisek9-mz.124-15.T10.extracted.bin) on windows. The performance is good, but I have lot of layer 2 issues, so logically connected devices sometimes do not see each other. Did you face same issues?

    Reply
    • January 1, 2012 at 7:38 pm
      Permalink

      No, I don’t have those issue. The only thing that happens is that I sometimes have routing adjacencies flap. I could probably get rid of this if I allocated more memory but I only have 4 GB on my laptop. How much memory do you have and how much do you allocate to each router?

      Reply
      • January 1, 2012 at 9:07 pm
        Permalink

        I allocate 160 MB for each device.

        Reply
      • January 1, 2012 at 11:32 pm
        Permalink

        That should definately be enough. Do you have IP reachability. CDP is not working? Can you run routing on links etc? Try looking at CDP counters and see if they are increasing.

        Reply
  • January 3, 2012 at 11:52 am
    Permalink

    Usually devices see each other through CDP. However, sometimes few devices can not ping each other and routing adjacencies do not come up. I have to shut/unshut interfaces to make this working or even sometimes to restart the whole lab. Sometimes pings do not work at all when layer 2 topology is too complex so that a packet has to go from switch to the STP root and come back through the same switch going to other layer 3 end. On INE forums, some mentioned changing the STP root to solve this, but it did not work for me. Also, in complex OSPF topologies where there are lot of adjacencies, CPU utilization becomes high, and some adjacencies stuck in the exstart and then INIT phases. I have to shut some interfaces till some adjancencies come up, and then unshut these interfaces to make others coming up. All previous cases are usually true when there is a scenario containing backup interfaces or PPPoFR. Also Complex BGP topologies rise the CPU utilization and there is always routing adjacencies flapping as you mentioned. All of these issues are very noisy & time consuming and prevents me from concentrating on the actual lab and achieving the goal of working in speed.

    Any help from your side will be highly appreciated

    Reply
    • January 3, 2012 at 12:12 pm
      Permalink

      What kind of computer and OS are you running on? I think the recommended memory is 256MB for that IOS version. I usually just allocate 128MB but I noticed a lot of issues with NAT running out of memory. I’m ordering a 4GB RAM module so I can run my laptop with 8GB RAM. Can you try to increase to 256MB and see if that changes anything? You may need extra hypervisors if you increase the memory per router. How many hypervisors are you running? It could help if I had a look at your .net file.

      I have not tweaked STP in any way. I recognize what you say about not being able to ping. Sometimes multicast works but unicast does not. I would try to increase memory as a first step and then I could take a look at your .net if you want.

      Reply
      • January 3, 2012 at 1:01 pm
        Permalink

        I use windows XP sp2 with quad core 2.4GHZ & 4 GB RAM. I use three hypervisors, one for internal routers, one for switches, and one for Backbone routers. .net file is the dynamips INE file. I use the following settings per hypervisor

        image = E:SimulatorIOSc3725-adventerprisek9-mz.124-15.T10.extracted.bin
        ram = 160
        disk0 = 64
        idlepc = 0x62b257fc
        idlemax = 100
        sparsemem = True
        ghostios = True

        The Idlepc values used in INE file did not work for me. The CPU becomes 100% utilized. I used the above mentioned value or 0x62b21ea4 which make utilization under 20%. The 0x62b22904 value is good also but makes the show and write memory commands very slow in response.

        Reply
        • January 3, 2012 at 2:50 pm
          Permalink

          I use idlepc = 0x614ac21c. Maybe you could try that value. Are you running 64-bit Win XP? Maybe performance would be better in Win 7 if you have the option of upgrading. Otherwise I would recommend getting some more memory or try runnig Linux instead, it is more stable.

          Reply
  • January 15, 2012 at 6:57 am
    Permalink

    Thank you for the info on idlepc I am run win 7 64bit with AMD Athlon 64 3800+ single core with 4GB ram. I am just in the mid way through ccna.

    I just pick up asus m5a97 motherboard with amd fx 8120 8 core and 8GB ram hope it will do the job.

    again thank’s

    Reply
  • February 8, 2012 at 5:08 pm
    Permalink

    Hi Daniel
    Thanks for this tip.
    I am using c3725-adventerprisek9-mz.124-15.T5 but it not working for with idlemax = 500.

    Do you know what could be the issue?
    Here is my parameters:
    disk0 = 64
    ram = 144
    ghostios = true
    sparsemem = true
    idlemax = 100

    KR,

    Aliou

    Reply
    • February 8, 2012 at 7:55 pm
      Permalink

      What OS and version of GNS3/Dynamips are you running?

      Reply
      • February 8, 2012 at 8:22 pm
        Permalink

        I am using GNS 0.7.1 under Ubuntu

        Reply
        • February 8, 2012 at 8:41 pm
          Permalink

          You might be running a too old version of Dynamips. When I was testing on Linux the version of Dynamips that was available in the repository was not new enough to support idlemax. I had to get one from the source and compile it myself. Try to see if you can find a newer version of Dynamips and if that helps. Good luck.

          Reply
  • February 8, 2012 at 8:44 pm
    Permalink

    i think the version I am using support idlemax, it worked well if I use c3640-jk9o3s-mz.124-16a image.
    Thx for your reply.

    Reply
  • Pingback:One Network Engineer's journey to the CCIE » Dynamips reducing CPU even further

  • July 23, 2012 at 11:19 am
    Permalink

    it works great, after adding idlemax, my CPU goes down from ~100% to 30% (INE lab, full BGP). Thank you very much.

    Reply
  • August 14, 2012 at 10:59 am
    Permalink

    Thanks Daniel. It works like charm for me.
    Though I increase hypervisor to and after the result is cpu usage of 9%

    Reply
  • August 16, 2012 at 5:12 pm
    Permalink

    Does anybody have any idea how I can implement this without using GNS? I’m running straight dynamips on linux boxes. I’m guessing change the source before recompiling but I don’t want to spend 4 hours and 5 cups of coffee re-inventing the wheel if someone has already figured this out.

    Reply
    • August 16, 2012 at 5:31 pm
      Permalink

      This has nothing to do with GNS3. You can just put it in a .net file and run Dynamips as usual.

      Reply
  • August 17, 2012 at 12:01 am
    Permalink

    Sorry I wasn’t very clear.. I compile dynamips and run it right off the command line out of the startup scripts. There are no .net files, dynagen, or anything else… my dynamips launches something like this:

    dynamips -X -p cards -s connections –idle-pc=0x12345678 imagename.image

    I run a single instance of dynamips on several linux boxes with nothing but linux and the dynamips-0.2.8-RC3 distro compiled on that box.

    However if a .net file can pass this value to dynamips there has to be some way for me to I would think.

    Reply
  • August 17, 2012 at 1:24 am
    Permalink

    Thankfully this source code is VERY well commented 🙂

    I found it and another interesting variable someone might want to try altering.. don’t know if it will be passed or whether it will do anything or screw anything up but you can always remove the line if it screws anything up. It might help lower the CPU usage even more if it gets increased. Its idle_sleep_time and the default is 30000.

    I’m going to build a fresh box later and recompile after I do a baseline and see what happens.

    Reply
  • August 17, 2012 at 7:47 am
    Permalink

    OK! I think we can do better as long as it doesn’t affect your performance.

    I don’t know if putting this in your .net files will work but I’m thinking if idle_max somehow gets set this should too. I also don’t know if it will cause anyone problems but it didn’t on my setup – same as setting idle_max I guess – gotta try it and see.

    The variable is idle_sleep_time and the default is 30000. Increasing it cut my CPU usage even more. I wouldn’t go crazy – I used 50000 to see what happens and I might try a little more. Going too high on this one will cause problems, especially with routing protocols but then again going too low on idle_max will too I’m sure.

    To test it I used an old P3 I had laying around to make sure it would load up. This thing was at 38% with no config and the idlepc set and 42-46 with interfaces configured but doing nothing!

    So I recompiled dynamips with idle_max at 500 and got the same results as everyone else – 29% CPU usage. Then I did it again and left idle_max alone but changed idle_sleep_time to 50000 and I got 35%. Then I combined the two and I got it down to 19%.

    If anyone else wants to build it into the compile the values are set in the source file for the processor your router uses – mips64.c or ppc32.c.

    Reply
  • September 28, 2012 at 3:28 pm
    Permalink

    Although this does drastically lower the CPU utilisation, i have found that with it set to 100, running a command like “show run” will cause interfaces to flap and neighbour relationships to fail.

    Reply
    • September 28, 2012 at 3:55 pm
      Permalink

      Hi Nick,

      I’m not seeing that. Occasionally I could have a routing adjacency go down but not enough to be a nuance. I have no flapping interfaces. Maybe try setting it to something a bit higher than like 200? Not sure how it will affect CPU usage though.

      Reply
  • November 22, 2012 at 10:15 am
    Permalink

    Hi all!

    I had this problem at work, where I run an Intel(R) Core(TM)2 Quad CPU, with 2GB of RAM. I couldn’t even run a simple topology with 5 routers, without the CPU reaching 100%. With this great tip, the CPU has decreased to 25-30%!
    Pitty that this tip isn’t more widely known!!!!

    Thanks all 🙂

    Reply
  • December 29, 2012 at 8:08 am
    Permalink

    I found that using the 2691 IOS, the problem goes away.

    Reply
  • April 1, 2013 at 4:27 am
    Permalink

    Thanks a lot …it is working fine with GNS3, for me

    Reply
  • April 1, 2013 at 5:19 am
    Permalink

    Hi, i am running the cisco TSHOOT lab topology with 12 routers, 2 of them used as computers, 4 as switches and remaining 6 as routers. The ios is C3660-JK.BIN. My computer runs windows7, dual core 1.9GHz, 2.5Gb RAM. After editing the .net file with idlemax = 100 , as given here, the CPU usage has come down drastically and i am able to work comfirtably, but only for 10 to 15 minutes. After 10 to 15 minutes the CPU usage again increases to 100% and my computer slows down and i am unable to work with the GNS3 lab. Any suggestions to improve. Pls help. Thanks in advance.

    Reply
    • April 1, 2013 at 7:26 am
      Permalink

      My guess would be that one of your console sessions hasn’t been used for a while and then times out. For some reason this seems to trigger Dynamips to go to 100% CPU. I usually put exec-timeout 0 0 under all the console lines to keep this from happening. It’s just a guess though.

      Reply
  • April 1, 2013 at 5:22 pm
    Permalink

    Thanks a ton Reaper81…ur guess worked out…i am able to work comfirtably now…Thanks again…

    Reply
  • June 10, 2014 at 12:48 am
    Permalink

    one bullet for cpu usage!
    thank you, works in a BAD GREAT AWESOME WAY!

    Reply
  • July 13, 2014 at 7:45 am
    Permalink

    This is simple to apply.
    Step 1: Select an IOS image in GNS 3 using the Menu option : Edit -> IOS Images -> Image file
    Step 2: Add a Router
    Step 3: Start the Router and then after 2 or 3 minutes select the Idle PC using right mouse click.
    Step 4: Click the PopDown button for Idle PC and then select the option which has an asterick symbol and apply it.
    Step 5: Save the project and close it.
    Step 6: Open the .net file for the topology in the wordpad.
    Step 7: You should see the following:-

    [127.0.0.1:7202]
    workingdir = C:DOCUME~1RAMLOCALS~1Temp
    udp = 10201
    [[3725]]
    image = J:dynaIosImagesImage_DIRc3725-adventerprisek9-mz.124-15_T13_unZ.BIN
    ram = 128
    idlepc = 0x62b2823c
    idlemax = 100
    sparsemem = True
    ghostios = True

    Note: Guys in my case idlemax was no there in the file even if I save it on the GUI for IOS Images.

    Therefore I added idlemax and it is working fine. No high CPU now

    Reply
  • September 13, 2014 at 6:32 pm
    Permalink

    excellent tip!! It lowered my CPU load from 60% to 10%. nice, thanks!!

    Reply

Leave a Reply to Aliou Dia Cancel reply

Your email address will not be published. Required fields are marked *