Professional Documents
Culture Documents
Networks
5 Design LAN/Ethernet
Command Description
indent filename To indent files containing C programs.
gcc abc.c ‐o abc Compile the file abc.c and create the executable abc.out.
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.
Command Description
ls Lists files and directories.
ls -l Lists files in ‘long format’ i.e containing useful info. About file
such as who owns it, exact size of file.
ls -a Lists all files and directories.
ls abc* Lists all files and directories starting with abc.
mv f1 f2 Moves a file i.e gives it a different name or moves it into a
different directory
cp f1 f2 Copy file1 to file2.
rm f1 Removes a file.
rm -i Ask for a confirmation before deleting anything.
wc f1 Gives no of lines, words and characters in a file.
cat f1 To view a file.
cat > f1 To create a file.
cat f1 f2 > f3 Concatenates file1 and file2 to file3.
gzip f1 Produces a compressed a file with .gz extension.
gunzip f1 Decompress a file compressed with gzip.
lpr Prints a file.
grep string f1 Prints all lines of file that contain the string.
grep-v string Prints all lines of the file except those that contain the string.
f1
tar To combine multiple files into a single file.
-vf f.tar f1 f2
Tar-xvf f.tar To separate an archive created by tar into separate files.
Code :
Creation :- gedit ashish.c
#include<stdio.h>
int main()
{
int num,i,Pro=1;
for(i=1;i<=num;i++)
{
Pro=Pro*i;
}
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.
6 1
8
1 10Mb, 10ms 20Mb, 5ms
10Mb, 10ms
25Mb, 15ms
3 40Mb, 15ms 4 7
15Mb, 5ms
0.5Mb, 15ms
5Mb, 5ms
5
2 9
1
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]
Output :-
Result :-
Given network of nodes & links is designed using network
simulator.
Experiment -3
Theory :-
• 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.
• 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.
Network :-
5
4 1
10Mb, 40ms 10Mb, 40ms
1 8
10Mb, 40ms
10Mb, 40ms
3 10Mb, 40ms 7
10Mb, 40ms 10Mb, 40ms
2 9
10Mb, 40ms 10Mb, 40ms
1
6
0
Code :
proc finish {} {
global ns nf
$ns flush-trace
exec nam out.nam &
exit 0
}
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).
0 1 5 8
3 1
9
2
6
1
4
0
Code :-
Output :-
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.
Code :-
create-god $val(nn)
Output :-
Figure 5.2: Ad hoc network of three wireless mobile nodes.
Result :-
Ad hoc network of three wireless mobile nodes is successfully
designed & 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:
For UDP :-
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
}
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
}
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 lan [$ns newLan "$n9 $n10 $n11 $n12" 50Mb 20ms LL Queue/DropTail
MAC/Csma/Cd Channel]
proc finish { } {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit0
}
$ns at 0.0 "$ftp start"
$ns at 400.0 "$ftp stop"
$ns at 500.0 "finish"
$ns run
Fig. LAN
Output :-
Result :-
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 :-
# defining nodes
set n0 [$ns node]
set n1 [$ns node]
#scheduling
$ns at 1.0 "$ftp start"
$ns at 100.0 "$ftp stop"
OUTPUT
TCP: TAHOE
4
10
3
10
No. of packets received
2
10
1
10
0
10
-2 -1 0 1 2
10 10 10 10 10
error %
LEARNING OUTCOMES
Theory : -
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 re-
ordered 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.
Code :-
# defining nodes
set n0 [$ns node]
set n1 [$ns node]
#scheduling
$ns at 1.0 "$ftp start"
$ns at 100.0 "$ftp stop"
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 ErrorModel class is derived from the Connector base class. As the result,
it inherits some methods for hooking up objects such as target and drop-
target. 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.
5. Hyperexponential Distribution-
In addition to the basic class ErrorModel described above, there are several
other types of error modules-
A B
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.