NS3 Road---Tutorial interpretation---beginning&&concept

Source: Internet
Author: User

Given that the NS3 installation has already been written, the beginning section will not be re-introduced.

The fourth chapter introduces the very important concepts in several networks. For the network is familiar with basically a look can understand, understanding these concepts for understanding NS3 is very important. The following is the tutorial fourth chapter of the relevant translation work.

Introduction to Related concepts

First of all, it is necessary to introduce the relevant concepts before the development of the NS3 program. They are the most basic objects in the network and must therefore be understood.

Node-node

In Internet terminology, a computing device connected to a network is called a host or terminal. But since NS3 is a network emulator, not an Internet simulator, we are more accustomed to using the concept node in graph theory to describe it.

The base class of a Node object is a nodes class written in C + + that provides a variety of methods for simulating computing devices in a network. It also allows users to add functionality (applications, protocol stacks, external device drivers ...) to their interiors. ) to simulate more complex network devices.

Application-application

Computer software is divided into two categories: System software and application software. The system software is responsible for organizing all kinds of resources (memory, processor, disk, network ...) ), the application software is used to complete user requirements (during which time it may be necessary to communicate with the system software to use its resources). In Ns3, however, there is no operating system concept, so the system software does not exist, leaving only the application.

In Ns3, the base class of the application is application. But at the beginning of the study, we used two specific application classes directly, they inherited application, respectively: udpechoclientapplication (client) and udpechoserverapplication (server). They can be used to generate and respond to packets.

Channel-channel

In reality, the media that the network communication data flows through is willing to be called "the Channel". Similarly, in NS3 we also need to have the concept of a channel. Its base class is expressed using channel. Channels are used to manage communication between communication subnets, between nodes and communication subnets.

In NS3, specific channel classes are provided, which inherit from the channel. are: Csmachannel (carrier-listening multichannel access channel), Pointtopointchannel (Point-to-point channel), Wifichannel (WiFi channel). Different channels support the same protocol, such as Csmachannel on its communication medium to provide carrier interception and collision detection, can simulate the characteristics of Ethernet.

Network Devices-net Device

It is always known that when you need to use a computer to surf the Internet, you must use a network interface card (NIC). However, the hardware card must be software-driven, and the combination of the two can work properly. In the Linux operating system, they appear in the form similar to eth0.

In Ns3, the simulation of network equipment includes two parts: hardware and soft drive. And it must be "installed" in node to allow node to communicate externally with the channel. In addition, a node allows multiple net Device to communicate with the outside through multiple channel.

The abstraction of network devices in NS3 is Netdevice, which provides a way to connect channel and node. The specific derived classes in NS3 are: Csmanetdevice (CSMA network device), Pointtopointnetdevice (Point-to-point network device), Wifinetdevice (WiFi network device). Different network devices should be used between node and the corresponding channel. For example: Csmanetdevice corresponds to Csmachannel.

Topology Helper-topology Helpers

The reality of the network is very complex, want to simulate in the NS3, then must be in node, Netdevice, channel to build a variety of connections, including the allocation of IP, and so on. To simplify development efforts, NS3 provides a topology helpers to help build a network topology, which provides developers with a more convenient model.

The first of the ns-3 Script

Take the ns-3.15 I installed as an example, in ... ns-3.15/examples/tutorial/first.cc, this is the first example we need to learn. For an explanation of this example, please refer to Tutorial 第25-33 page for details. This article selects the section which is not described above to explain.

    1. Nodecontainer

is located under the Ns3 namespace. It provides a way to manage, create, and Access node objects. The Create () involved in the program is the method that creates the node.

    1. Pointtopointhelper

It belongs to the topology Helper we mentioned earlier. Constructs a point-to-point link in the script, connecting Pointtopointnetdevice and Pointtopointchannel. After instantiating the object, two methods were used: Setdeviceattribute () Set the properties of the network device, including MTU, Address, BPS, daterate, etc. setchannelattribute () set the channel properties, specific access to Www.nsnam.org/docs/release/3.24/doxygen;

    1. Netdevicecontainer

A network device container, similar to Nodecontainer, is a container for network devices. But it does not create objects like Netcontainer. Instead, a network device card is constructed by connecting the channel and node together, and it is attached to the node and channel. The property values that were initially set when the channel was created are transitioned to the created property. The following code matches the container as Object 22.

Netdevicecontainer = Pointtopointhelper.install (Nodecontainer);

    1. Internetstackhelper

The network protocol Deployer, which belongs to the topology Helper mentioned earlier, requires that the Internet Protocol (TCP, UDP, IP, and so on) be deployed in the node after the overall topology is set up. The following installation process takes the node container as an object.

Internetstackhelper.install (Nodecontainer);

    1. Ipv4addresshelper

is responsible for the allocation of IP address, the same for convenience, you can directly use the node container as the object for address assignment. At present, this class provides only the basic IP address and subnet mask setting function, the function is SetBase ().

Ipv4addresshelper.setbase (IP, MASK);

The specific allocations are done by the Assign () method, with the container as an object and the IP assigned sequentially. Of course, the IP address is bound on netdevice. This forms a network interface, which is saved as Ipv4interfacecontainer, and is also a container class, providing a unified access to the outside.

Ipv4internetcontainer = Ipv4addresshelper.assign (Netdevicecontainer);

In this way, a basic network architecture is built. The next thing to do is to generate traffic in the network.

Application-application

As mentioned earlier, in order to simplify the process of getting started, we mentioned two specific classes: Udpechoserverapplication and Udpechoclientapplication, respectively, as servers and clients, in NS3 in order to reduce the work of developers, Udpechoserverhelper and Udpechoclienthelper are provided respectively, and for server helper it is necessary to set a listening port at initialization, and then install the service into a node (not a node container). The resulting udpechoserverapplication is also stored in the Applicationcontainer container.

Udpserverhelper Echoserver (PORT);

Applicationcontainer = Udpechoserverhelper.install (Node);

Client helper needs to set the remote IP address, remote port of access during initialization. Next, set the related attributes (packet size, contract interval, etc.), and finally install the client on the node.

Udpechoclienthelper echoclient (remote IP, remote Port);

Udpechoclienthelper.setattribute (ATTRIBUTES);

Applicationcontainer = Udpechoclienthelper.install (Node);

It is important to note that both the server and the client are stored in the Applicationcontainer, but the program is built with two applicationcontainer, which are stored separately. objects within the same container are stored in first served order.

Simulation-simulator

After the infrastructure is set up and the traffic engineering setup is complete, you can start the network and start the simulation. Simulation time with flow motion is determined by the start and shutdown times of the client and server. The simulation directly calls run to start the entire project.

Simulator::run ();

However, after the run is finished, it must be closed to avoid problems such as memory leaks.

Simulator::D Estroy ();

In addition, the emulator can display a stop, which is a call to stop ().

Simulator::stop ();

Before the program runs, it is generally compiled and then run.

$./waf

$./waf–run Your-programm

NS3 Road---Tutorial interpretation---beginning&&concept

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.