Computer Network Simulation Using NS2

Page 1 of 33

CHAPTER 6 WIRED NETWORK SIMULATION

6.1    Introduction The architecture of NS2 and certain preliminary concepts were discussed in Chapter 4 and Chapter 5. In this chapter, we discuss simulation of a wired network. Computer communication networks may be classified into two types: wired and wireless. In wired networks, the nodes are connected via cables. On the other hand, in wireless networks the nodes are connected with air as the medium. In the first case a topology of the network is usually defined, whereas in the second case nodes can move and the topology changes dynamically and hence no static topology can be defined. If a node comes within the communication range of another node, then direct communication between the two nodes is possible. In this chapter we discuss simulation of wired networks, and wireless network simulation is discussed in Chapter 7. We start with a few simple examples and gradually develop programs of increasing sophistication with the objective of being able to simulate real-life wired network scenarios for various kinds of networks.

6.2    Step-by-Step Wired Network Simulation Complete network simulation using NS2 involves many steps. To be able to satisfactorily simulate a network, a thorough understanding of these steps is necessary. A minimal step-by-step process to simulate any wired network is provided in the form of a block diagram in Figure 6.1. The different blocks are briefly discussed below. Each block represents a step, and the details of these steps are discussed in subsequent sections. All simulation scripts are written using Tcl.

Figure 6.1 Block diagram for wired network simulation in NS2 Step I: Creating the Event Scheduler Creating the event scheduler is the first program statement in any NS2 program. This scheduler queues any event that is generated by the simulation. The scheduler is an object of the simulator class. The following Tcl statement is used to create the event scheduler. set ns [new Simulator] Step II: Tracing This step is essential if you need to record the events that are occurring during the simulation experiments in a specific format in a plain-text file. These files are treated as the output of any

file:///C:/Users/admin/AppData/Local/Temp/bityefte.y04/OPS/xhtml/13_Chapter06.xht... 4/16/2018

Computer Network Simulation Using NS2

Page 2 of 33

simulation program execution. Two types of traces are available. One is used by the programmer to analyze the simulation results for various network parameters (like throughput, delay, etc.) and is called the Packet Trace/Event Trace/NS trace. The other one is used by the network animator (NAM) module to create visualization for the simulation and is known as the NAM Trace. The following Tcl syntax may be used to generate traces. Syntax: Packet Trace set ptf [open w] $ns trace-all $ptf Syntax: NAM Trace set ntf [open w] $ns namtrace-all $ntf The file names given in angular brackets are user defined, i.e., the user has to provide the file name. Packet-trace is discussed in more detail in Section 6.7. Step III Creating Network Topology In this step the network topology is created. Different kinds of network topologies can be defined as per the user requirement. To realize a required topology, a set of nodes is first created, and the links between the nodes are defined as per the requirement. The syntax to create the nodes and links is provided below. Also, some complete programs are given to demonstrate the creation of different topologies. These programs may be executed to visualize the topologies in the NAM window. Syntax: Creating nodes set [$ns node] Syntax: Creating a link between two nodes $ns

Link parameters: •  The link-type can be simplex or duplex. •  node1 and node2 represents the nodes between which the link needs to be established. •  link-bw represents the bandwidth of the link normally provided in Mbps. •  Delay is the propagation delay in ms. •  Each link is associated with an interface queue in the MAC sublayer. These queues can be of various types and are discussed in subsequent sections. The simplest queue type is drop-tail, which is essentially a FIFO queue and when the queue is full any arriving packet is dropped. Let’s now write a program to create two nodes and a link between them. The code is given in Listing 6.1. Listing 6.1 A Two Node Network set ns [new Simulator]; # create Simulator Object 1 2 3 set nf [open twoNode . nam w]; # create NAM trace file 4 $ns namtrace -all $nf; # write into nam file 5 6 7 8 9 10 11 12

set n0 [$ns node]; # create node n0 set n1 [$ns node]; # create node n1 # create a duplex link between them $ns duplex -link $n0 $n1 10 Mb 10 ms DropTail $ns run; # run the simulation

file:///C:/Users/admin/AppData/Local/Temp/bityefte.y04/OPS/xhtml/13_Chapter06.xht... 4/16/2018

Computer Network Simulation Using NS2

Page 3 of 33

Write and save the program in a file with extension .tcl (twoNode.tcl). Now run the program using the following command in the command line/shell prompt. $ ns twoNode.tcl This command will execute the Tcl script and produce the NAM traces that are stored in a file named twoNode.nam, as given in line 3 of Listing 6.1. To see the NAM visualization, use the following command. $ nam twoNode.nam & This results in the creation of the topology shown in Figure 6.2. In this program only the NAM trace is used, and no packet trace is used, as no packet transmission is made between these nodes. The packet transmission mechanism will be discussed later in this chapter.

Figure 6.2 A two-node network with a point-to-point link. Let us now write another program for a four-node mesh network, as shown in Listing 6.2. Listing 6.2 Four-node mesh network 1 # Four node Mesh Topology set ns [new Simulator] 2 3 set nf [open fourNode . nam w] 4 $ns namtrace - all $nf 5 6 set n0 [$ns node] 7 set n1 [$ns node] 8 set n2 [$ns node] 9 set n3 [$ns node] 10 11 # create link between each node 12 $ns duplex - link $n0 $n1 10 Mb 10 ms DropTail 13 $ns duplex - link $n0 $n2 10 Mb 10 ms DropTail 14 $ns duplex - link $n0 $n3 10 Mb 10 ms DropTail 15 $ns duplex - link $n0 $n2 10 Mb 10 ms DropTail 16 $ns duplex - link $n1 $n3 10 Mb 10 ms DropTail 17 $ns duplex - link $n1 $n3 10 Mb 10 ms DropTail 18 19 $ns run 20 When code Listing 6.2 is executed using execution commands (as in the previous program), it will produce the topology provided in Figure 6.3 with four nodes and six links among them. If the actual layout does not resemble the figure provided, then click on the relayout button of the NAM window provided in the right bottom corner to get the figure in the proper layout (it may sometimes require multiple clicks).

Figure 6.3 Four-node mesh topology

file:///C:/Users/admin/AppData/Local/Temp/bityefte.y04/OPS/xhtml/13_Chapter06.xht... 4/16/2018

Computer Network Simulation Using NS2

Page 4 of 33

As can be seen from Listing 6.2, to create multiple nodes and links lines 7 to 10 and lines 13 to 18 are repeated redundantly. The same program may be rewritten using loops and arrays, as shown in Listing 6.3. Listing 6.3 Four-node mesh network using loops #Four node Mesh Topology 1 2 set ns [new Simulator] 3 4 set nf [open fourNode . nam w] 5 $ns namtrace - all $nf 6 #create nodes 7 for {set i 0} {$i < 4} {incr i} { set n($i) [$ns node] 8 9 } 10 #create links 11 for {set i 0} {$i < 3} {incr i} { for {set j [expr $i +1]} {$j < 4} {incr j} { 12 $ns duplex - link $n($i) $n($j) 10 Mb 10 ms DropTail 13 } 14 15 } 16 17 $ns run Step IV: Simulating Network Layer Protocol The network layer activity definition is optional in NS2. That is, if the user does not define any protocol for the network layer, then the simulator chooses a default routing protocol. We defer discussion of the definition of the network layer to subsequent sections. Step V: Attaching Transport Protocol Transport agents are created in pairs, as default options of NS2 support half-duplex connections in the transport layer. That is, one source agent and one sink agent need to be created for any connection. Many transport layer protocols are available in NS2, but here we discuss the UDP agent, the simplest one, and other agents are discussed later in this chapter. Syntax: Create source agent set [new Agent/UDP] Syntax: Attach the agent to a specific node (sender) $ns attach-agent Syntax: Create sink agent set [new Agent/Null] Syntax: Attach the sink agent to another node (receiver) $ns attach-agent Syntax: Connect two agents $ns connect Step VI: Application Now we need to attach an application that generates packets for transmission through the connections (traffic generation). Out of many traffic types available in NS2, we choose constant bit rate traffic for this example. Other traffic types will be discussed later in this chapter. Syntax: Create and attach application traffic set [new Application/Traffic/CBR] attach-agent Syntax: start and stop data transmission $ns at

chapter 6 wired network simulation -

Page 1 of 33. Computer Network Simulation Using NS2. 4/16/2018 file:///C:/Users/admin/AppData/Local/Temp/bityefte.y04/OPS/xhtml/13_Chapter06.xht.

3MB Sizes 1 Downloads 899 Views

Recommend Documents

Chapter 6 - Home
write each new term and its definition in your notebook. □ communication (p. 174). □ verbal communication. (p. 175). □ nonverbal communication ..... Page 9 ...

Chapter 6
when a lot of features are irrelevant and drown out the relevant features' signal in the distance calculations. Notice that the nearest-neighbor method can easily be applied to regression problems with a real-valued target variable. In fact, the meth

CHAPTER 6 Clean.pdf
time by approved providers. Approved providers include: (A) The American Physical Therapy Association (APTA),. including any sections, credentialed ...

Chapter 6 Friction.pdf
R. T1. R. A 1g. 1a. R. R. 1g. 1a.. 0.5g. 0.5g. a. A B. =0.2. 0.5kg. 1kg 1kg. =0.2. 2×0.5 16N. R1. 4g. 16N=T. 2R. 4×0.5. 30°. a. 1. 0.5 m/s2. 2kg. 4kg. 2. Page 3 of 10. Chapter 6 Friction.pdf. Chapter 6 Friction.pdf. Open. Extract. Open with. Sign

Chapter 6 Review.pdf
The Worthington Pottery Company manufactures beer mugs in batches of 120. and the overall rate of defects is 5%. Find the probability of having more than 6. defects in a batch. 8. A bank's loan officer rates applicants for credit. The ratings are nor

chapter 6.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. chapter 6.pdf.

CHAPTER 6 Clean.pdf
A license or certificate holder who seeks a waiver of the continuing. competence requirements shall provide to the Board in writing the specific reasons for requesting. the waiver and additional information that the Board may request in support of th

Chapter 6.pdf
Page 1 of 18. Page 1 of 18. Page 2 of 18. Page 2 of 18. Page 3 of 18. Page 3 of 18. Page 4 of 18. Page 4 of 18. Chapter 6.pdf. Chapter 6.pdf. Open. Extract. Open with. Sign In. Details. Comments. General Info. Type. Dimensions. Size. Duration. Locati

Chapter 5 and 6 - GitHub
Mar 8, 2018 - These things are based on the sampling distribution of the estimators (ˆβ) if the model is true and we don't do any model selection. • What if we do model selection, use Kernels, think the model is wrong? • None of those formulas

Chapter 6.pdf
by gulping air at the surface of the water or by releasing dissolved gases. from their blood. 6.1. expanded swim bladder contracted swim bladder. Figure 2.

Chapter 6-DatabaseConnectivity.pdf
The Prerequisite for connecting a Java application to MySQL is adding MySQL. JDBC driver in the Project/Program. The NetBeans IDE comes with pre-bundled MySQL JDBC Driver. You may add. JDBC Driver in the Database Connectivity Project as follows-. Pag

AIFFD Chapter 6 - Mortality - GitHub
6.5 Adjusting Catch-at-Age Data for Unequal Recruitment . . . . . . . . . . . . . . . . . . . . . . ...... System: Windows, i386-w64-mingw32/i386 (32-bit). Base Packages: base ...

GNS3 Network Simulation Guide.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Main menu.

GNS3 Network Simulation Guide.pdf
GNS3 Network Simulation Guide.pdf. GNS3 Network Simulation Guide.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying GNS3 Network Simulation ...Missing:

GNS3 Network Simulation Guide.pdf
GNS3 Network Simulation Guide.pdf. GNS3 Network Simulation Guide.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying GNS3 Network Simulation ...

Chapter Number 6 Chapter Title Incentives and ...
Mar 30, 2015 - well as by technology. ..... [6] Casper, B. A., and S. A. Tyson. .... cisions under incomplete information, whereas we abstract from collective action ...

Managerial Economics & Business Strategy Chapter 6
Procure inputs in the least cost manner, like point B. • Provide incentives for workers to put forth effort. • Failure to accomplish this results in a point like A.

Adopted Rule Chapter 6.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Adopted Rule ...

Chapter 6. The Elections Act.pdf
... Social Networking. §6-3.8. Door-to-door Campaigning. §6-3.9. Social Functions. §6-3.10. Student Government Facilities. §6-3.11. Campaign-Restricted Areas.

Geometry Chapter 6 Test Review.pdf
Loading… Page 1. Whoops! There was a problem loading more pages. Retrying... Geometry Chapter 6 Test Review.pdf. Geometry Chapter 6 Test Review.pdf.

Chapter 6 Multivector Calculus -
definition. 1We are following the treatment of Tensors in section 3–10 of [4]. ...... ∂αL |α=0 = ∂αL(x + αn)|α=0 = n · ∇L = ∇ · (nL). (8.66). ∂αψ i|α=0 = n · ∇ψi.

Chapter 6 - Audio Amplifier.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Chapter 6 ...