You are on page 1of 4

Even Semester 2011-2012 COMPUTER NETWORKS LAB CI671

Lab Assignment 7
The objective of this lab is to know about Local Area Networks 10 marks

1. Introduction
The objective of local area networks is to share resources that are either costly or that are not monopolized by a single user. Local area network simplifies message exchanges, sharing of files and distributed computing. Four main topologies of LANs exist: The star The mesh The ring The bus In a star topology, terminals are connected to a central hub through point-to-point links. This allows to control in a centralized way conflicts and allows handling easily broadcast. The drawback is the reliability of its operation that is limited due to the dependence on the central hub. Furthermore, the capacity of the central hub limits the number of stations that can be connected. The meshed topology allows for several possible routes between two users. An example is the telephone system. The ring network consists of repeaters linked through point-to-point unidirectional links so as to form a closed loop. Examples are the IBM token ring, IEEE 802.5 and the FDDI. It is simple, and allows transmitting on one link while receiving from the other. In order to avoid collisions only one station can transmit at a time, which means inefficient use of resources. The bus topology consists of a single segment of cable to which stations are connected; the connection is of the multipoint type; all the stations connected to the bus hear the signal, and if two stations transmit at the same time there is a collision. Examples are the token bus (IEEE 802.4) and the Ethernet (IEEE 802.3, IEEE 802.9, IEEE 802.12 and

IEEE 802.14). The bus itself is passive which results in a limited range. In order to extend the range one needs to use repeaters which can connect several buses to a cable. In topologies that are other than star, distributed MAC protocols to the channel need to be implemented. The access protocols are divided into three categories: static sharing, random access, and access by demand. In random access protocols, access is attempted at random which may cause collisions and a need of retransmissions. Examples are the Aloha used in satellite communications and the Ethernet. In order to reduce collisions, one can first listen if there is no other signal being transmitted on the channel, and if there is, transmission is delayed. This is called Carrier Sense Multiple Access (CSMA). One can avoid transmission a long tram if during the transmission, a collision is detected. This is called Collision Detection (CD). This version of CSMA is denoted as CSMA/CD and CSMA is implemented in ns. The Ethernet A MAC protocol based on CSMA/CD is the Ethernet, and various versions of it are standardized, e.g. IEEE 802.3 (10Mbps), IEEE 802.9 (multimedia), IEEE 802.11 (wireless Ethernet), IEEE 802.12 (AnyLAN) and IEEE 802.14 (high speed). The Ethernet includes backoff algorithms for the retransmissions. The IEEE 802.3 is implemented in ns. The collision window is bounded by 51.2 sec and the LAN is limited to 5km. It has several versions, e.g. 10base5, 10base2, 10broad36 and others. The silence period between transmitted frames in 10base5 is of 9.6sec. When using a faster Ethernet, this silence time as well as the maximum propagation time reduces, and so does the maximum physical range of the network.

2. Simulating LANs with ns


The ns simulates three levels related to a LAN: link layer protocols such as the ARQ, the MAC protocol and the physical channel. The basic way to define a LAN through which a group of nodes is connected is by the command
set lan [$ns newLan <arguments>]

There are seven arguments: 1. A group of nodes 2. The delay 3. The bandwidth 4. The link layer type 5. The interference queue type 6. The MAC type 7. The channel type

3. Tcl Script
set ns [new Simulator] #Define different colors for data flows (for NAM) $ns color 1 Blue $ns color 2 Red #Open the Trace files set file1 [open out.tr w]

set winfile [open WinFile w] $ns trace-all $file1 #Open the NAM trace file set file2 [open out.nam w] $ns namtrace-all $file2 #Define a 'finish' procedure proc finish {} { global ns file1 file2 $ns flush-trace close $file1 close $file2 exec nam out.nam & exit 0 } #Create six nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] $n1 color red $n1 shape box #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns simplex-link $n2 $n3 0.3Mb 100ms DropTail $ns simplex-link $n3 $n2 0.3Mb 100ms DropTail set lan [$ns newLan MAC/Csma/Cd Channel] "$n3 $n4 $n5" 0.5Mb 40ms LL Queue/DropTail

# $ns duplex-link $n3 $n4 0.5Mb 40ms DropTail # $ns duplex-link $n3 $n5 0.5Mb 30ms DropTail #Set Queue Size of link (n2-n3) to 10 # $ns queue-limit $n2 $n3 20 #Setup a TCP connection set tcp [new Agent/TCP/Newreno] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink/DelAck] $ns attach-agent $n4 $sink $ns connect $tcp $sink $tcp set fid_ 1 $tcp set window_ 8000 $tcp set packetSize_ 552 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP

#Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n5 $null $ns connect $udp $null $udp set fid_ 2 #Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 0.01mb $cbr set random_ false $ns $ns $ns $ns at at at at 0.1 "$cbr start" 1.0 "$ftp start" 124.0 "$ftp stop" 124.5 "$cbr stop"

# next procedure gets two arguments: the name of the # tcp source node, will be called here "tcp", # and the name of output file. proc plotWindow {tcpSource file} { global ns set time 0.1 set now [$ns now] set cwnd [$tcpSource set cwnd_] set wnd [$tcpSource set window_] puts $file "$now $cwnd" $ns at [expr $now+$time] "plotWindow $tcpSource $file" } $ns at 0.1 "plotWindow $tcp $winfile" $ns at 5 "$ns trace-annotate \"packet drop\"" $ns at 125.0 "finish" $ns run

Exercise
1. Run the tcl script given above for MAC CSMA/CD channel and note down the impact on TCP traffic destined for nodes in the LAN. Analyze and state your results. 2. Modify the above script for IEEE 802.3 specifications. Note down the behavior of network traffic. Analyze and state your findings.

You might also like