Network Simulator
Use NSO's network simulator to simulate your network and test functionality.
The ncs-netsim
program is a useful tool to simulate a network of devices to be managed by NSO. It makes it easy to test NSO packages towards simulated devices. All you need is the NSO NED packages for the devices that you need to simulate. The devices are simulated with the Tail-f ConfD product.
All the NSO examples use ncs-netsim
to simulate the devices. A good way to learn how to use ncs-netsim
is to study them.
Using Netsim
The ncs-netsim
tool takes any number of NED packages as input. The user can specify the number of device instances per package (device type) and a string that is used as a prefix for the name of the devices. The command takes the following parameters:
Assume that you have prepared an NSO package for a device called router
. (See the examples.ncs/getting-started/developing-with-ncs/0-router-network
example). Also, assume the package is in ./packages/router
. At this point, you can create the simulated network by:
This creates three devices; device0
, device1
, and device2
. The simulated network is stored in the ./netsim
directory. The output structure is:
There is one separate directory for every ConfD simulating the devices.
The network can be started with:
You can add more devices to the network in a similar way as it was created. E.g. if you created a network with some Juniper devices and want to add some Cisco IOS devices. Point to the NED you want to use (See {NCS_DIR}/packages/neds/
) and run the command. Remember to start the new devices after they have been added to the network.
To extract the device data from the simulated network to a file in XML format:
This data is usually used to load the simulated network into NSO. Putting the XML file in the ./ncs-cdb
folder will load it when NSO starts. If NSO is already started it can be reloaded while running.
The generated device data creates devices of the same type as the device being simulated. This is true for NETCONF, CLI, and SNMP devices. When simulating generic devices, the simulated device will run as a netconf device.
Under very special circumstances, one can choose to force running the simulation as a generic device with the option --force-generic
.
The simulated network device info can be shown with:
Here you can see the device name, the working directory, and the port number for different services to be accessed on the simulated device (NETCONF SSH, SNMP, IPC, and direct access to the CLI).
You can reach the CLI of individual devices with:
The simulated devices actually provide three different styles of CLI:
cli
: J-Stylecli-c
: Cisco XR Stylecli-i
: Cisco IOS Style
Individual devices can be started and stopped with:
You can check the status of the simulated network. Either a short version just to see if the device is running or a more verbose with all the information.
View which packages are used in the simulated network:
It is also possible to reset the network back to the state of initialization:
When you are done, remove the network:
Using ConfD Tools with Netsim
The netsim tool includes a standard ConfD distribution and the ConfD C API library (libconfd) that the ConfD tools use. The library is built with default settings where the values for MAXDEPTH and MAXKEYLEN are 20 and 9, respectively. These values define the size of confd_hkeypath_t
struct and this size is related to the size of data models in terms of depth and key lengths. Default values should be big enough even for very large and complex data models. But in some rare cases, one or both of these values might not be large enough for a given data model.
One might observe a limitation when the data models that are used by simulated devices exceed these limits. Then it would not be possible to use the ConfD tools that are provided with the netsim. To overcome this limitation, it is advised to use the corresponding NSO tools to perform desired tasks on devices.
NSO and ConfD tools and Python APIs are basically the same except for naming, the default IPC port and the MAXDEPTH and MAXKEYLEN values, where for NSO tools, the values are set to 60 and 18, respectively. Thus, the advised solution is to use the NSO tools and NSO Python API with netsim.
E.g. Instead of using the below command:
One may use:
Learn More
The README file in examples.ncs/getting-started/developing-with-ncs/0-router-network
gives a good introduction on how to use ncs-netsim
.
Last updated