I explained "Using dynagen & dynamips for multible cisco router simulation" in the
http://stdioe.blogspot.com/2012/06/using-dynagen-dynamips-for-multible.html article before. I'm going to talk about how to create a dynagen configuration for multiple dynamips service. Also we are going to work about dynagen performance optimization. Let's create a network topology to try on our system.
Now, we have got three dynamips services. Each single dynamips service is creating three virtual routers and all of them are connected to each other. The first dynamips service contains R1, R2 and R3 routers, the second dynamips service contains R4, R5 and R6 routers, the third dynamips service contains R7, R8 and R9 routers. They are seperated on configuration but logically they are connected to each other directly.
Start to practice,
1-) Starting dynamips services with different port numbers,
ismail@ismail-ThinkPad-T410:~$ dynamips -H 7200 &
ismail@ismail-ThinkPad-T410:~$ dynamips -H 7301 &
ismail@ismail-ThinkPad-T410:~$ dynamips -H 7402 &
2-) Create dynamips configuration file corresponding our network topology,
###############################1-Dynamips-1#############################
[localhost:7200]
udp=10000
workingdir = /tmp/workingdy1
[[3725]]
image = /tmp/c3725-adventerprisek9-mz.124-15.T13.bin
ram = 128
#idlepc = ?? # We will talk about this, later.
ghostios = true
sparsemem = true
idlemax = 100
disk0=128
[[Router R1]]
model = 3725
console = 2001
autostart = false
S0/0 = R2 S0/0
[[Router R2]]
model = 3725
console = 2002
autostart = false
S0/0 = R1 S0/0
S0/1 = R3 S0/0
[[Router R3]]
model = 3725
console = 2003
autostart = false
WIC0/0 = WIC-2T
S0/0 = R2 S0/1
S0/1 = R7 S0/1
###############################1-Dynamips-1#############################
###############################2-Dynamips-2#############################
[localhost:7201]
udp=11000
workingdir = /tmp/workingdy2
[[3725]]
image = /tmp/c3725-adventerprisek9-mz.124-15.T13.bin
ram = 128
#idlepc = ?? # We will talk about this, later.
ghostios = true
sparsemem = true
idlemax = 100
disk0=128
[[Router R4]]
model = 3725
console = 2004
autostart = false
S0/0 = R5 S0/0
S0/1 = R8 S0/1
[[Router R5]]
model = 3725
console = 2005
autostart = false
S0/0 = R4 S0/0
S0/1 = R6 S0/0
[[Router R6]]
model = 3725
console = 2006
autostart = false
S0/0 = R5 0/1
###############################2-Dynamips-2#############################
###############################3-Dynamips-3#############################
[localhost:7202]
udp=12000
workingdir = /tmp/workingdy3
[[3725]]
image = /tmp/c3725-adventerprisek9-mz.124-15.T13.bin
ram = 128
#idlepc = ?? # We will talk about this, later.
ghostios = true
sparsemem = true
idlemax = 100
disk0=128
[[Router R7]]
model = 3725
console = 2007
autostart = false
S0/0 = R9 S0/0
S0/1 = R3 S0/1
[[Router R8]]
model = 3725
console = 2008
autostart = false
WIC0/0 = WIC-2T
S0/0 = R9 S0/1
S0/1 = R4 S0/1
[[Router R9]]
model = 3725
console = 2009
autostart = false
S0/0 = R7 0/0
S0/1 = R8 0/0
###############################3-Dynamips-3#############################
I saved the content above with a file name of sample2.net name in /tmp directory. We need working directories as below:
ismail@ismail-ThinkPad-T410:~$ mkdir /tmp/workingdy1
ismail@ismail-ThinkPad-T410:~$ mkdir /tmp/workingdy2
ismail@ismail-ThinkPad-T410:~$ mkdir /tmp/workingdy3
3-) The working directories are ready. Right now, dynagen service is ready to start. I did a mistake to shown follow up how to troubleshooting.
ismail@ismail-ThinkPad-T410:~$ dynagen /tmp/sample2.net
Reading configuration file...
Shutdown in progress...
Shutdown completed.
Shutdown in progress...
Shutdown completed.
Shutdown in progress...
Shutdown completed.
*** Warning: Connecting R6 S0/0 to R5 0/1 resulted in:
malformed destination interface: R5 0/1
*** Warning: Connecting R9 S0/0 to R7 0/0 resulted in:
malformed destination interface: R7 0/0
*** Warning: Connecting R9 S0/1 to R8 0/0 resulted in:
malformed destination interface: R8 0/0
*** Error: errors during loading of the topology file, please correct them
Shutdown in progress...
Error: could not communicate with dynamips server localhost
It may have crashed. Check the dynamips server output.
Exiting...
Press ENTER to exit
[3]+ Segmentation fault (core dumped) dynamips -H 7202
ismail@ismail-ThinkPad-T410:~$
Normally, you can define a connection on both ends of lines. But on our sample, dynagen service doesn't accept this duplicate defination. I removed " S0/1 = R6 S0/0" line in R5 router part. Also " S0/0 = R9 S0/0" line in R7 part and " S0/0 = R9 S0/1" line in R8 part. After editing, sample2.net file has a content as seen below:
###############################1-Dynamips-1#############################
[localhost:7200]
udp=10000
workingdir = /tmp/workingdy1
[[3725]]
image = /tmp/c3725-adventerprisek9-mz.124-15.T13.bin
ram = 128
#idlepc = ?? # We will talk about this, later.
ghostios = true
sparsemem = true
idlemax = 100
disk0=128
[[Router R1]]
model = 3725
console = 2001
autostart = false
S0/0 = R2 S0/0
[[Router R2]]
model = 3725
console = 2002
autostart = false
#S0/0 = R1 S0/0
S0/1 = R3 S0/0
[[Router R3]]
model = 3725
console = 2003
autostart = false
#S0/0 = R2 S0/1
S0/1 = R7 S0/1
###############################1-Dynamips-1#############################
###############################2-Dynamips-2#############################
[localhost:7201]
udp=11000
workingdir = /tmp/workingdy2
[[3725]]
image = /tmp/c3725-adventerprisek9-mz.124-15.T13.bin
ram = 128
#idlepc = ?? # We will talk about this, later.
ghostios = true
sparsemem = true
idlemax = 100
disk0=128
[[Router R4]]
model = 3725
console = 2004
autostart = false
S0/0 = R5 S0/0
S0/1 = R8 S0/1
[[Router R5]]
model = 3725
console = 2005
autostart = false
#S0/0 = R4 S0/0
S0/1 = R6 S0/0
[[Router R6]]
model = 3725
console = 2006
autostart = false
# S0/0 = R5 0/1
###############################2-Dynamips-2#############################
###############################3-Dynamips-3#############################
[localhost:7202]
udp=12000
workingdir = /tmp/workingdy3
[[3725]]
image = /tmp/c3725-adventerprisek9-mz.124-15.T13.bin
ram = 128
#idlepc = ?? # We will talk about this, later.
ghostios = true
sparsemem = true
idlemax = 100
disk0=128
[[Router R7]]
model = 3725
console = 2007
autostart = false
S0/0 = R9 S0/0
#S0/1 = R3 S0/1
[[Router R8]]
model = 3725
console = 2008
autostart = false
S0/0 = R9 S0/1
#S0/1 = R4 S0/1
[[Router R9]]
model = 3725
console = 2009
autostart = false
# S0/0 = R7 0/0
# S0/1 = R8 0/0
###############################3-Dynamips-3#############################
We already started dynamips with 7200, 7201 and 7202 ports but dynagen service has been crashed. Some dynamips services may have been crashed. We have to check them before restarting dynages service.
ismail@ismail-ThinkPad-T410:~$ ps -ef | grep dynamips
ismail 3811 3756 1 10:15 pts/0 00:00:14 dynamips -H 7200
ismail 3829 3756 1 10:16 pts/0 00:00:14 dynamips -H 7201
ismail 4017 3756 0 10:27 pts/0 00:00:00 grep --color=auto dynamips
So One dynamips service crashed and other two ones still working. I want to kill all dynamips services and start them again to make sure about everything on the way. We can kill a PID using the "kill -9 3811" command but I selected pkill command in this sample to show first practice.
ismail@ismail-ThinkPad-T410:~$ pkill dynamips
[1]- Terminated dynamips -H 7200
[2]+ Terminated dynamips -H 7201
ismail@ismail-ThinkPad-T410:~$
And now, there is no any running dynamip process. We can start all of them again,
ismail@ismail-ThinkPad-T410:~$ dynamips -H 7201 &
ismail@ismail-ThinkPad-T410:~$ dynamips -H 7202 &
ismail@ismail-ThinkPad-T410:~$ dynamips -H 7203 &
ismail@ismail-ThinkPad-T410:~$ dynagen /tmp/sample2.net
Reading configuration file...
...
...
...
Dynagen management console for Dynamips and Pemuwrapper 0.11.0
Copyright (c) 2005-2007 Greg Anuzelli, contributions Pavel Skovajsa
=>
Finally dynagen loaded our network topology. We can handle it now. We can start routers with "start" command on dynagen console and get console of routers with "telnet Rx" command (x is number of router name, for example R4).
We may need to use the "idlepc" parameter in this sample. If you need more performance, you have to use idlepc parameter. Dynagen can optimize itself using the value given for idlepc. We have to learn only what is our idlepc value for our system. We can use following command in the dynagen console,
=> start R1
=> idlepc get R1
Please wait while gathering statistics...
Please wait while gathering statistics...
Done. Suggested idling PC:
0x60c08128 (count=22)
0x60c08164 (count=33)
0x60c08180 (count=35)
0x60c081c0 (count=66)
0x62b2823c (count=45)
0x60c08bf8 (count=23)
0x60c08c20 (count=20)
0x614b0e34 (count=38)
0x62b2b134 (count=20)
0x6026bca4 (count=30)
Restart the emulator with "--idle-pc=0x60c08128" (for example)
1: 0x60c08128 [22]
2: 0x60c08164 [33]
3: 0x60c08180 [35]
4: 0x60c081c0 [66]
5: 0x62b2823c [45]
6: 0x60c08bf8 [23]
7: 0x60c08c20 [20]
8: 0x614b0e34 [38]
9: 0x62b2b134 [20]
10: 0x6026bca4 [30]
Potentially better idlepc values marked with "*"
Enter the number of the idlepc value to apply [1-10] or ENTER for no change:
No changes made
=>
If you find any "*" line, you can use this line value. If you don't have any marked line with "*", you can try to get idlepc value again.