Thursday, September 5, 2019
Examining The Network Simulations Of NS2 Information Technology Essay
Examining The Network Simulations Of NS2 Information Technology Essay NS2 is a Linux based tool to perform network simulations. NS2 is based on C++ and TCL programming Languages. TCL uses simple commands to define network configuration and C++ allows users to adjust protocol functionalities in detail and also to define new protocols. Our Project involves simulation of VoIP over two transport layer protocols UDP and SCTP. Installation of NS2: Installation of NS2 involves many steps. These Steps are: Checking for pre-requisites: Please make sure that you have installed the fedora 12 O.S with all packages and you are logged in as administrator. Downloading latest version of NS2: We first Downloaded NS2 v. 2.34 from: http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/ns-allinone-2.34.tar.gz/download Extracting the NS2 package: Extract the contents of .tar file in a directory and go into that directory. The following snapshot shows the extracted file against .tar file. Patching of SCTP module: Initially NS2 does not provide support to SCTP, so we have to download apply its patch before installation of NS2. The patch can be downloaded from http://pel.cis.udel.edu Now untar the patch in a directory and type the given command in terminal: patch -p0 Now we are ready to install NS2 with SCTP module. Installation of NS2 : We can either install NS2 by typing commands in the terminal. Or we can do this by simply double clicking the install file. The snapshot below shows the later. Now the installation has started. It would take some time to complete it. Configuring the installation path of NS2: The terminal will get get closed after installation of NS2. Now open terminal again and type: gedit ~/.bashrc to configure the path file Now edit this file as in the figure: Now save and close bash file and type following command in the terminal to tell your O.S about the path of NS2: source ~/.bashrc Confirming the installation of NS2: To confirm that NS2 is correctly installed, type ns in the terminal. The outlook of the terminal will be changed in this way: (Else it would print some filter of error in the terminal.) To revert to the normal mode type exit in the terminal. Running a simple code on NS2: NS2 executes .tcl file format. If you have followed all the previous steps, then you can execute a .tcl file by typing the following syntax in the terminal: ns [file name].tcl But make sure you are the directory where the .tcl file is present. e.g: Here we have a sample code script.tcl. In this code we are simulating a simple topology of two wired nodes. On typing ns script.tcl in the terminal, we get the following output: Handling the output trace file: On execution of .tcl code, two output files are generated. One is the .nam file with which we see the graphical simulation of our code. The other one is the .tr trace file, with which we can analyze the output of our simulation. The trace file looks like: It contains various parameters such as arrival time of packets, packet size transport agent etc. Using the trace file, we can get the graphical outputs to analyze the behavior of our simulation. To do this we need a graph drawing software such as xgraph or gnuplot. Here we are using gnuplot. But to draw a graph, we need to filter the trace file and get the coordinates out of which we can draw a graph. To filter a trace file, we write an awk script. Since we have to draw graphs for latency and throughput, therefore we will write one script for each type of graph. The awk script for latency is: #latency BEGIN { time1 = 0.0; time2 = 0.0; } { time2 = $2; if ($1==r) { printf(%f %fn, time1, time2) > latency; time1 += $2; } } END { print(Done); } And awk script for throughput is: #throughput BEGIN { node =1; time1 = 0.0; time2 = 0.0; num_packet=0; bytes_counter=0; } { time2 = $2; if (time2 time1 > 0.05) { thru = bytes_counter / (time2-time1); thru /= 1000000; printf(%f %fn, time2, thru) > throughput; time1 = $2; } if ($1==r) { bytes_counter += $6; num_packet++; } } END { print(Done); } Now type the following command in the terminal to filter the trace file: gawk file=[awk file name].awk [trace file name].tr The filtered file would be like this: Now weve to give a plot for which our graph is to be ploted. (i.e: weve to tell about the x and y coordinates) So we create a simple file in which we tell about these parameters. set title VoIP over UDP Latency! set grid set ylabel s set xlabel time plot latency w linespoints title voip throughput Now type gnuplot in the terminal to enter into gnuplot mode. Here type the command: load [x-y parameters file] (inner double quotes inclusive) And type exit to exit gnuplot Formation of VOIP Traffic over the Network: VoIP (Voice over IP) is simply the transmission of voice traffic over IP-based networks. The Internet Protocol (IP) was originally designed for data networking. à It is also referred to as IPà Telephonyà or Internet Telephony. Simulating VOIP in NS2: VoIP is basically just UDP packets encapsulating RTP packets with the voice data inside, all you should need to do to simulate a VoIP stream is set the correct packet size and frequency that the packets are sent out and that would simulate a stream. In NS2 we will implement VOIP over UDP and SCTP protocols. We will implement VOIP using a simple two-node topology. For this we will do the following steps: create two .tcl files simulate VOIP traffic handle the trace files to draw graphs for latency and throughput for evaluation between the two protocols Simulation of VoIP over the network using UDP: Creating the tcl file:- First create a tcl file for Voip simulation over UDP protocol. Given below is the source code for our file voip_udp.tcl # start new simulation set ns [new Simulator] # setup tracing/nam set tr [open voip.tr w] set nf [open voip.nam w] $ns trace-all $tr $ns namtrace-all $nf # finish function, close all trace files and open up nam proc finish {} { global ns nf tr $ns flush-trace close $nf close $tr exec nam voip.nam exit 0 } ### creating nodes set node0 [$ns node] $node0 label Voice 1 $node0 color red set node1 [$ns node] $node1 label Voice 2 $node1 color blue # creating duplex-link $ns duplex-link $node0 $node1 256Kb 50ms DropTail $ns duplex-link-op $node0 $node1 orient right # setup colors $ns color 1 Yellow $ns color 2 Green ## 2-way VoIP connection #Create a UDP agent and attach it to node0 set udp0 [new Agent/UDP] $ns attach-agent $node0 $udp0 # set udp0 flowid to 1 $udp0 set fid_ 1 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 128 $cbr0 set interval_ 0.020 # set traffic class to 1 $cbr0 set class_ 1 $cbr0 attach-agent $udp0 # Create a Null sink to receive UDP set sinknode1 [new Agent/LossMonitor] $ns attach-agent $node1 $sinknode1 # Connect the UDP traffic source to Null sink $ns connect $udp0 $sinknode1 set udp1 [new Agent/UDP] $ns attach-agent $node1 $udp1 $udp1 set fid_ 2 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 128 $cbr1 set interval_ 0.020 $cbr1 set class_ 2 $cbr1 attach-agent $udp1 set sinknode0 [new Agent/LossMonitor] $ns attach-agent $node0 $sinknode0 $ns connect $udp1 $sinknode0 # end of voice simulation setup # start up traffic $ns at 0.1 $cbr0 start $ns at 0.1 $cbr1 start $ns at 10.0 $cbr0 stop $ns at 10.0 $cbr1 stop $ns at 10.5 finish # run the simulation $ns run Simulate VOIP traffic: Now type the following command in the terminal to view simulation of VOIP over UDP: ns voip_udp.tcl The output is: Performance of SCTP: Now we draw the graphs with gnuplot using above mentioned steps. The performance is evaluated on the basis of latency, throughput and capacity. The capacity can be evaluated with the help of latency and throughput. Latency: Throughput: Simulation of VoIP over the network using SCTP: Creating the tcl file:- First create a tcl file for Voip simulation over UDP protocol. Given below is the source code for our file voip_sctp.tcl # start new simulation set ns [new Simulator] # setup tracing/nam set tr [open voip.tr w] set nf [open voip.nam w] $ns trace-all $tr $ns namtrace-all $nf # finish function, close all trace files and open up nam proc finish {} { global ns nf tr $ns flush-trace close $nf close $tr exec nam voip.nam exit 0 } ### creating nodes set n0 [$ns node] $n0 label Voice 1 $n0 color red set n1 [$ns node] $n1 label Voice 2 $n1 color blue # creating duplex-link $ns duplex-link $n0 $n1 256Kb 50ms DropTail $ns duplex-link-op $n0 $n1 orient right # setup colors $ns color 1 Yellow $ns color 2 Green ## 2-way VoIP connection #Create a UDP agent and attach it to n0 set sctp0 [new Agent/SCTP] $ns attach-agent $n0 $sctp0 $sctp0 set fid_ 1 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 128 $cbr0 set interval_ 0.020 # set traffic class to 1 $cbr0 set class_ 1 $cbr0 attach-agent $sctp0 # Create a Null sink to receive Data set sinknode1 [new Agent/LossMonitor] $ns attach-agent $n1 $sinknode1 set sctp1 [new Agent/SCTP] $ns attach-agent $n1 $sctp1 $sctp1 set fid_ 2 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 128 $cbr1 set interval_ 0.020 $cbr1 set class_ 2 $cbr1 attach-agent $sctp1 set sinknode0 [new Agent/LossMonitor] $ns attach-agent $n0 $sinknode0 $ns connect $sctp0 $sctp1 $ns at 0.1 $cbr0 start $ns at 0.1 $cbr1 start # stop up traffic $ns at 10.0 $cbr0 stop $ns at 10.0 $cbr1 stop # finish simulation $ns at 10.5 finish # run the simulation $ns run Simulate VOIP traffic: Now type the following command in the terminal to view simulation of VOIP over UDP: ns voip_sctp.tcl The output is: Performance of SCTP: Now we draw the graphs with gnuplot using above mentioned steps. The performance is evaluated on the basis of latency, throughput and capacity. The capacity can be evaluated with the help of latency and throughput. Latency: Throughput: Difference between SCTP and UDP: SCTP: SCTP Stands for Stream Control Transmission Protocol. It is a Transport Layer protocol. It is a connection-oriented protocol similar to TCP, but provides facilities such as multi-streaming and multi-homing for better performance and redundancy. It is used in Unix-like operating systems. UDP: UDP stands for User Datagram Protocol. It is a minimal message-oriented transport layer protocol. It enables two hosts to connect and send short messages to one another. Unlike Transmission Control Protocol (TCP), it does not guarantee that data is received or that it is received in the order in which it was sent. Comparison between SCTP and UDP: Message Orientation: In SCTP, message boundaries are preserved. If an application sends a 100-byte message, the peer application will receive all 100 bytes in a single read: no more, no less. UDP provides a message-oriented service, but without SCTPs reliability. Un-Ordered Service: In addition to ordered message service (and parallel ordered service discussed above), SCTP offers the reliable delivery of messages with no order constraints. UDP provides unordered service, but again without SCTPs reliability. Unordered reliable delivery will be useful for many applications, in particular disk over LAN services (iSCSI, RDMA, etc.) where the application already provides ordering. Stronger checksum: SCTP uses a 32-bit end-to-end checksum proven to be mathematically stronger than the 16-bit ones-complement sum used by UDP. SCTPs better checksum provides stronger verification that a message passes end-to-end without bit errors going undetected. These were some of the differences between SCTP and UDP. A tabulated contrast between the two protocols is given below: Services/Features SCTP UDP Connection-oriented yes no Full duplex yes yes Reliable data transfer yes no Partial-reliable data transfer optional no Ordered data delivery yes no Unordered data delivery yes yes Flow control yes no Congestion control yes no ECN capable yes no Selective ACKs yes no Preservation of message boundaries yes yes Path MTU discovery yes no Application PDU fragmentation yes no Application PDU bundling yes no Multistreaming yes no Multihoming yes no Protection against SYN flooding attacks yes n/a Allows half-closed connections no n/a Reachability check yes no Psuedo-header for checksum no (uses vtags) yes Time wait state for vtags n/a SCTP vs. UDP Latency: From the graphs of latency we conclude that latency is slightly higher in UDP. In real practice, latency in UDP is much higher than in SCTP. Practically, the latency in UDP is about 15% more than SCTP. Throughput: From the graphs of throughput we see that UDP shows a constant but less throughput while SCTP shows continuous fluctuations in its graph. But overall SCTP has a higher throughput than UDP. In real practice, throughput in SCTP is about 15% more than in UDP. Capacity: By observing the graphs of throughput, we conclude the SCTP can support more capacity than UDP. UDP will loose its performance at higher data rates. Conclusion: From the above statistics, we conclude that SCTP is better than UDP in terms of latency, throughput and capacity. Therefore there is no doubt in the fact that that SCTP is going to be the future of VOIP and many other network technologies. But since this technology is under the process of evolution so it may take some time for it to replace the older technologies like UDP and TCP etc. Refrences: http://yonghoon.livejournal.com/4799.html http://www.isoc.org/briefings/017/index.shtml http://www.google.com/dictionary?source=dict-chrome-exsl=entl=enq=sctp http://www.google.com/dictionary?langpair=en|enq=udphl=enaq=f http://mailman.isi.edu/pipermail/ns-users/2006-August/056723.html http://books.google.com.pk/books?id=bF3L7g1u_mQCpg=PA189lpg=PA189dq=udp+vs+sctp+latency+throughputsource=blots=zdb5JeCsMfsig=PPt8c4nvtcrIJcXr5eKBIe_GbkQhl=enei=XhIgTYCeLs-z8QO8_KS8BQsa=Xoi=book_resultct=resultresnum=2ved=0CB4Q6AEwAQ#v=onepageqf=true
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.