If you want to simulate a Cisco router, you can use dynamips but if you want to create a network topology you have to use both of dynagen and dynamips. This blog post is about about creating a sample network topology, connecting routers to each other and testing all nodes in the topology.
I'm using Ubuntu 12.04 to show an example now. First, we have to install dynagen (and dynamips) on Ubuntu 12.04. Actually we will also need dynamips but dynamips is a dependance of dynamips. So if we install dynagen, dynamips will be installed with dynagen.
ismail@ismail-ThinkPad-T410:~$ sudo apt-get install dynagen Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: dynamips python-configobj The following NEW packages will be installed: dynagen dynamips python-configobj 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. Need to get 1,070 kB/1,418 kB of archives. After this operation, 4,263 kB of additional disk space will be used. Do you want to continue [Y/n]? Get:1 http://tr.archive.ubuntu.com/ubuntu/ precise/main python-configobj all 4.7.2+ds-3build1 [233 kB] Get:2 http://tr.archive.ubuntu.com/ubuntu/ precise/multiverse dynagen all 0.11.0-6 [836 kB] Fetched 1,070 kB in 0s (1,495 kB/s) Selecting previously unselected package dynamips. (Reading database ... 206573 files and directories currently installed.) Unpacking dynamips (from .../dynamips_0.2.7-0.2.8RC2-5ubuntu1_amd64.deb) ... Selecting previously unselected package python-configobj. Unpacking python-configobj (from .../python-configobj_4.7.2+ds-3build1_all.deb) ... Selecting previously unselected package dynagen. Unpacking dynagen (from .../dynagen_0.11.0-6_all.deb) ... Processing triggers for man-db ... Processing triggers for doc-base ... Processing 1 added doc-base file... Registering documents with scrollkeeper... Setting up dynamips (0.2.7-0.2.8RC2-5ubuntu1) ... Setting up python-configobj (4.7.2+ds-3build1) ... Setting up dynagen (0.11.0-6) ... Processing triggers for python-support ... ismail@ismail-ThinkPad-T410:~$
Let's start to work with sample network topology;
There are only 3 routers on our sample network topology. Only one dynamips instance should be enough.
1-) Start dynamips instance
ismail@ismail-ThinkPad-T410:~$ dynamips -H 7100 & [1] 16919 ismail@ismail-ThinkPad-T410:~$ Cisco Router Simulation Platform (version 0.2.8-RC2-amd64) Copyright (c) 2005-2007 Christophe Fillot. Build date: Jan 18 2011 19:25:29 Hypervisor TCP control server started (port 7100). ismail@ismail-ThinkPad-T410:~$ ps -ef | grep dynamips ismail 16919 8265 6 17:59 pts/2 00:00:00 dynamips -H 7100 ismail 16934 8265 0 17:59 pts/2 00:00:00 grep --color=auto dynamips ismail@ismail-ThinkPad-T410:~$
We are starting dynamips service with "dynamips -H 7100 &" and checking it with "ps -ef | grep dynamips" command.
2-) Create a dynagen configuration file
# [START INSTANCE1] [localhost:7100] udp=10000 workingdir = /tmp/working [[3725]] image = /tmp/c3725-adventerprisek9-mz.124-15.T13.bin ram = 128 # idlepc = ?? We will talk about it later. ghostios = true sparsemem = true idlemax = 100 disk0=128 [[Router R1]] model = 3725 console = 2001 autostart = false # F0/0 = S0/0 = R2 S0/0 [[Router R2]] model = 3725 console = 2002 autostart = false # F0/0 = S0/0 = R1 S0/0 S0/1 = R3 S0/0 [[Router R3]] model = 3725 console = 2003 autostart = false S0/0 = R2 S0/1 # F0/0 = # [FINISH INSTANCE1]
First stage is about connecting to an existing dynamips service. Dynamips will create some files when it is loading a topology. This files will be created in the "workingdir" directory.
Second stage is about creating a Cisco Router model. We have to define a Cisco ios file path and some hardware specifications in this stage.
The last stages are about defining our virtual routers. If we create more than one models, we can select different models for earch virtual router. The "console" key defines the port number. We will use this port numbers to connect to console of router. Autostart key defines either manual or auto router booting while starting to dynagen process. Finally we will define connections between virtual routers.
I created a "working" directory under /tmp and the dynagen configuration file before starting the dynagen as shown below:
ismail@ismail-ThinkPad-T410:~$ vim /tmp/sample1.net {write dynagen configuration file content as above INSTANCE1} ismail@ismail-ThinkPad-T410:~$ ismail@ismail-ThinkPad-T410:~$ dynagen /tmp/sample1.net Reading configuration file... Shutdown in progress... Shutdown completed. CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb. NVRAM is empty, setting config register to 0x2142 C3725 instance 'ghost-c3725-adventerprisek9-mz.124-15.T13.bin-localhost.ghost' (id 3): VM Status : 0 RAM size : 128 Mb NVRAM size : 128 Kb IOS image : /tmp/c3725-adventerprisek9-mz.124-15.T13.bin Loading ELF file '/tmp/c3725-adventerprisek9-mz.124-15.T13.bin'... ELF entry point: 0x80008000 C3725 'ghost-c3725-adventerprisek9-mz.124-15.T13.bin-localhost.ghost': starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled. C3725 'ghost-c3725-adventerprisek9-mz.124-15.T13.bin-localhost.ghost': stopping simulation. Network successfully loaded Dynagen management console for Dynamips and Pemuwrapper 0.11.0 Copyright (c) 2005-2007 Greg Anuzelli, contributions Pavel Skovajsa => list Name Type State Server Console R1 3725 stopped localhost:7100 2001 R2 3725 stopped localhost:7100 2002 R3 3725 stopped localhost:7100 2003 => => ? 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 => => start R1 Warning: Starting R1 with no idle-pc value CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb. C3725 instance 'R1' (id 0): VM Status : 0 RAM size : 128 Mb NVRAM size : 128 Kb IOS image : /tmp/c3725-adventerprisek9-mz.124-15.T13.bin Loading ELF file '/tmp/c3725-adventerprisek9-mz.124-15.T13.bin'... ELF loading skipped, using a ghost RAM file. ELF entry point: 0x80008000 C3725 'R1': starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled. 100-VM 'R1' started => => start R2 Warning: Starting R2 with no idle-pc value CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb. NVRAM is empty, setting config register to 0x2142 C3725 instance 'R2' (id 1): VM Status : 0 RAM size : 128 Mb NVRAM size : 128 Kb IOS image : /tmp/c3725-adventerprisek9-mz.124-15.T13.bin Loading ELF file '/tmp/c3725-adventerprisek9-mz.124-15.T13.bin'... ELF loading skipped, using a ghost RAM file. ELF entry point: 0x80008000 C3725 'R2': starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled. 100-VM 'R2' started => start R3 Warning: Starting R3 with no idle-pc value CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb. NVRAM is empty, setting config register to 0x2142 C3725 instance 'R3' (id 2): VM Status : 0 RAM size : 128 Mb NVRAM size : 128 Kb IOS image : /tmp/c3725-adventerprisek9-mz.124-15.T13.bin Loading ELF file '/tmp/c3725-adventerprisek9-mz.124-15.T13.bin'... ELF loading skipped, using a ghost RAM file. ELF entry point: 0x80008000 C3725 'R3': starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled. 100-VM 'R3' started =>
Open another terminal and execute this command:
ismail@ismail-ThinkPad-T410:~$ telnet localhost 2001 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Connected to Dynamips VM "R1" (ID 0, type c3725) - Console port when press enter will appear this; % Please answer 'yes' or 'no'. Would you like to enter the initial configuration dialog? [yes/no]:
press Ctrl+c and enter and enter again:
Press RETURN to get started! *Mar 1 00:00:03.843: %LINEPROTO-5-UPDOWN: Line protocol on Interface VoIP-Null0, changed state to up *Mar 1 00:00:03.847: %LINEPROTO-5-UPDOWN: Line protocol on Interface IPv6-mpls, changed state to up *Mar 1 00:00:03.927: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up *Mar 1 00:00:03.935: %LINK-3-UPDOWN: Interface Serial0/1, changed state to up *Mar 1 00:00:04.927: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up *Mar 1 00:00:04.935: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up *Mar 1 00:00:32.927: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to down *Mar 1 00:01:26.839: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down *Mar 1 00:01:32.875: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up *Mar 1 00:01:39.015: %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to administratively down *Mar 1 00:0 Router>1:39.075: %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to administratively down *Mar 1 00:01:40.115: %SYS-5-RESTART: System restarted -- Cisco IOS Software, 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(15)T13, RELEASE SOFTWARE (fc3) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2010 by Cisco Systems, Inc. Compiled Wed 07-Apr-10 12:44 by prod_rel_team *Mar 1 00:01:40.123: %SNMP-5-COLDSTART: SNMP agent on host Router is undergoing a cold start *Mar 1 00:01:40.147: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down *Mar 1 00:01:40.147: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to down *Mar 1 00:01:40.159: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is OFF *Mar 1 00:01:40.159: %CRYPTO-6-GDOI_ON_OFF: GDOI is OFF *Mar 1 00:01:40.951: %LINK-5-CHANGED: Interface Serial0/0, changed state to administratively down *Mar 1 00:01:40.951: %LINK-5-CHANGED: Interface Serial0/1, changed state to administratively down *Mar 1 00:01:41.951: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down *Mar 1 00:01:43.839: %IP-5-WEBINST_KILL: Terminating DNS process Router>
So you can get console for other virtual routers with "telnet localhost 2002", "telnet localhost 2003" and "telnet localhost 2004" commands.
I'm preparing more samples for multiple instances, physical ethernet connectivity and switch simulation with dynagen&dynamips.
Dynagen is a front-end for use with the Dynamips which is a Cisco router emulator.. thanx for the tutorial for creating multiple ciscor router stimulation
ReplyDeleteyou're amazing! thanks for the share
ReplyDelete