For how to verify the correctness of the network protocol and perform related performance tests, people have put forward a lot of methods, and the most widely used methods are simulated by virtual environments. NS-2 is the most popular software for network simulation, has been widely used by research institutes and colleges and universities for network analysis, research and teaching. It supports numerous agreements and provides a wealth of test scripts.
The NS-2 is full of NetWork Simulator Version 2. It is an object-oriented, discrete event-driven network environment simulator, which is mainly used to solve network research problems. NS-2 provides analog in a wireless or wired network, TCP, routing, multicast and other protocols.
The earliest source of NS-2 and 1989 Real Network Simulator project have been supported by Xerox in 1995 in 1995, joining the VINT project. NS has always absorbed the results of researchers around the world, including UCB, CMU and other universities and SUN wireless networks.
NS-2 is implemented by two programming languages, OTCL (with TCL script programming languages for object-oriented features) and C . The reason why the two programming languages is used because the simulator has two things to do. On the one hand, the simulation and implementation of the specific protocol requires a programming language that can perform information such as bytes (Packet Header), and the appropriate algorithm can be operated on a large number of data sets. In order to achieve this task, the running speed of the program internal module is very important, and the time of running analog environments, finds and fixes the bug time, the time to recompile and run (Run-Around Time) is not very important. In this case, the C language is very suitable.
On the other hand, many networks are carried out around the settings and changes of the specific parameters of the network components and the environment, which requires fast development and simulation of the required network environment in a short time, and convenient to modify And found that the bug in the repair program. In this task, the time of the network environment is important, because the establishment of the analog environment and the configuration of the parameter information need to be run once. In this case, the scripting language has a great advantage, and the TCL scripting language with object-oriented features can fully meet the needs. The internal class structure of NS-2 is shown in Figure 1.
Figure 1: NS-2 class structure diagram
The structure of ns-2 nodes is very similar to the network nodes in the actual environment, as shown in Figure 2. For a network node, there is an IP address and port number, which corresponds to the address classifier and port classifier in the figure. When the TCP packet comes from the node entry comes in the node, it is first determined whether the IP address is the same as this node at the address classifier. If the same, enter the port classifier, the purpose of obtaining the packet through the TCP header The port is sent to the corresponding port of the node to the corresponding port; if the destination IP address of the packet is discovered at the address classifier, the packet is resended into the link to handle other node processing.
Figure 2: NS-2 node structure diagram
In short, NS-2 provides us with a good test platform. It uses two languages, C facilitates fast running speed; TCL is conducive to rapidly establishing a test environment. The entity structure in NS-2 is also very clear, which is conducive to building new network protocols and network entities. (T114)