Telecommunication Network Lab Manual

Published on January 2017 | Categories: Documents | Downloads: 30 | Comments: 0 | Views: 386
of 45
Download PDF   Embed   Report

Comments

Content

Telecommunication Networks

Ashish Ranjan, 8102333 Jaypee Institute of Information Technology

Index
S.N o Name of the Experiment Date Teacher’s Signature Remarks

1

To understand the basic Unix Commands. & using those commands, calculate factorial of 9. Design the following network with the given capacity of link & propogation delay. Give red color to the Nodes 1 to 6 & green to therest nodes. Links can be taken of any color. UDP & TCP Simulations Using NS2 Design LAN/Ethernet Design Ad hoc network (MANET) of three wireless mobile nodes Analysis of trace file in TCP/UDP/LAN TCP in wireless scenario Comparison Of Different Tcp Congestion Avoidance Algorithms In Wireless Scenario Studying Error Models

2

3 4 5

6 7 8 9

S.N o

Name of the Experiment

Date

Teacher’s Signature

Remarks

Experiment - 1
Aim : To understand the basic Unix Commands. & using those commands,
calculate factorial of 9.

Some Basic Unix Commands :
C program related commands: Command indent filename gcc abc.c ‐o abc Description To indent files containing C programs. Compile the file abc.c and create the executable abc.out.

Directories related commands: Command Description mkdir dirname Makes a new directory. pwd Prints the current working directory. Rm-r/rmdir Removes an empty directory. cd Changes to home directory. cd ~ Changes to home directory. cd .. Changes to parent directory. cd dirname Changes to named directory. rename from to f Renames the specified files by replacing the first ile occurrence of from in their name by to.

File related commands: Command ls ls -l ls -a ls abc* mv f1 f2 cp f1 f2 rm f1 rm -i wc f1 cat f1 Description Lists files and directories. Lists files in ‘long format’ i.e containing useful info. About file such as who owns it, exact size of file. Lists all files and directories. Lists all files and directories starting with abc. Moves a file i.e gives it a different name or moves it into a different directory Copy file1 to file2. Removes a file. Ask for a confirmation before deleting anything. Gives no of lines, words and characters in a file. To view a file.

cat > f1 cat f1 f2 > f3 gzip f1 gunzip f1 lpr grep string f1 grep-v string f1 tar -vf f.tar f1 f2 Tar-xvf f.tar

To create a file. Concatenates file1 and file2 to file3. Produces a compressed a file with .gz extension. Decompress a file compressed with gzip. Prints a file. Prints all lines of file that contain the string. Prints all lines of the file except those that contain the string. To combine multiple files into a single file. To separate an archive created by tar into separate files.

Question : Calculate factorial of 9.

Code :
Creation :- gedit ashish.c #include<stdio.h> int main() { int num,i,Pro=1; printf(" Enter the Number : "); scanf("%d",&num); for(i=1;i<=num;i++) { Pro=Pro*i; } printf(" Factorial = "); printf("%d",Pro); } Compile :Run :gcc ashish.c –o ashish ./ashish

Output :Enter the Number : 5 Factorial = 120

Result :-

All the basic commands are successful tried on unix & factorial of a given no. is found.

Experiment -2 Aim :Definition of a Network of links & nodes.
Design the following network with the given capacity of link & propogation delay. Give red color to the Nodes 1 to 6 & green to therest nodes. Links can be taken of any color.

1 10Mb, 10ms

6 10Mb, 10ms 25Mb, 15ms 3 40Mb, 15ms 4 5Mb, 5ms 5 1 7

1 8 20Mb, 5ms

0.5Mb, 15ms

15Mb, 5ms

2

9

Theory :A network simulator is a piece of software or hardware that predicts the behavior of a network without an actual network being present. Network simulators, as the name suggests are used by researchers, developers and engineers to design various kinds of networks, simulate and then analyze the effect of various parameters on the network performance. A typical network simulator encompasses a wide range of networking technologies and help the users to build complex networks from basic building blocks like variety of nodes and links.the help of simulators, one can design hierarchical networks using various types of nodes like computers, hubs, bridges, routers, switches, links, mobile units etc.

Code : set ns [new Simulator]

set nf [open out.nam w] $ns namtrace-all $nf proc finish {} { global ns nf $ns flush-trace exec nam out.nam & exit 0 } set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] set n6 [$ns node] set n7 [$ns node] set n8 [$ns node] set n9 [$ns node] $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns simplex-link $n1 $n3 10Mb 10ms DropTail duplex-link $n2 $n3 0.5Mb 15ms DropTail simplex-link $n3 $n4 40Mb 15ms DropTail duplex-link $n4 $n5 5Mb 5ms DropTail duplex-link $n4 $n6 10Mb 10ms DropTail simplex-link $n4 $n7 25Mb 5ms DropTail duplex-link $n7 $n8 20Mb 5ms DropTail duplex-link $n7 $n9 15Mb 5ms DropTail simplex-link-op $n1 $n3 orient right-down duplex-link-op $n2 $n3 orient right-up simplex-link-op $n3 $n4 orient right duplex-link-op $n4 $n5 orient down duplex-link-op $n4 $n6 orient up simplex-link-op $n4 $n7 orient right duplex-link-op $n7 $n8 orient right-up duplex-link-op $n7 $n9 orient right-down simplex-link-op $n1 $n3 color "blue" duplex-link-op $n2 $n3 color "blue" simplex-link-op $n3 $n4 color "blue" duplex-link-op $n4 $n5 color "blue" duplex-link-op $n4 $n6 color "blue" simplex-link-op $n4 $n7 color "blue" duplex-link-op $n7 $n8 color "blue"

$ns duplex-link-op $n7 $n9 color "blue" $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 color color color color color color color color color red red red red red red green green green

$ns at 5.0 "finish" $ns run

Output :-

Result :Given network of nodes & links is designed using network simulator.

Experiment -3
Aim :UDP & TCP Simulations Using NS2 :-

Theory

Transmission Control Protocol (TCP) and User Datagram Protocol (UDP)is a transportation protocol that is one of the core protocols of the Internet protocol suite. Both TCP and UDP work at transport layer TCP/IP model and both have very different usage. TCP (Transmission Control Protocol) : TCP is a connection-oriented protocol, a connection can be made from client to server, and from then on any data can be sent along that connection.








Reliable - when you send a message along a TCP socket, you know it will get there unless the connection fails completely. If it gets lost along the way, the server will re-request the lost part. This means complete integrity, things don't get corrupted. Ordered - if you send two messages along a connection, one after the other, you know the first message will get there first. You don't have to worry about data arriving in the wrong order. Heavyweight - when the low level parts of the TCP "stream" arrive in the wrong order, resend requests have to be sent, and all the out of sequence parts have to be put back together, so requires a bit of work to piece together. Acknowledgement TCP primarily uses a cumulative acknowledgment scheme, where the receiver sends an acknowledgment signifying that the receiver has received all data preceding the acknowledged sequence number.

UDP (User Datagram Protocol) : A simpler message-based connectionless protocol. With UDP you send messages(packets) across the network in chunks.
• •

Unreliable - When you send a message, you don't know if it'll get there, it could get lost on the way. Not ordered - If you send two messages out, you don't know what order they'll arrive in.



Lightweight - No ordering of messages, no tracking connections, etc. It's just fire and forget! This means it's a lot quicker, and the network card / OS have to do very little work to translate the data back from the packets.

Question

:- Design the network drawn below with the propagation delay of 40 ms & Capacity of link is 10 Mb. Then simulate the UDP between node 0 and 9 & TCP between nodes 0 & 6 .

Network :4 10Mb, 40ms 5 1 10Mb, 40ms

1 10Mb, 40ms 3 10Mb, 40ms

8 10Mb, 40ms 7

10Mb, 40ms 2

10Mb, 40ms

10Mb, 40ms

9 10Mb, 40ms 1 0

6

Code :
set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf proc finish {} { global ns nf $ns flush-trace exec nam out.nam & exit 0

} set set set set set set set set set set $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns n1 [$ns node] n2 [$ns node] n3 [$ns node] n7 [$ns node] n8 [$ns node] n9 [$ns node] n4 [$ns node] n5 [$ns node] n6 [$ns node] n10 [$ns node] duplex-link duplex-link duplex-link duplex-link duplex-link duplex-link duplex-link duplex-link duplex-link $n1 $n2 $n3 $n7 $n7 $n9 $n9 $n8 $n8 $n3 10Mb 40ms DropTail $n3 10Mb 40ms DropTail $n7 10Mb 40ms DropTail $n8 10Mb 40ms DropTail $n9 10Mb 40ms DropTail $n10 10Mb 40ms DropTail $n6 10Mb 40ms DropTail $n4 10Mb 40ms DropTail $n5 10Mb 40ms DropTail $n3 orient right-down $n3 orient right-up $n7 orient right $n8 orient right-up $n9 orient right-down $n9 orient right-up $n10 orient right-down $n8 orient right-down $n5 orient right-up $n3 color "blue" $n3 color "blue" $n7 color "blue" $n8 color "blue" $n9 color "blue" $n5 color "blue" $n4 color "blue" $n9 color "blue" $n10 color "blue"

duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op

$n1 $n2 $n3 $n7 $n7 $n6 $n9 $n4 $n8 $n1 $n2 $n3 $n7 $n7 $n8 $n8 $n6 $n9

$n1 color red $n2 color red

$n3 color red $n7 color green $n8 color green $n9 color green $n4 color black $n5 color black $n6 color black $n10 color black # ------------------ TCP ----------------------------- # set tcp [new Agent/TCP] $ns attach-agent $n1 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n4 $sink $ns connect $tcp $sink $tcp set fid_ 1 $tcp set packetsize_ 552 set ftp [new Application/FTP] $ftp attach-agent $tcp #----------------- UDP ----------------------------- # set udp0 [new Agent/UDP] $ns attach-agent $n1 $udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetsize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 set null0 [new Agent/Null] $ns attach-agent $n10 $null0 $ns connect $udp0 $null0 $ns at 0.5 "$cbr0 start" $ns at 3.0 "$cbr0 stop" $ns at 0.1 "$ftp start" $ns at 10.0 "$ftp stop" $ns at 20.0 "finish" $ns run

Output :
UDP : Between node 0 & node 9 TCP : Between node 0 & node 6

Data is sent using TCP

Data is sent using UDP

Acknowledgement is sent by receiver in TCP.

No such Acknowledgement in UDP.

Result :

Givent Network has been drawn and UDP, TCP simulation is performed using NS2.

Expriment - 4
Aim :
Design LAN/Ethernet .

Theory :
Ethernet protocols refer to the family of local-area network (LAN) covered by the IEEE 802.3. A local area network (LAN) is a computer network that connects computers and devices in a limited geographical area such as home, school, computer laboratory or office building. Ethernett defines a number of wiring and signaling standards for the Physical Layer of the OSI networking model as well as a common addressing format and a variety of Medium Access Control procedures at the lower part of the Data Link Layer. In the Ethernet standard, there are two modes of operation: half-duplex and full-duplex modes. In the half duplex mode, data are transmitted using the popular CSMA/CD protocol on a shared medium. The main disadvantages of the half-duplex are the efficiency and distance limitation, in which the link distance is limited by the minimum MAC frame size. This restriction reduces the efficiency drastically for high-rate transmission. Therefore, the carrier extension technique is used to ensure the minimum frame size of 512 bytes in Gigabit Ethernet to achieve a reasonable link distance.Full duplex is a well know mode of operation in wide area telecommunication networks. Four data rates are currently defined for operation over optical fiber and twisted-pair cables: • 10 Mbps - 10Base-T Ethernet (IEEE 802.3) • 100 Mbps - Fast Ethernet (IEEE 802.3u) • 1000 Mbps - Gigabit Ethernet (IEEE 802.3z) • 10-Gigabit - 10 Gbps Ethernet (IEEE 802.3ae). Ethernet uses a protocol called CSMA/CD, this stands for Carrier Sense, Multiple Access with Collision Detection. To understand what this means lets separate the three parts.
• •

Carrier Sense - When a device connected to an Ethernet network wants to send data it first checks to make sure it has a carrier on which to send its data (usually a piece of copper cable connected to a hub or another machine).





Multiple Access - This means that all machines on the network are free to use the network whenever they like so long as no one else is transmitting. Collision Detection - A means of ensuring that when two machines start to transmit data simultaneously, that the resultant corrupted data is discarded, and re-transmissions are generated at differing time intervals.

Ethernet confuses people because it is a 'broadcast' protocol--the packet is broadcasted to all hosts on the network, but the packet is only 'destined' for the host whose MAC address matches the one in the desitnation MAC field of the Ethernet frame

Question :• •

• •

Design the folowing Lan/Ethernet with given specifications. Capacity of link is 15 Mb . Propogation delay is of 20ms. Data Packets are transmitted b/w nodes 0 & 10 using FTP/IP protocol. Data Packets are transmitted b/w nodes 2 & 8 using UDP protocol.

0

1 3

5 1

8

9 2 6 1 0

4

7

Code :set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf

proc finish {} { global ns nf $ns flush-trace exec nam out.nam & exit 0 } set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] set n6 [$ns node] set n7 [$ns node] set n8 [$ns node] set n9 [$ns node] set n10 [$ns node] set lan [ $ns newLan "$n5 $n6 $n7 $n8 $n9 $n10" 0.5Mb 40ms LL Queue/Droptail Mac/Csma/Cd Channel ] $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns duplex-link duplex-link duplex-link duplex-link duplex-link duplex-link duplex-link $n0 $n1 $n2 $n2 $n3 $n4 $n4 $n1 $n2 $n3 $n4 $n5 $n6 $n7 15Mb 15Mb 15Mb 15Mb 15Mb 15Mb 15Mb 20ms 20ms 20ms 20ms 20ms 20ms 20ms DropTail DropTail DropTail DropTail DropTail DropTail DropTail

duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op

$n0 $n2 $n2 $n2 $n3 $n4 $n4

$n1 $n1 $n3 $n4 $n5 $n6 $n7

orient orient orient orient orient orient orient

right up right-up right-down right right-up right-down

$n0 color black $n1 color black

$n2 color red $n3 color red $n4 color black $n5 color red $n7 color black $n6 color black $n8 color red $n9 color black $n10 color black $ns duplex-link-op $n2 $n3 color blue $ns duplex-link-op $n3 $n5 color blue #--------- TCP ----------- # set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n10 $sink $ns connect $tcp $sink $tcp set fid_ 1 $tcp set packetsize_ 552 set ftp [new Application/FTP] $ftp attach-agent $tcp # ------- UDP ------------- # set udp0 [new Agent/UDP] $ns attach-agent $n2 $udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetsize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 set null0 [new Agent/Null] $ns attach-agent $n8 $null0

$ns connect $udp0 $null0 $ns at 0.5 "$cbr0 start" $ns at 3.0 "$cbr0 stop" $ns at 0.1 "$ftp start" $ns at 10.0 "$ftp stop" $ns at 20.0 "finish" $ns run

Output :-

Fig .1 :- LAN

Fig.2 :- TCP

Fig .3 :- Fall of Data Packets

Fig .4 :- TCP/IP b/w 0 & 10. UDP b/w nodes 2 & 8

Result :-

Given LAN/Ethernet is designed & output is observed.

Experiment - 5
Aim :- Design Ad hoc network (MANET) of three wireless mobile nodes. Theory :
An ad hoc network is a collection of mobile nodes forming a temporary network without the aid of any centralized administration or standard support services. MANET are formed by a group of nodes that can transmit and receive data and also relay data among themselves. Communication between nodes is made over wireless links. A pair of nodes can establish a wireless link among themselves only if they are within transmission range of each other. An important feature of ad hoc networks is that routes between two hosts may consist of hops through other hosts in the network When a sender node wants to communicate with a receiver node, it may happen that they are not within communication range of each other. However, they might have the chance to communicate if other hosts that lie in-between are willing to forward packets for them. This characteristic of MANET is known as multihopping. Figure 1.1 illustrates an ad hoc network with four wireless mobile nodes. In this example, each node is within transmission range of two neighboring nodes (indicated by the circles around each node), but is out of range of a third. If two nodes which are not within range of each other wish to exchange information, they must enlist the aid of intermediary nodes to forward information on their behalf. In Figure 1.1, if node 1 sends a packet to node 4, it must send it first to node 2 (or 3). Node 2 can then forward the packet on to node 4.

Figure 5.1: Ad hoc network of four wireless mobile nodes. Each time a packet is transmitted to a neighboring node, it is said to have made a hop. In the above example, when node 1 sends a packet to node 4, the packet makes two hops: first from node 1 to node 2, and second from node 2 to node 4.

Code :set set set set set set set set set set set set set set set set set val(chan) Channel/WirelessChannel val(prop) Propagation/TwoRayGround val(netif) Phy/WirelessPhy val(mac) Mac/802_11 val(ifq) Queue/DropTail/PriQueue val(ll) LL val(ant) Antenna/OmniAntenna val(ifqlen) 50 val(nn) 3 val(rp) DSDV val(x) 500 val(y) 400 val(stop) 150 ns [new Simulator] tracefd [open simple.tr w] windowVsTime2 [open win.tr w] namtrace [open simwrls.nam w]

$ns trace-all $tracefd $ns namtrace-all-wireless $namtrace $val(x) $val(y) set topo [new Topography]

$topo load_flatgrid $val(x) $val(y) create-god $val(nn) $ns node-config -adhocRouting $val(rp) \ -llType $val(ll) \ -macType $val(mac) \ -ifqType $val(ifq) \ -ifqLen $val(ifqlen) \ -antType $val(ant) \ -propType $val(prop) \ -phyType $val(netif) \ -channelType $val(chan) \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace ON \ for {set i 0} {$i < $val(nn) } { incr i } { set node_($i) [$ns node] } $node_(0) set X_ 2.0 $node_(0) set Y_ 5.0 $node_(0) set Z_ 0.0 $node_(1) set X_ 15.0 $node_(1) set Y_ 20.0 $node_(1) set Z_ 0.0 $node_(2) set X_ 5.0 $node_(2) set Y_ 10.0

$node_(2) set Z_ 0.0 $ns at 15.0 "$node_(0) setdest 45.0 285.0 10.0" $ns at 30.0 "$node_(2) setdest 100.0 100.0 15.0" set tcp [new Agent/TCP/Newreno] $tcp set class_ 2 set sink [new Agent/TCPSink] $ns attach-agent $node_(0) $tcp $ns attach-agent $node_(1) $sink $ns connect $tcp $sink set ftp [new Application/FTP] $ftp attach-agent $tcp $ns at 10.0 "$ftp start" for {set i 0} {$i < $val(nn) } { incr i } { $ns initial_node_pos $node_($i) 30 } for {set i 0} {$i < $val(nn) } { incr i } { $ns at $val(stop) "$node_($i) reset"; } $ns at $val(stop) "$ns nam-end-wireless $val(stop)" $ns at $val(stop) "stop" $ns at 150.01 "puts \"end simulation\" ; $ns halt" proc stop {} { global ns tracefd namtrace $ns flush-trace close $tracefd close $namtrace } $ns run

Output :-

Figure 5.2: Ad hoc network of three wireless mobile nodes.

Result :designed & Ad hoc network of three wireless mobile nodes is successfully implemented on NS2.

Experiment - 6
Aim :Analysis of trace file in TCP/UDP/LAN. Theory : An example of a trace file (without the tcp header fields) might appear as follows: + 1.84375 0 2 cbr 210 ------- 0 0.0 3.1 225 610 - 1.84375 0 2 cbr 210 ------- 0 0.0 3.1 225 610 r 1.84471 2 1 cbr 210 ------- 1 3.0 1.0 195 600 r 1.84566 2 0 ack 40 ------- 2 3.2 0.1 82 602 + 1.84566 0 2 tcp 1000 ------- 2 0.1 3.2 102 611 - 1.84566 0 2 tcp 1000 ------- 2 0.1 3.2 102 611 r 1.84609 0 2 cbr 210 ------- 0 0.0 3.1 225 610 + 1.84609 2 3 cbr 210 ------- 0 0.0 3.1 225 610 d 1.84609 2 3 cbr 210 ------- 0 0.0 3.1 225 610 - 1.8461 2 3 cbr 210 ------- 0 0.0 3.1 192 511 r 1.84612 3 2 cbr 210 ------- 1 3.0 1.0 196 603 + 1.84612 2 1 cbr 210 ------- 1 3.0 1.0 196 603 - 1.84612 2 1 cbr 210 ------- 1 3.0 1.0 196 603 + 1.84625 3 2 cbr 210 ------- 1 3.0 1.0 199 612

Here we see 14 trace entries, five enque operations (indicated by “+” in the first column), four deque operations (indicated by “-”), four receive events (indicated by “r”), and one drop event. (this had better be a trace fragment, or some packets would have just vanished!). The simulated time (in seconds) at which each event occurred is listed in the second column. The next two fields indicate between which two nodes tracing is happening. The next field is a descriptive name for the the type of packet seen. The next field is the packet’s size, as encoded in its IP header. The next field contains the flags, which not used in this example. The next field gives the IP flow identifier field as defined for IP version 6. In ns v2, the flow ID field is available for this purpose, but any additional should be placed in its own separate field, possibly in some other header. The subsequent two fields indicate the packet’s source and destination node addresses, respectively. The following field indicates the sequence number. The last field is a unique packet identifier. Each new packet created in the simulation is assigned a new, unique identifier.

For UDP :Code :set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf set tracefile1 [ open lab6a.tr w] $ns trace-all $tracefile1 proc finish {} { global ns nf $ns flush-trace exec nam out.nam & exit 0 } set set set set set set $ns $ns $ns $ns $ns n0 n1 n2 n3 n4 n5 [$ns [$ns [$ns [$ns [$ns [$ns node] node] node] node] node] node] $n0 $n2 $n2 $n3 $n3 $n2 $n1 $n3 $n4 $n5 1Mb 1Mb 1Mb 1Mb 1Mb 10ms 10ms 10ms 10ms 10ms DropTail DropTail DropTail DropTail DropTail

duplex-link duplex-link duplex-link duplex-link duplex-link

$ns duplex-link-op $n0 $n2 orient right-up

$ns $ns $ns $ns $ns $ns $ns $ns $ns

duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op

$n2 $n2 $n3 $n3 $n0 $n1 $n3 $n3 $n3

$n1 $n3 $n4 $n5 $n2 $n2 $n2 $n4 $n5

orient orient orient orient color color color color color

left-up right right-down right-up

"red" "green" "blue" "black" "purple"

# ------- UDP ------------- # set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetsize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 set null0 [new Agent/Null] $ns attach-agent $n5 $null0 $ns connect $udp0 $null0 $ns at 0.5 "$cbr0 start" $ns at 4.0 "$cbr0 stop" $ns at 5.0 "finish" $ns run

Figure : UDP

For TCP
Code :set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf

set tracefile1 [ open lab6b.tr w] $ns trace-all $tracefile1 proc finish {} { global ns nf $ns flush-trace exec nam out.nam & exit 0 } set set set set set set $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns n0 n1 n2 n3 n4 n5 [$ns [$ns [$ns [$ns [$ns [$ns node] node] node] node] node] node] $n0 $n2 $n2 $n3 $n3 $n2 $n1 $n3 $n4 $n5 1Mb 1Mb 1Mb 1Mb 1Mb 10ms 10ms 10ms 10ms 10ms DropTail DropTail DropTail DropTail DropTail

duplex-link duplex-link duplex-link duplex-link duplex-link

duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op duplex-link-op

$n0 $n2 $n2 $n3 $n3 $n0 $n1 $n3 $n3 $n3

$n2 $n1 $n3 $n4 $n5 $n2 $n2 $n2 $n4 $n5

orient orient orient orient orient color color color color color

right-up left-up right right-down right-up

"red" "green" "blue" "black" "purple"

$n1 shape box $n4 shape box # ------- TCP ------------- # set tcp [new Agent/TCP] $ns attach-agent $n1 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n4 $sink

$ns connect $tcp $sink $tcp set fid_ 1 $tcp set packetsize_ 552 set ftp [new Application/FTP] $ftp attach-agent $tcp $ns at 0.1 "$ftp start" $ns at 5.0 "$ftp stop" $ns at 5.0 "finish" $ns run

Figure. TCP

For LAN Code :-

set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf set tracefile1 [ open out.tr w] $ns trace-all $tracefile1 set set set set set set set set n0 n1 n2 n3 n4 n5 n6 n7 [$ns [$ns [$ns [$ns [$ns [$ns [$ns [$ns node] node] node] node] node] node] node] node]

set set set set set $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns $ns

n8 [$ns node] n9 [$ns node] n10 [$ns node] n11 [$ns node] n12 [$ns node] duplex-link $n0 $n1 15Mb 25ms DropTail duplex-link-op $n0 $n1 orient right-down duplex-link $n2 $n3 15Mb 25ms DropTail duplex-link-op $n2 $n3 orient right duplex-link $n3 $n1 15Mb 25ms DropTail duplex-link-op $n3 $n1 orient right-up duplex-link $n1 $n7 15Mb 25ms DropTail duplex-link-op $n1 $n7 orient right duplex-link $n7 $n9 15Mb 25ms DropTail duplex-link-op $n7 $n9 orient right-down duplex-link $n4 $n5 15Mb 25ms DropTail duplex-link-op $n4 $n5 orient right-down duplex-link $n6 $n5 15Mb 25ms DropTail duplex-link-op $n6 $n5 orient right-up duplex-link $n5 $n8 15Mb 25ms DropTail duplex-link-op $n5 $n8 orient right duplex-link $n8 $n9 15Mb 25ms DropTail duplex-link-op $n8 $n9 orient right-up

#setup a tcp2 connection b/w n0 to n10 set tcp2 [new Agent/TCP] $ns attach-agent $n0 $tcp2 set sink [new Agent/TCPSink] $ns attach-agent $n10 $sink $ns connect $tcp2 $sink $tcp2 set fid_ 1 set ftp2 [new Application/FTP] $ftp2 attach-agent $tcp2 #setup a tcp1 connection b/w n4 to n12 set tcp1 [new Agent/TCP] $ns attach-agent $n4 $tcp1 set sink [new Agent/TCPSink] $ns attach-agent $n12 $sink $ns connect $tcp1 $sink $tcp1 set fid_ 2 set ftp1 [new Application/FTP] $ftp1 attach-agent $tcp1

#setup a udp connection b/w n2 to n11 set udp1 [new Agent/UDP] $ns attach-agent $n2 $udp1 set null [new Agent/Null] $ns attach-agent $n11 $null $ns connect $udp1 $null $udp1 set fid_ -1 #cbr for the above udp set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp1 $ftp1 attach-agent $tcp1 set lan [$ns newLan "$n9 $n10 $n11 $n12" 50Mb 20ms LL Queue/DropTail MAC/Csma/Cd Channel] $ns $ns $ns $ns duplex-link duplex-link duplex-link duplex-link $n1 $n2 $n3 $n3 $n2 $n3 $n4 $n5 10Mb 30ms DropTail 1Mb 15ms DropTail 20Mb 10ms DropTail .5Mb 50ms DropTail right-up right right-up right-down

$ns duplex-link-op $n1 $n2 orient $ns duplex-link-op $n2 $n3 orient $ns duplex-link-op $n3 $n4 orient $ns duplex-link-op $n3 $n5 orient set tcp [new Agent/TCP] $ns attach-agent $n1 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n5 $sink $ns connect $tcp $sink $tcp set fid_ -1 $tcp set packetSize_ 552 set ftp [new Application/FTP] $ftp attach-agent $tcp $ns queue-limit $n1 $n2 2 $ns queue-limit $n2 $n3 2 $ns queue-limit $n3 $n5 2 proc finish { } { global ns nf $ns flush-trace close $nf exec nam out.nam & exit0 }

$ns $ns $ns $ns

at 0.0 "$ftp start" at 400.0 "$ftp stop" at 500.0 "finish" run

Fig. LAN

Output :Trace File of UDP : + 0.5 0 2 cbr 210 ------- 0 0.0 5.0 0 0 - 0.5 0 2 cbr 210 ------- 0 0.0 5.0 0 0 . . . - 4.99668 2 3 cbr 210 ------- 0 0.0 5.0 897 897 r 4.99836 2 3 cbr 210 ------- 0 0.0 5.0 895 895 + 4.99836 3 5 cbr 210 ------- 0 0.0 5.0 895 895 - 4.99836 3 5 cbr 210 ------- 0 0.0 5.0 895 895 + 5 0 2 cbr 210 ------- 0 0.0 5.0 900 900 - 5 0 2 cbr 210 ------- 0 0.0 5.0 900 900 Trace File of TCP : + 0.1 1 2 tcp 40 ------- 1 1.0 4.0 0 0 - 0.1 1 2 tcp 40 ------- 1 1.0 4.0 0 0 r 0.11032 1 2 tcp 40 ------- 1 1.0 4.0 0 0 . . . r 4.9984 2 1 ack 40 ------- 1 4.0 1.0 555 1127 + 4.9984 1 2 tcp 1040 ------- 1 1.0 4.0 575 1134 r 4.99904 2 3 tcp 1040 ------- 1 1.0 4.0 561 1106 + 4.99904 3 4 tcp 1040 ------- 1 1.0 4.0 561 1106 - 4.99904 3 4 tcp 1040 ------- 1 1.0 4.0 561 1106

Trace File of LAN : + 0 1 3 tcp 40 ------- -1 1.0 5.0 0 0 - 0 1 3 tcp 40 ------- -1 1.0 5.0 0 0 r 0.025021 1 3 tcp 40 ------- -1 1.0 5.0 0 0 . . . - 400.036799 3 1 ack 40 ------- -1 5.0 1.0 5854 12206 r 400.052349 3 1 ack 40 ------- -1 5.0 1.0 5853 12205 r 400.061821 3 1 ack 40 ------- -1 5.0 1.0 5854 12206

Result :Trace Files in TCP / UDP/ LAN are analysed.

Experiment - 7
Aim :TCP IN WIRELESS SCENARIO

Theory : An important performance measure of TCP is average throughput. Throughput is the average rate of successful message delivery over a communication channel. It is usually measured in bits per second (bit/s or bps), and sometimes in data packets per second or data packets per time. Code :set ns [new Simulator] class set nf [open out.nam w] for visualization created file out.nam in the write mode $ns namtrace-all $nf file set tf [open out.tr w] (output files with data opening the created file out.tr in write mode $ns trace-all $tf trace file, where recorded # defining the procedure finish proc finish {} { global ns nf tf $ns flush-trace # tf is the pointer to the all the traces are to # nf is the pointer to the nam # creating the trace file on simulation) and #Creating object of Simulator

# creating the nam file used and opening the

close $nf #close $tf exec nam out.nam & exit 0 } # defining nodes set n0 [$ns node] set n1 [$ns node]

$ns at 1.0 "$n0 label \"FTP\"" # creating links between nodes $ns duplex-link $n0 $n1 2Mb 100ms DropTail

#Set error model on link n0 to n1 set loss_module [new ErrorModel] $loss_module set rate_ 0.02 rate= 2% $loss_module ranvar [new RandomVariable/Uniform] distributed RV $loss_module drop-target [new Agent/Null] $ns lossmodel $loss_module $n0 $n1 #setup a TCP connection set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink/DelAck] $ns attach-agent $n1 $sink $ns connect $tcp $sink $tcp set fid_ 1 #setup an FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP #scheduling

# error #uniformly

$ns at 1.0 "$ftp start" $ns at 100.0 "$ftp stop" $ns at 120.0 "finish" $ns run

OUTPUT
10
4

TCP: TAHOE

10 No. of packets received

3

10

2

10

1

10 -2 10

0

10

-1

10 error %

0

10

1

10

2

Fig 1: No. of packets vs. error % plot(logarithmic) for Tahoe (default TCP scheme)

LEARNING OUTCOMES • • • We learned how to replicate wired cum wireless network by using error model. We learned how to read the trace file and used it for plotting the graph. With the help of the graph, we saw that the throughput decreases as the error rate in the link increases.

Experiment - 8
Aim :Comparison Of Different Tcp Congestion Avoidance Algorithms In Wireless Scenario. Theory : -

Modern implementations of TCP contain four intertwined algorithms: Slowstart, congestion avoidance, fast retransmit, and fast recovery. Slow Start: Slow Start, a requirement for TCP software implementations is a mechanism used by the sender to control the transmission rate, otherwise known as sender-based flow control. This is accomplished through the return rate of acknowledgements from the receiver. When a TCP connection first begins, the Slow Start algorithm initializes a congestion window to one segment which is the maximum segment size ( MSS ) initialized by the receiver during the connection establishment phase. When acknowledgements are returned by the receiver, the congestion window increases by one segment for each acknowledgement returned. Thus, the sender can transmit the minimum of the congestion window and the advertised window of the receiver, which is simply called the transmission window.

Congestion Avoidance: During the initial data transfer phase of a TCP connection the Slow Start algorithm is used. However, there may be a point during Slow Start that the network is forced to drop one or more packets due to overload or congestion. If this happens, Congestion Avoidance is used to slow the transmission rate. However, Slow Start is used in conjunction with Congestion Avoidance as the means to get the data transfer going again so it doesn’t slow down and stay slow. In the Congestion Avoidance algorithm a retransmission timer expiring or the reception of duplicate ACKs can implicitly signal the sender that a network congestion situation is occurring. The sender immediately sets its transmission window to one half of the current window size (the minimum of the congestion window and the receiver’s advertised window size), but to at least two segments. If congestion was indicated by a timeout, the congestion window is reset to one segment, which automatically puts the sender into Slow Start mode. If congestion was indicated by duplicate ACKs, the Fast Retransmit and Fast Recovery algorithms are invoked. Fast Retransmit: When a duplicate ACK is received, the sender does not know if it is because a TCP segment was lost or simply that a segment was delayed and received out of order at the receiver. If the receiver can re-order segments, it should not be long before the receiver sends the latest expected acknowledgement. Typically no more than one or two duplicate ACKs should be received when simple out of order conditions exist. If however more than two duplicate ACKs are received by the sender, it is a strong indication that at least one segment has been lost. The TCP sender will assume enough time has lapsed for all segments to be properly reordered by the fact that the receiver had enough time to send three duplicate ACKs. When three or more duplicate ACKs are received, the sender does not even wait for a retransmission timer to expire before retransmitting the segment. This process is called the Fast Retransmit algorithm. Fast Recovery: Since the Fast Retransmit algorithm is used when duplicate ACKs are being received, the TCP sender has implicit knowledge that there is data still flowing to the receiver. The reason is because duplicate ACKs can only be generated when a segment is received. This is a strong indication that serious network congestion may not exist and that the lost segment was a rare event. So instead of reducing the flow of data abruptly by going all the way into Slow Start, the sender only enters Congestion Avoidance mode. Rather than start at a window of one segment as in Slow Start mode, the sender resumes transmission with a larger window, incrementing as if in Congestion Avoidance mode. This allows for higher throughput under the condition of only moderate congestion. Along with the congestion the losses can be due to noisy links. This is especially true in case of radio links e.g. in cellular phones or in satellite

links. A link may become in fact completely disconnected for some period or it may suffer from occasional interferences (due to shadowing, fading, etc) that cause packets to contain errors and then to be dropped. For that, we introduce an error model where we assume that packets are dropped on forward link independently with some constant fixed probability. An important performance measure of TCP is average throughput. Throughput is the average rate of successful message delivery over a communication channel. It is usually measured in bits per second (bit/s or bps), and sometimes in data packets per second or data packets per time.
Code :-

set ns [new Simulator] Simulator class set nf [open out.nam w] used for visualization created file out.nam in

#Creating object of

# creating the nam file and opening the the write mode

$ns namtrace-all $nf nam file set tf [open out.tr w] (output files with data opening the created file

# nf is the pointer to the # creating the trace file on simulation) and out.tr in write

mode $ns trace-all $tf trace file, where recorded # defining the procedure finish proc finish {} { global ns nf tf $ns flush-trace close $nf #close $tf # tf is the pointer to the all the traces are to

exec nam out.nam & exit 0 } # defining nodes set n0 [$ns node] set n1 [$ns node]

$ns at 1.0 "$n0 label \"FTP\"" # creating links between nodes $ns duplex-link $n0 $n1 2Mb 100ms DropTail

#Set error model on link n0 to n1 set loss_module [new ErrorModel] $loss_module set rate_ 0.02 rate= 2% $loss_module ranvar [new RandomVariable/Uniform] distributed RV $loss_module drop-target [new Agent/Null] $ns lossmodel $loss_module $n0 $n1 #setup a TCP connection set tcp [new Agent/TCP] different congestion avoidance algos #set tcp [new Agent/TCP/NewReno] OR #set tcp [new Agent/TCP/Vegas] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink/DelAck] $ns attach-agent $n1 $sink $ns connect $tcp $sink $tcp set fid_ 1 #setup an FTP over TCP connection

# error #uniformly

# defining OR

set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP #scheduling $ns at 1.0 "$ftp start" $ns at 100.0 "$ftp stop" $ns at 120.0 "finish" $ns run

Output

LEARNING OUTCOMES

 We learned how to use different congestion avoidance algorithms of TCP  With the help of the graph we concluded that TCP Vegas in the best algorithm out of TCP Tahoe and TCP NewReno in terms of number of packets received at a particular error rate of the link.

Experiment 9

AIM:Studying Error Models THEORY

There has been renewed interest in exploring the functionality of TCP under the new conditions imposed by heterogeneous networks that are evolving at a fast pace. So, a researcher must have the means to test TCP under different conditions. He will have to replicate the wired-cum-wireless world in as realistic way as possible. Therefore one must have some error model in order to simulate losses in the network. The broad characteristics of error model are: Rate-based vs. Temporal error models :- Rate-based error models have a user specified deterministic or probabilistic drop rate on a persegment basis. In the latter case, the model drops a segment based on a Bernoulli trial with the specified probability. In a temporal error model, the user specifies the proportion of time that the channel is “bad” or “good”. In the bad state any segment that happens to be coming along is corrupted, whereas in the good state no segments are dropped. Since a rate-based model will corrupt a specified proportion of segments irrespective of the protocol behavior, it is difficult, under such a model, to confidently assess the impact of the proposed improvements to existing protocols or the performance gain of new ones. Synchronized vs. non-synchronized error models :- A TCO connection between two hosts could have the same forward and reverse paths, or could have at least one different link in the two paths. In the former case, whenever the forward path is in the bad state so should the reverse path be, and vice versa. In this sense, the error model has to be synchronized in both directions. On the other hand, if the forward and reverse paths are different, even if they exhibit the same error characteristics, the model should not be synchronized. A simple example of creating an error model with a packet error rate of 1% is – set loss_module [new ErrorModel] set its # create a loss_module and

$loss_module set rate_ 0.01 percent

packet error rate to 1

# optional: set the unit and random variable $loss_module unit pkt # error unit: packets (the default) $loss_module ranvar [new RandomVariable/Uniform] $loss_module drop-target [new Agent/Null] packets # set target for dropped

The ErrorModel class is derived from the Connector base class. As the result, it inherits some methods for hooking up objects such as target and droptarget. If the drop target exists, it will receive corrupted packets from ErrorModel. Otherwise, ErrorModel just marks the error_ flag of the packet's common header, thereby, allowing agents to handle the loss. The ErrorModel also defines additional Tcl method unit to specify the unit of error and ranvar to specify the random variable for generating errors. If not specified, the unit of error will be in packets, and the random variable will be uniform distributed from 0 to 1. Types of distribution of random variable:1. Pareto Distribution- It is constructed by specifying its expectation

and shape parameter β, the default values are 1.0 and 1.5 resp. set r1 [new RandomVariable/Pareto] $r1 set avg_ 10.0 $r1 set shape_ 1.2
2. Constant- A degenerated RV is the constant which equals to its value.

set r2 [new RandomVariable/Constant] $r2 set val_ 5.0
3. Uniform Distribution- It is defined through the smallest and largest

point in its support whixh is 0 and 1 by default. set r3 [new RandoVariable/Uniform] $r3 set min_ 0.0 $r3 set max_ 10.0

4. Exponential Distribution- It is defined through its average value.

set r4 [new RandomVariable/Exponential] $r4 set avg_ 5 5. Hyperexponential Distributionset r5 [new RandomVariable/HyperExponential] $r5 set avg_ 1.0 $r5 set cov_ 4.0 In addition to the basic class ErrorModel described above, there are several other types of error modules• • • • • • •

MrouteErrorModel: error model for multicast routing, now inherits from trace. ErrorModel/Periodic: models periodic packet drops (drop every nth packet we see). SelectErrorModel: for Selective packet drop. ErrorModel/TwoState: Two-State: error-free and error. ErrorModel/TwoStateMarkov, ErrorModel/Expo, ErrorModel/Empirical: inherit from ErrorModel/TwoState. ErrorModel/List: specify a list of packets/bytes to drop, which could be in any order. ErrorModel/Uniform: Uniform error model.

A predominant error model in literature is a two state continuous time Markovian chain. A B

As depicted, the “automaton” alternates between two states (A and B) which can have different dropping rates, possibly corresponding to “good” periods where the network does not corrupt packets, and “bad” periods when packets are dropped. The model uses the exponential distribution to determine the sojourn time in each state. In a given state we decide whether to drop, or not drop, an incoming packet according to, say, a random distribution. For example, if the specified drop rate for the B state is 10% then, while the automaton is in state B, an incoming packet is dropped according to a Bernoulli trial with probability 10%. This model is rate-based, because the decision of whether to drop a packet or not is predetermined according to a fixed rate. In other words, it does not matter when exactly a segment will actually arrive at the receiver: each and every segment

undergoes a Bernoulli trial at the specified drop probability. The same twostate model can also be configured as time-based. Here, instead of assigning a drop rate to each state, we designate one as a “good” state where no segments are dropped, and the other one as “bad” where all segments are dropped. The sojourn times in each state are still sampled from a random distribution. set $rvGood [new RandomVariable/Exponential] exponential random (for Markov model) $rvgood set avg_ xxx error-free parameter set $rvLoss [new RandomVariable/Exponential] $rvloss set avg_ xxx error parameter set em [new ErrorModel/TwoState] state Markov $em ranvar 0 $rvgood and assign $em ranvar 1 $rvloss parameters # xxx is the # xxx is the # Now create a 2 # error model # the # Create 2 variable

Similarly, a multi-state error model can be implemented. Transitions to the next error state occur at the end of the duration of the current state. The next error state is then selected using the transition state matrix. To create a multi-state error model, the following parameters should be supplied
• • • • • • •

states: an array of states (error models). periods: an array of state durations. trans: the transition state model matrix. transunit: one of [pkt|byte|time]. sttype: type of state transitions to use: either time or pkt. nstates: number of states. start: the start state.

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close