Previous Tip  |  Next Tip  |  Design Tips   | [Bill's Home]

140. Router emulator

Well, along with the switch, wireless AP and UNIX emulators, here is a Cisco router emulator:

[Expand]

A key element in an emulator is to allow the users to complete the required configuration with a single key stroke or command. Thus if you enter enable, followed by complete, you should have all the required settings. This can be checked using the show running-config command. The reload command with erase the configuration. This is achieved with:

else if (str=="complete") set_complete();

....

function set_complete()
{
e0.ip="219.17.100.1";e0.subnetmask="255.255.255.0"; e0.submaskbits="24"; e0.stat="up"; e0.protocol="up";
s0.ip="199.6.13.1";s0.subnetmask="255.255.255.0"; s0.submaskbits="24";s0.stat="up"; s0.protocol="up";
s0.encapsulation="ppp"; s0.authentication="chap";
s1.ip="201.100.11.2";s1.subnetmask="255.255.255.0"; s1.submaskbits="24";s1.stat="up"; s1.protocol="up";
s1.encapsulation="ppp";s1.authentication="chap";
network_type="rip";
no_networks=3;
network[0]="199.6.13.0";
network[1]="201.100.11.0";
network[2]="219.17.100.0";
hosts_table[0].name="LAB_A";
hosts_table[0].host1="192.5.5.1";
hosts_table[0].host2="205.7.5.1";
hosts_table[0].host3="201.100.11.1";
hosts_table[1].name="LAB_B";
hosts_table[1].host1="210.100.11.2";
hosts_table[1].host2="219.17.100.1";
hosts_table[1].host3="199.6.13.1";
hosts_table[2].name="LAB_C";
hosts_table[2].host1="223.8.151.1";
hosts_table[2].host2="204.204.7.1";
hosts_table[2].host3="199.6.13.1";
hosts_table[3].name="LAB_D";
hosts_table[3].host1="210.93.105.1";
hosts_table[3].host2="204.204.7.2";
hosts_table[4].name="LAB_E";
hosts_table[4].host1="210.93.105.2";

no_hosts_table=5;

nameserver="192.168.0.10";
domainname="mycomp.com";

}