Dynamips/Dynagen HowTo

Dynamips/Dynagen HowTo:

This is intended to be a simple guide for installing and using Dynamips/Dynagen on Linux Os.

A- Installing Dynamips/Dynagen from CLI.

sudo apt-get install Dynamips Dynagen

B – Creating the network file [.net file]

 Network file is where you setup your topology.

1- At the begining of the file you need to specifyt the ip/hostname of the machine running Dynamips and Dynamips server port, by default port 7200 is used even if you didnt mention it in your configuration.

[127.0.0.1:7200]

[127.0.0.1]

2- You might specify common settings for a platform eg. 3725 router series or whatever you will be running. you can override the common settings in per router basis.

[[7200]]

[[3725]]

3- Under common configuration mode per platform,

1st- Set the destination of the IOS image using “image” keyword.

image = /media/Data/IOS/c7200-jk8s-mz.122-15.T17.bin

image = /media/Data/IOS/c3725-advipservicesk9-mz.124-25b.bin

2nd- Set the npe and ram values using keywords “npe & “ram”.

For 7200 Series ONLY we set a npe “Network Processing Engine” as this is a feature in

7200 series. For other serieses we set the ram value only.

npe = npe-400

ram = 128

4- Create a virtual router instance using “ROUTER” keyword then the router name.

[[ROUTER R1]]

 5- Set the model number of the virtual router instance.

model = 1720

model = 3725

 6- Configure Slot/WIC Modules under each virtual router instance as needed and assigns ports connections under each Slot/WIC.

slot1 = NM-1FE-TX → installs an ethernet port adapter with 1 ethernet port

f1/0 = R3 f0/0 → ports assigned on slot1

WIC0/0 = WIC-1T

s0/1 = R2 s2/0

WIC0/1 = WIC-2T

7- Create a second virtual router R2 instance using the “ROUTER” keyword. There is no need to create and assign interfaces below R2 connected to R1 as it has been already taken care off when you firstly assigned it under R1.

[[ROUTER R2]]

8- Optimizing memory resources utilization using both “ghostios” and “sparsemem” commands, you can configure them and the top level under the [127.0.0.1] partition or under the router model default configuration [3725]

Briefly;

ghostios” enables a shared IOS for router instances that are running the same IOS instead of loading a separate IOS for each router in the actual memory and this reduce the RAM utilization significantly.

sparsemem” when enabled it allows Dynagen to allocate the used amount of memory by a router instance IOS instead of allocating the whole amount without using it.

e.g. 3725 router requires 128M of RAM, currently its using 30M only so sparsemem will allocate 30M from the actual real RAM to this router instance and not the whole 128M, if the instance needs more RAM the sparsemem allocates more as RAM as needed till it reaches its configured value.

 [127.0.0.1]

ghostios = true

sparsemem = true

[[3725]]

ghostios = true

sparsemem = true

 9- Some OSes limits a single process to 2GB on 32-bit OS and 3GB on 64-bit OS, however dividing your virtual router instances to run over multiple Dynamips processes might help in enhancing the overall performance, and to do so you need to configure multiple Dynamips servers within your .net file as following.

[127.0.0.1:7201]

[[3725]]

[[ROUTER R1]]

[[ROUTER R2]]

[127.0.0.1:7202]

[[7200]]

[[ROUTER R3]]

[[ROUTER R4]]

Notes:

– There is no difference in the configuration under each mode.

– You need to run both Dynamips server processes configured before you load your file.

– Notice the different port numbers following the Dynamips host IP

 

After configuring multiple Dynamips server processes and loading your .net file.

=> list

Name Type State Server Console

PE1 3725 stopped 127.0.0.1:7202 2001

PE2 3725 stopped 127.0.0.1:7202 2002

PE3 3725 stopped 127.0.0.1:7202 2003

PE4 3725 stopped 127.0.0.1:7202 2004

PE5 3725 stopped 127.0.0.1:7202 2005

CE1 3725 stopped 127.0.0.1:7203 2006

CE2 3725 stopped 127.0.0.1:7203 2007

ISP1 3725 stopped 127.0.0.1:7202 2008

ISP2 3725 stopped 127.0.0.1:7202 2009

C – Starting the Dynamips and Dynagen Processes

1- Start the Dynamips control server, the server listens to tcp port 7200 by default, the [-H] parameter tells Dynamips to run in hypervisor mode.

After excuting the command the Dynamips server will run in the background.

Dynamips -H 7200 &

Dynamips -H 7201 & → if you are running multiple Dynamips server processes

 2- Run your topology.net file with the Dynagen command, this will give you the access to the Dynagen instance.

  $ Dynagen lab1-topology.net

 => list → this command will list the routers you have created and details about them as the console port

 => list

Name Type State Server Console

R1 7200 stopped 127.0.0.1:7200 2000

R2 7200 stopped 127.0.0.1:7200 2001

3- As you see above two 7200 routers and there state is “stopped”, to start a router use the command “start” and to stop use “stop”

=> start R1 => stop R1

=> start /all => stop /all

4- There are two ways to telnet to you routers, the first is to telnet from inside Dynagen and the second is to telnet from your CLI, the diffrence between the two ways is that the pop-up telnet window from inside Dynagen wont be flexible as much as the CLI, also when you telnet from the CLI you will be able to use SCREEN :D.

– from inside Dynagen: – from CLI

=> telnet R1 $ screen telnet 127.0.0.1 2000

=> telnet /all

127.0.0.1” is the IP of the loobback interface configured at the begining of the .net file and “2000” is the console port of the router you want to telnet into it.

5- Type “help” at Dynagen console window to show the avaliable commands.

=> help

=> ?

 Documented commands (type help <topic>):

========================================

capture confreg cpuinfo export hist list py save show suspend

clear console end filter idlepc no reload send start telnet

conf copy exit help import push resume shell stop ver

6- As we all know the reload command always crashes when executed on a virtual router, now we can use the reload command from the Dynagen console.

=> reload R1

=> reload /all

7- To suspend a virtual router instance use the “suspend” command and to resume the instance use the “resume” command.

=> suspend R1 => resume R1

=> suspend /all =>resume /all

8- Setting the mighty IdlePC Value for each IOS image.

– First initiate the “idlepc get” command to calculate vlaues for your IOS.

=> idlepc get R1

– The values marked with an asterisk * are supposed to be the better values, enter the index number of the value to be applied.

1: 0x6079ed90 [37]

2: 0x6079ed94 [36]

* 3: 0x60707878 [58]

– If you were satisfied with the result then you are done, if not you can initiate the “idlepc show” command to show the previously calculated values and re-set one of them.

=> idlepc show R1

– If you already have an IdlePC Value that you would like to set for your router manually, use the “idlepc set” command.

=> idlepc set R1 0x60707878

– To set the assigned value to all routers running the same IOS as R1 use the “idlepc copy “

=> idlepc copy r1 /all

– To save the idlepc value under a single virtual router instance in your .net file use the “idlepc save” command.

=> idlepc save R1

[[router R1]]

idlepc = 0x60707878

– To save the idlepc value as the default value for this IOS in your .net file use “idlepc save Rx default” command.

=> idlepc save R1 default

[[7200]]

idlepc = 0x60707878

– To save the idlepc value in the Dynagen database so that when you load any other lab with the same IOS the idlepc value will be assigned automatically use the “idlepc save Rx db”

=> idlepc save R1 db

Notes:

– Any line preceded with a hash tag # is considered a comment.

– Words are not case sensitive so feel free to write in UPPER or lower cases.

– For detailed supported hardware check the following link  http://Dynagen.org/tutorial.htm#_Toc193248012


Hope You Find This Useful !!

Abdullah Medhat, CCIE#64416, is a co-founder at Recursive-Lookup, with over 10 years of experience in Service Provider networks. Always hungry for knowledge and learning  new technologies.

Leave a Reply