Getting idlepc values for dynamips/dynagen in Linux

Now tht I’ve got my basic configuration up, we now need to set idlepc values for dynamips. If you load up even just 1 router without doing this, you’ll end up with 100% CPU usage. As an added bonus I’ve measured power draw from the wall just to see exactly how much power this set up pulls.

At idle my server pulls exactly 75watts.

I’ve now loaded up dynamips/dynagen with 20 router instances with NO idlepc values set and this is the result:

Tasks: 109 total,   2 running, 106 sleeping,   1 stopped,   0 zombie
Cpu(s): 99.8%us,  0.2%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3996956k total,  3014956k used,   982000k free,     5576k buffers
Swap:  7960168k total,        0k used,  7960168k free,  1563492k cached

As you can see I’m sitting on 99.8% CPU usage. These are the routers running:

=> list
Name       Type       State      Server          Console   
R1         3745       running    localhost:7200  2001      
R2         3745       running    localhost:7200  2002      
R3         3745       running    localhost:7200  2003      
R4         3745       running    localhost:7200  2004      
R5         3745       running    localhost:7200  2005      
R6         3745       running    localhost:7200  2006      
R7         3745       running    localhost:7200  2007      
R8         3745       running    localhost:7200  2008      
R9         3745       running    localhost:7200  2009      
R10        3745       running    localhost:7200  2010      
R11        3745       running    localhost:7200  2011      
R12        3745       running    localhost:7200  2012      
R13        3745       running    localhost:7200  2013      
R14        3745       running    localhost:7200  2014      
R15        3745       running    localhost:7200  2015      
R16        3745       running    localhost:7200  2016      
R17        3745       running    localhost:7200  2017      
R18        3745       running    localhost:7200  2018      
R19        3745       running    localhost:7200  2019      
R20        3745       running    localhost:7200  2020

I’m now pulling a total of 160watts from the wall.

In order to get my idlepc value I do this:

=> idlepc get R2
Please wait while gathering statistics...

Please wait while gathering statistics...
Done. Suggested idling PC:
   0x61239894 (count=55)
   0x604ebf00 (count=31)
   0x60aacff8 (count=41)
   0x60aad000 (count=23)
   0x6123552c (count=72)
   0x6123558c (count=65)
   0x612355d4 (count=22)
   0x60aa6490 (count=34)
   0x60aa64c0 (count=29)
   0x60aa6694 (count=33)
Restart the emulator with "--idle-pc=0x61239894" (for example)
*  1: 0x61239894 [55]
   2: 0x604ebf00 [31]
   3: 0x60aacff8 [41]
   4: 0x60aad000 [23]
   5: 0x6123552c [72]
   6: 0x6123558c [65]
   7: 0x612355d4 [22]
   8: 0x60aa6490 [34]
   9: 0x60aa64c0 [29]
  10: 0x60aa6694 [33]
Potentially better idlepc values marked with "*"
Enter the number of the idlepc value to apply [1-10] or ENTER for no change: 1
Applied idlepc value 0x61239894 to R2

I’ve now applied an idlepc value to R2, but I need this replicated across all routers. This isn’t a problem as all my routers are the same type. All I need to do is this:

=> idlepc copy R2 /all
R4: idlepc set to 0x61239894
R5: idlepc set to 0x61239894
R6: idlepc set to 0x61239894
R7: idlepc set to 0x61239894
R12: idlepc set to 0x61239894
R1: idlepc set to 0x61239894
R3: idlepc set to 0x61239894
R20: idlepc set to 0x61239894
R11: idlepc set to 0x61239894
R8: idlepc set to 0x61239894
R9: idlepc set to 0x61239894
R18: idlepc set to 0x61239894
R10: idlepc set to 0x61239894
R15: idlepc set to 0x61239894
R14: idlepc set to 0x61239894
R17: idlepc set to 0x61239894
R16: idlepc set to 0x61239894
R19: idlepc set to 0x61239894
R13: idlepc set to 0x61239894

You can do this for every router type. In other words, if I had 2 different router types, I’d have to do these commands for each type and then copy the values.

My CPU usage has now jumped down, while still running 20 routers:

Tasks: 109 total,   2 running, 106 sleeping,   1 stopped,   0 zombie
Cpu(s): 64.8%us,  0.0%sy,  0.0%ni, 35.2%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3996956k total,  3053568k used,   943388k free,     7524k buffers
Swap:  7960168k total,        0k used,  7960168k free,  1591900k cached

Power draw at the wall has jumped down to 94Watts. Quite a big saving on juice!

In order to save yourself from having to do this each time, you can just save the idlepc values in your .net file. This means that when you load up your routers, it’ll apply the idlepc value straight away. Do it like so in your .net file:

 [[Router R1]]
  model = 3745
  console = 2001
  autostart = false
  idlepc = 0x61239894

[[Router R2]]
  model = 3745
  console = 2002
  autostart = false
  idlepc = 0x61239894

Note. Do NOT use my values. See what works for you. Use a few different ones and see what happens. Once I’ve actually got protocols running in my lab I’m sure I’ll need to change these values, so please do this for yourself as well.

© 2009-2020 Darren O'Connor All Rights Reserved -- Copyright notice by Blog Copyright