ramrao adik institute of technology, nerul, navi...

46
Computer Networks Manual 1 Ramrao Adik Institute Of Technology, Nerul, Navi Mumbai 2014-20015 Subject: Computer Networks Semester: V Practical Lists 1) Study and implement Error detecting and error correcting codes (CRC, Hamming code, Checksum) 2) Installation and configuration of NS2 in Linux environment 3) To study and monitor traffic for the given topology in NS2 4) Write a Program to implement find out class of a given IP address, subnet mask and first& last IP address of that block 5) Implement Client-Server using network socket connection 6) Implement sliding window protocol using network sockets. 7) Implement Stop and Wait protocol using sockets. 8) Implement network layer services( (Shortest Path routing, DVR, LSR) 9) Implement LAN topology 10) Study of various network devices. 11) Study of network management tools 12) To study basics of shell commands in Unix / Linux

Upload: leque

Post on 10-Jun-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 1

Ramrao Adik Institute Of Technology, Nerul, Navi Mumbai2014-20015

Subject: Computer Networks

Semester: V

Practical Lists

1) Study and implement Error detecting and error correcting codes

(CRC, Hamming code, Checksum)

2) Installation and configuration of NS2 in Linux environment

3) To study and monitor traffic for the given topology in NS2

4) Write a Program to implement find out class of a given IP address,

subnet mask and first& last IP address of that block

5) Implement Client-Server using network socket connection

6) Implement sliding window protocol using network sockets.

7) Implement Stop and Wait protocol using sockets.

8) Implement network layer services( (Shortest Path routing, DVR,

LSR)

9) Implement LAN topology

10) Study of various network devices.

11) Study of network management tools

12) To study basics of shell commands in Unix / Linux

Page 2: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 2

1.Error Detection and Correction

AIM OF THE EXPERIMENT:-

To study and implement Error detecting and error correcting codes (CRC,Hamming code, Checksum)

THEORY:-

Error detection is the ability to detect the presence of errors caused by noise orother impairments during transmission from the transmitter to the receiver

Error correction is the additional ability to reconstruct the original, error-free data Error detection codes (which include all error-detection-and-correction codes)

transmit more bits than were in the original data. The receiver applies the samealgorithm to the received data bits and compares its output to the received checkbits; if the values do not match, an error has occurred at some point during thetransmission

A] CHECKSUM:

The goal of checksum algorithms is to detect accidental modification such as corruptionto stored data or errors in a communication channel

A checksum of a message is an arithmetic sum of message code words of a certain wordlength, for example byte values, and their carry value.

Parity bit:

A parity bit is a bit that is added to ensure that the number of bits with value of one in agiven set of bits is always even or odd Parity bits are used as the simplest error detectingcode

As for binary digits, there are two variants of parity bits: even parity bit and odd paritybit An even parity bit is set to 1 if the number of ones in a given set of bits is odd Anodd parity bit is set to 1 if the number of ones in a given set of bits is even (making thetotal number of ones, including the parity bit, odd) Parity bit is an error detecting code,but is not an error correcting code .

Example:

Transmission sent using even parity:

A wants to transmit: 1001A computes parity bit value: 1^0^0^1 = 0

Page 3: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 3A adds parity bit and sends: 10010B receives: 10010B computes parity: 1^0^0^1^0 = 0B reports correct transmission after observing expected even result

Transmission sent using odd parity:

A wants to transmit: 1001A computes parity bit value: ~(1^0^0^1) = 1A adds parity bit and sends: 10011B receives: 10011B computes overall parity: 1^0^0^1^1 = 1B reports correct transmission after observing expected odd result

Transmission sent using even parity:

A wants to transmit: 1001A computes parity bit value: 1^0^0^1 = 0A adds parity bit and sends: 10010*** TRANSMISSION ERROR ***B receives: 11010B computes overall parity: 1^1^0^1^0 = 1B reports incorrect transmission after observing unexpected odd result

B] CRC:

The CRC is a very powerful but easily implemented technique to obtain data reliability.Using this technique, the transmitter appends an extra n-bit sequence to every framecalled Frame check sequence (FCS). The FCS holds redundant information about theframe that helps the transmitter detect error in frame. The CRC is one of the most usedtechniques for error detection in data communication. Its popularity because it combinesthree advantages:

Extreme error detection capabilities. Little overhead.

Ease of implementation.

The following section will explain the CRC more.How the CRC algo worksGiven the original frame, the transmitter generates the FCS for that frame. The FCS isgenerated so that the resulting frame (the cascade of original frame and the FCS), isexactly devisable by some pre-defined polynomial. This pre-defined polynomial is calledthe devisor or CRC polynomial.For the formal explanation we will define the foll:M- The original frame to be transmitted, before adding the FCS. It is k-bits long.F-The resulting FCS to be added to M. It is n bits long.T-The cascading of M and F. This is the resulting frame that will be transmitted. It is k+nbits long.P- The pre-defined CRC Polynomial. A pattern of n+1 bits.CRC ExampleAssume that:M= 1010001101 (k=10) and’P=110101 (n+1=6)

Page 4: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 4

Then the FCS to be calculated by the transmitter will be n=5 bits in length. Let’s assumethat the transmitter has calculated the FCS to be:F=1110 (n=5)Then the transmitted frame will be:T=10100011011110The main idea behind the CRC algo is that the FCS is generated so that the remainder ofT\P is zero. It’s clear that

1) T=M*x^n+FThis is because by cascading F to M we have shifted T by n bits to the left and then addedF to the result. We want the transmitted frame, T, to be exactly divisible by the pre-defined polynomial P, so we would have to find a suitable frame check sequence(F) forevery raw message(M).Suppose we divided only M*x^n by P, we would get:

2) M*x^n/P= Q+R\P3) There is a quotient and a remainder. We will use this remainder, as our FCS (F).

Returning to Eq.1:4) T/P= (M*x^n+R)/p=M*x^n/P+R/P=Q+R/P+R/P=Q+(R+R)/P

But any binary number added to itself in a modulo 2 field yields zero so:5) T/P=Q, with no remainder.

CRC creation process:1. Get the raw frame.2. Left shift the raw frame by n bits and the divide it by P.3. The remainder of the last action is the FCS.4. Append the FCS to the raw frame. The result is the frame to transmit.

CRC check process:1. Receive the frame.2. Divide it by P.3. Check the remainder. If not zero then there is an error in the frame.

Sample Input: Input should be in polynomial form. Both generator polynomial and framepolynomial should be given.

Sample Output: The algorithm should generate the polynomial for the frame to betransmitted after CRC checksum has been added.

C] HAMMING CODE:

A Hamming code can detect up to two simultaneous bit errors, and correct single-biterrors; thus, reliable communication is possible when the Hamming distance between thetransmitted and received bit patterns is less than or equal to one By contrast, the simpleparity code cannot correct errors, and can only detect an odd number of errors

Page 5: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 5

General algorithm

Following general algorithm generates a single-error correcting (SEC) code for anynumber of bits

1. Number the bits starting from 1: bit 1, 2, 3, 4, 5, etc2. Write the bit numbers in binary 1, 10, 11, 100, 101, etc3. All bit positions that are powers of two (have only one 1 bit in the binary form of

their position) are parity bits4. All other bit positions, with two or more 1 bits in the binary form of their position,

are data bits5. Each data bit is included in a unique set of 2 or more parity bits, as determined by

the binary form of its bit position

This general rule can be shown visually:

Bit position 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20Encoded databits p1 p2 d1 p4 d2 d3 d4 p8 d5 d6 d7 d8 d9 d10 d11 p16 d12 d13 d14 d15

Paritybitcoverage

p1 X X X X X X X X X X

p2 X X X X X X X X X X

p4 X X X X X X X X X

p8 X X X X X X X X

p16 X X X X X

The pattern continues indefinitely

To check for errors, check all of the parity bits The pattern of errors, called the errorsyndrome, identifies the bit in error If all parity bits are correct, there is no errorOtherwise, the sum of the positions of the erroneous parity bits identifies the erroneousbit For example, if the parity bits in positions 1, 2 and 8 indicate an error, then bit1+2+8=11 is in error If only one parity bit indicates an error, the parity bit itself is inerror

REFFERENCE BOOK:-1. Computer Networks by Tannenbaum,2. Data Communication and Networking by B.Ferouzan.

REQUIREMENT:- TURBO C / TURBOC C++

Page 6: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 6

2.NS-2 Installation

AIM OF THE EXPERIMENT:-

Installation and configuration of NS2 in Linux environment

THEORY:-

What is ns-2?• ns-2 stands for Network Simulator version 2• ns-2 is a discrete event simulator for networking research• ns-2 works at packet level• ns-2 provides substantial support to simulate bunch of protocols like TCP, UDP, FTP,HTTP and DSR• Simulate wired and wireless network• Is primarily Unix based• Use TCL as its scripting language• ns-2 is a standard experiment environment in research community

Page 7: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 7

Why two language? (Tcl & C++)

Hello World – Example in TCL Scriptset ns [new Simulator]$ns at 1 “puts \“Hello World!\””$ns at 1 5 “exit”$ns run(Save the file as simple tcl in the bin directory of ns2 Then go to the bin directory of ns2from ns2 and give the following command to run the file )………> ns simple tclHello World! (This is output obtained)

Page 8: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 8

Basic ns-2• Create a new simulator object• [Turn on tracing]– [Open your own trace files]• Create network (physical layer)• Create link and queue (data-link layer)• Define routing protocol• Create transport connection (transport layer)• Create traffic (application layer)• Insert errors

Creating simulator instance• Create simulator instanceset ns [new Simulator]- Usually the first non-comment statement in ns-2 script- Initialize the packet format- Create a scheduler (default is a calendar scheduler)- Create a “null agent”

Turning on a tracefile• Open file for NS tracingset f [open out tr w]$ns trace-all $f• Open file for nam tracingset nf [open out nam w]$ns namtrace-all $nf• Open your own trace fileset my_f [open my_out tr w]puts $my_f “[$ns now] [expr $x(1) + $y(1)]”

Start/Stop ns• Schedule an event to start traffic at time 1 0$ns at 1 0 "$ftp0 start“• Schedule an event to stop ns at time 17 0$ns at 17 0 "$ftp0 stop“• Start ns$ns run- last statement• Stop nsexit 0

Visualization tool: nam• Replay events from a nam trace file• The nam trace file can be huge when simulation time is long or events happenintensively Be careful!• Run nam:– $nam –a nam_trace_file nam– In ns-2 script:Proc finish{} {

Page 9: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 9

……exec nam –a nam_trace_file nam &exit

The first Tcl script

Step 1: You need to create a simulator objectset ns [new Simulator]

Step 2: Open a file for writing that is going to be used for the nam trace dataset nf [open out nam w]$ns namtrace-all $nfThe first line opens the file 'out nam' for writing and gives it the file handle 'nf' Inthe second line we tell the simulator object that we created above to write allsimulation data that is going to be relevant for nam into this file

Step 3: Add a 'finish' procedure that closes the trace file and starts namproc finish {} {global ns nf$ns flush-traceclose $nfexec nam out nam &exit 0}

Step 4: Tell the simulator object to execute the 'finish' procedure after 5 0 seconds ofsimulation time

Page 10: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 10

$ns at 5 0 "finish"ns provides a very simple way to schedule events with the 'at' commandSave the file as “example1 tcl” and try to run it with 'ns example1 tcl' Note theerror

Step 5: Define the two nodes (Insert the code in this section before the line '$ns run', oreven better, before the line '$ns at 5 0 "finish")set n0 [$ns node]set n1 [$ns node]A new node object is created with the command '$ns node' The above codecreates two nodes and assigns them to the handles 'n0' and 'n1'

Step 6: Connect the two nodes$ns duplex-link $n0 $n1 1Mb 10ms DropTailThis line tells the simulator object to connect the nodes n0 and n1 with a duplexlink with the bandwidth 1Megabit, a delay of 10ms and a DropTail queue Nowyou can save your file and start the script with 'ns example1 tcl' nam will bestarted automatically and you should see an output that resembles the picturebelow

Step 7: Send some data from node n0 to node n1 In ns, data is always being sent fromone 'agent' to another So the next step is to create an agent object that sends datafrom node n0, and another agent object that receives the data on node n1#Create a UDP agent and attach it to node n0set udp0 [new Agent/UDP]$ns attach-agent $n0 $udp0#Create a Null agent which acts as traffic sink and attach it to node n1set null0 [new Agent/Null]$ns attach-agent $n1 $null0

Step 8: Attach a CBR traffic generatot to the UDP agent CBR stands for 'constant bitrate'# Create a CBR traffic source and attach it to udp0set cbr0 [new Application/Traffic/CBR]$cbr0 set packetSize_ 500$cbr0 set interval_ 0 005$cbr0 attach-agent $udp0The packetSize is being set to 500 bytes and a packet will be sent every 0 005seconds (i e 200 packets per second)

Step 9: Connect the two agents together$ns connect $udp0 $null0

Step 10: Tell the CBR agent when to send data and when to stop sending$ns at 0 5 "$cbr0 start"$ns at 4 5 "$cbr0 stop"Save the file and start the simulation again When you click on the 'play' button inthe nam window, you will see that after 0 5 simulation seconds, node 0 startssending data packets to node 1

Page 11: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 11

Q Create the following topology in ns2

Marking flowsAdd the following two lines to your CBR agent definitions$udp0 set class_ 1$udp1 set class_ 2Now add the following piece of code to your Tcl script, preferably at the beginning afterthe simulator object has been created, since this is a part of the simulator setup$ns color 1 Blue$ns color 2 Red

REFFERENCE BOOK:- NS-2 Manuals1) Marc Greis' Tutorial for the UCB/LBNL/VINT Network Simulator "ns"2) NS2 Simulator for beginners3) NS2 6 829 tutorial

REQUIREMENT:- NS-2

Page 12: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 12

3.Topology in NS-2

AIM OF THE EXPERIMENT:- To study basic wired and wireless topology inNS2

THEORY:-

Page 13: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 13

4.IP address, subnet mask

AIM OF THE EXPERIMENT:- Write a Program to implement find out class of agiven IP address, subnet mask and first& last IP address of that block

THEORY:-

What id IP address

An IP address is a number that represents a device like a network card uniquely on

the Internet or on your company's intranet. This number is actually a binary one, but for

convenience it's normally written as four decimal numbers. For instance, a typical IP

address would be something like 192.168.1.1. The four constituent numbers together

represent the network that the computer is on and the computer (interface) itself. Let us

first look at the network address part.

The IP addresses for networks on the Internet are allocated by the InterNIC. If you have

an Internet connection (a registered domain and a permanent link to the Internet, and not

just a dial-up connection), then you would be allocated a network address by the agency

that registered you, like the InterNIC. Let us assume this to be 192.6.132.0, a class C

network. Then all the machines on this network would have the same network address.

And the last 0 will be replaced by a number from 1 to 254 for the node address. So, nodes

will have addresses 192.6.132.1, 192.6.132.2, and so on up to 192.6.132.254.It would be

worth mentioning here that IP address calculations and concepts make sense only when

done in binary.

Page 14: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 14

Types of networks and corresponding IP address

Depending on the size of the network, IP-based networks are divided into five classes

Class1st OctetDecimalRange

1st OctetHigh

Order Bits

Network/Host ID(N=Network,

H=Host)

Default SubnetMask

Number ofNetworks

Hosts perNetwork (Usable

Addresses)

A 1 – 126* 0 N.H.H.H 255.0.0.0 126 (27 – 2)16,777,214 (224 –2)

B 128 – 191 10 N.N.H.H 255.255.0.016,382 (214 –2)

65,534 (216 – 2)

C 192 – 223 110 N.N.N.H 255.255.255.02,097,150(221 – 2)

254 (28 – 2)

D 224 – 239 1110 Reserved for Multicasting

E 240 – 254 1111 Experimental; used for research

Note: Class A addresses 127.0.0.0 to 127.255.255.255 cannot be used and is reserved for

loopback and diagnostic functions.

Subnet Mask

In an IP network, every machine on the same physical network sees all the data packets

sent out on the network. As the number of computers on a network grows, network traffic

will grow many folds, bringing down performance drastically. In such a situation, you

would divide your network into different sub networks and minimize the traffic across

the different subnet works. Interconnectivity between the different subnets would be

provided by routers, which will only transmit data meant for another subnet across itself.

To divide a given network address into two or more subnets, you use subnet masks. The

default subnet masks for class A networks is 255.0.0.0, for class B is 255.255.0.0, and for

class C is 255.255.255.0, which signify a network without subnet

The InterNIC has (RFC 1597 Address Allocation for Private Internets) allocated

particular blocks of network addresses for use in intranets. These IP addresses don't

conflict with those of existing Internet hosts and will not be handed out for use on the

Internet.

Page 15: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 15

Class Private Networks Subnet Mask Address Range

A 10.0.0.0 255.0.0.0 10.0.0.0 - 10.255.255.255

B 172.16.0.0 - 172.31.0.0 255.240.0.0 172.16.0.0 - 172.31.255.255

C 192.168.0.0 255.255.0.0 192.168.0.0 - 192.168.255.255

Dynamic IP Addressing and Static IP Addressing

In assigning IP addresses to machines, you have two choices. You can either go around

typing in the individual address on each machine or you can setup one machine to assign

IP addresses to the others. The second one called dynamic addressing is preferred for

three reasons. First, it makes the job of administering the network such as adding new

clients, avoiding IP clashes, etc a lot easier. And second, since only those machines that

are switched on will need an IP address, you could potentially have more machines on

your network with dynamic addressing, than you could with static addressing. Finally,

mobile computing has become an everyday reality, and notebook computers have a

likelihood of moving from one network to another or from one subnet to another. In such

a situation, if you have static IP addressing, you have to reconfigure the machine every

time you move it something that is eminently avoidable.

You do dynamic addressing with DHCP (Dynamic Host Configuration Protocol). To

make DHCP work on your network you have to set up a DHCP server.

Page 16: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 16

5.NETWORK SOCKET CONNECTION

AIM OF THE EXPERIMENT:-

implement using network socket connection

THEORY:-

Sockets are interfaces that can "plug into" each other over a network Once so "pluggedin", the programs so connected communicateNormally, a server runs on a specific computer and has a socket that is bound to aspecific port number The server just waits, listening to the socket for a client to make aconnection request

On the client-side: The client knows the hostname of the machine on which the server isrunning and the port number on which the server is listening To make a connectionrequest, the client tries to rendezvous with the server on the server's machine and portThe client also needs to identify itself to the server so it binds to a local port number thatit will use during this connection This is usually assigned by the system

If everything goes well, the server accepts the connection Upon acceptance, the servergets a new socket bound to the same local port and also has its remote endpoint set to theaddress and port of the client It needs a new socket so that it can continue to listen to theoriginal socket for connection requests while tending to the needs of the connected client

On the client side, if the connection is accepted, a socket is successfully created and theclient can use the socket to communicate with the server

The client and server can now communicate by writing to or reading from their sockets

Definition: A socket is one endpoint of a two-way communication link between twoprograms running on the network A socket is bound to a port number so that the TCPlayer can identify the application that data is destined to be sent

The java net package in the Java platform provides a class, Socket, that implements one sideof a two-way connection between your Java program and another program on the

Page 17: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 17

network The Socket class sits on top of a platform-dependent implementation, hiding thedetails of any particular system from your Java program By using the java net Socket classinstead of relying on native code, your Java programs can communicate over the networkin a platform-independent fashion

Additionally, java net includes the ServerSocket class, which implements a socket thatservers can use to listen for and accept connections to clients

1. Open a socket2. Open an input stream and output stream to the socket3. Read from and write to the stream according to the server's protocol4. Close the streams5. Close the socket

These lines establish the socket connection between the client and the server and open aPrintWriter and a BufferedReader on the socket:

echoSocket = new Socket("taranis", 7);out = new PrintWriter(echoSocket getOutputStream(), true);in = new BufferedReader(new InputStreamReader(

echoSocket getInputStream()));The first statement in this sequence creates a new Socket object and names it echoSocketThe Socket constructor used here requires the name of the machine and the port number towhich you want to connect The example program uses the host name taranis This is thename of a hypothetical machine on our local network When you type in and run thisprogram on your machine, change the host name to the name of a machine on yournetwork Make sure that the name you use is the fully qualified IP name of the machineto which you want to connect The second argument is the port number Port number 7 isthe port on which the Echo server listens

The second statement gets the socket's output stream and opens a PrintWriter on itSimilarly, the third statement gets the socket's input stream and opens a BufferedReader onit The example uses readers and writers so that it can write Unicode characters over thesocket

To send data through the socket to the server, EchoClient simply needs to write to thePrintWriter To get the server's response, EchoClient reads from the BufferedReader

REFFERENCE BOOK:- NS-2 Manuals1. Marc Greis' Tutorial for the Network Simulator "ns"2. NS2 Simulator for beginners3. NS2 6 829 tutorial

Books :1. Computer Networks by Tannenbaum,2. Data Communication and Networking by B.Ferouzan.

REQUIREMENT:- JAVA

Page 18: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 18

6. SLIDING WINDOW PROTOCOL

AIM OF THE EXPERIMENT:-

Implement basics of shell commands in Unix / Linux

THEORY:-

Go-Back-N Error Recovery

Go-Back-N ARQ (is one of a number of error recovery procedures to detect andretransmit I-frames which have been corrupted due to errors in the physical link

Features required for Go-Back-N ARQ

The time period is selected to ensure the same PDU number is never used againfor a different PDU, until the first PDU has "left the network”.

The local node must also keep a buffer of all PDUs which have been sent, buthave not yet been acknowledged.

The receiver at the remote node keeps a record of the highest numbered PDUwhich has been correctly received.

Recovery of lost PDUs using Go-Back-N.

The recovery of a corrupted PDU proceeds in three stages:

First, the corrupted PDU is discarded at the remote node's receiver. Second, the remote node requests retransmission of the missing PDU using a

control PDU (sometimes called a NACK or REJECT). The receiver discards allPDUs which do not have the number of the requested PDU.

The final stage consists of retransmission of the lost PDU(s).

A remote node may request retransmission of corrupted PDUs by initiating Go-Back-N error recovery by sending a control PDU indicating the last successfully receivedPDU. This allows the remote node to instruct the sending node where to beginretransmission of PDUs. The remote node does not store any out-of-sequence PDUsand therefore must discard all received PDUs until one is received with the expectedsequence number.

Page 19: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 19

Retransmission using Go-Back-N

Upon receipt of a Go-Back-N control PDU (by the local node), the transmitter winds-back the sequence of PDUs pending transmission to the indicated PDU in its buffer ofunacknowledged PDUs. The transmitter then retransmits (Goes Back-to-N) the requestedPDU followed by all successive PDUs. This is sometimes known as "wind back" of thetransmitter.

If the retransmission is not successful, the protocol relies upon a protocol timer in thelocal node to detect that no acknowledgment was received. The lost PDUs may then berecovered by Polling.

Selective Repeat Error Recovery

Selective Repeat error recovery is a procedure which is implemented in somecommunications protocols to provide reliability. It is the most complex of a set ofprocedures which may provide error recovery, it is however the most efficient scheme.Selective repeat is employed by the TCP transport protocol.

Page 20: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 20

Features required for Selective Repeat ARQ

The time period is selected to ensure the same PDU number is never used againfor a different PDU, until the first PDU has "left the network" .

The local node must also keep a buffer of all PDUs which have been sent, buthave not yet been acknowledged.

The receiver at the remote node keeps a record of the highest numbered PDUwhich has been correctly received. Recovery of lost PDUs using Selective RepeatARQ

The recovery of a corrupted PDU proceeds in four stages:

First, the corrupted PDU is discarded at the remote node's receiver. Second, the remote node requests retransmission of the missing PDU using a

control PDU (sometimes called a Selective Reject). The receiver then stores allout-of-sequence PDUs in the receive buffer until the requested PDU has beenretransmitted.

The sender receives the retransmission request and then transmits the lost PDU(s). The receiver forwards the retransmitted PDU, and all subsequent in-sequence

PDUs which are held in the receive buffer.

Retransmission using Selective Repeat

A remote node may request retransmission of corrupted PDUs by initiating SelectiveRepeat error recovery by sending a control PDU indicating the missing PDU. This allowsthe remote node to instruct the sending node where to retransmit the PDU which has notbeen received. The remote stores any out-of-sequence PDUs (i.e. which do not have theexpected sequence number) until the retransmission is complete.

Upon receipt of a Selective Repeat control PDU (by the local node), the transmitter sendsa single PDU from its buffer of unacknowledged PDUs. The transmitter then continuesnormal transmission of new PDUs until the PDUs are acknowledged or another selectiverepeat request is received.

Page 21: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 21

If the retransmission is not successful, the protocol relies upon a protocol timer in thelocal node to detect that no acknowledgment was received. The lost PDUs may then berecovered by Polling.

REFFERENCE BOOK:-

Books :1. Computer Networks by Tannenbaum,2. Data Communication and Networking by B.Ferouzan

REQUIREMENT:- JAVA

Page 22: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 22

7.Stop and Wait protocol using sockets

AIM OF THE EXPERIMENT:-

Implement stop and wait protocol using network sockets

THEORY:-

Stop and wait protocol

Stop and Wait transmission is the simplest reliability technique and is adequate for a verysimple communications protocol. A stop and wait protocol transmits a Protocol Data Unit(PDU) of information and then waits for a response. The receiver receives each PDU andsends an Acknowledgement (ACK) PDU if a data PDU is received correctly, and aNegative Acknowledgement (NACK) PDU if the data was not received. In practice, thereceiver may not be able to reliably identify whether a PDU has been received, and thetransmitter will usually also need to implement a timer to recover from the conditionwhere the receiver does not respond.

Stop and Wait ARQ - Waiting for Acknowledgment (ACK) from the remote node.

The blue arrows show the sequence of data PDUs being sent across the link from thesender (top to the receiver (bottom). A Stop and Wait protocol relies on two waytransmission (full duplex or half duplex) to allow the receiver at the remote node to returnPDUs acknowledging the successful transmission. The acknowledgements are shown ingreen in the diagram, and flow back to the original sender. A small processing delay maybe introduced between reception of the last byte of a Data PDU and generation of thecorresponding ACK.When PDUs are lost, the receiver will not normally be able toidentify the loss (most receivers will not receive anything, not even an indication that

Page 23: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 23

something has been corrupted). The transmitter must then rely upon a timer to detect thelack of a response.

Stop and Wait ARQ - Retransmission due to timer expiry

In the diagram, the second PDU of Data is corrupted during transmission. The receiverdiscards the corrupted data (by noting that it is followed by an invalid data checksum).The sender is unaware of this loss, but starts a timer after sending each PDU. Normallyan ACK PDU is received before this the timer expires. In this case no ACK is received,and the timer counts down to zero and triggers retransmission of the same PDU by thesender. The sender always starts a timer following transmission, but in the secondtransmission receives an ACK PDU before the timer expires, finally indicating that thedata has now been received by the remote node.

The state diagram (also showing the operation of NACK) is shown below:

State Diagram for a simple stop and wait protocol

(Green for ACK, Blue for Data, Red for NACK)

Page 24: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 24

8.Network Routing Protocols

AIM OF THE EXPERIMENT:-

Study and analysis of network routing protocols (Shortest Path routing - DVR,LSR)

THEORY:-

A] Distance Vector Routing

A distance-vector routing protocol is one of the two major classes of routing protocolsused in packet-switched networks for computer communications, the other major classbeing the link-state protocol A distance-vector routing protocol uses the Bellman-Fordalgorithm to calculate paths

Examples of distance-vector routing protocols include RIPv1 and 2 and IGRP

A distance-vector routing protocol requires that a router informs its neighbors of topologychanges periodically and, in some cases, when a change is detected in the topology of anetwork Compared to link-state protocols, which require a router to inform all the nodesin a network of topology changes, distance-vector routing protocols have lesscomputational complexity and message overhead

In this network we have 4 routers A, B, C, and D:

3

A

D

C

B

232

5

Page 25: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 25

We shall mark the current time (or iteration) in the algorithm with T, and shall begin (attime 0, or T=0) by creating distance matrices for each router to its immediate neighborsAs we build the routing tables below, the shortest path is highlighted with the colorgreen, a new shortest path is highlighted with the color yellow

T=0

fromA

viaA

viaB

viaC

viaD

to Ato B 3

to C 23

to D

fromB

viaA

viaB

viaC

viaD

to A 3

to Bto C 2

to D

fromC

viaA

viaB

viaC

viaD

to A 23

to B 2

to Cto D 5

fromD

viaA

viaB

viaC

viaD

to Ato Bto C 5

to D

At this point, all the routers (A,B,C,D) have new "shortest-paths" for their DV (the list ofdistances that are from them to another router via a neighbor) They each broadcast this newDV to all their neighbors: A to B and C, B to C and A, C to A, B, and D, and D to C Aseach of these neighbors receives this information, they now recalculate the shortest pathusing it

For example: A receives a DV from C that tells A there is a path via C to D, with a distance(or cost) of 5 Since the current "shortest-path" to C is 23, then A knows it has a path to Dthat costs 23+5=28 As there are no other shorter paths that A knows about, it puts this as itscurrent estimate for the shortest-path from itself (A) to D, via C

T=1

fromA

viaA

viaB

viaC

viaD

to Ato B 3 25

to C 5 23

to D 28

fromB

viaA

viaB

viaC

viaD

to A 3 25

to Bto C 26 2

to D 7

fromC

viaA

viaB

viaC

viaD

to A 23 5

to B 26 2

to Cto D 5

fromD

viaA

viaB

viaC

viaD

to A 28

to B 7

to C 5

to D

Again, all the routers have gained in the last iteration (at T=1) new "shortest-paths", so theyall broadcast their DVs to their neighbors; This prompts each neighbor to re-calculate theirshortest distances again

For instance: A receives a DV from B that tells A there is a path via B to D, with a distance(or cost) of 7 Since the current "shortest-path" to B is 3, then A knows it has a path to Dthat costs 7+3=10 This path to D of length 10 (via B) is shorter than the existing "shortest-path" to D of length 28 (via C), so it becomes the new "shortest-path" to D

T=2

fromA

viaA

viaB

viaC

viaD

to Ato B 3 25

to C 5 23

fromB

viaA

viaB

viaC

viaD

to A 3 7

to Bto C 8 2

fromC

viaA

viaB

viaC

viaD

to A 23 5 33

to B 26 2 12

to C

fromD

viaA

viaB

viaC

viaD

to A 10

to B 7

to C 5

Page 26: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 26

to D 10 28 to D 31 7 to D 51 9 5 to D

This time, only routers A and D have new shortest-paths for their DVs So they broadcasttheir new DVs to their neighbors: A broadcasts to B and C, and D broadcasts to C Thiscauses each of the neighbors receiving the new DVs to re-calculate their shortest pathsHowever, since the information from the DVs doesn't yield any shorter paths than theyalready have in their routing tables, then there are no changes to the routing tables

T=3

fromA

viaA

viaB

viaC

viaD

to Ato B 3 25

to C 5 23

to D 10 28

fromB

viaA

viaB

viaC

viaD

to A 3 7

to Bto C 8 2

to D 13 7

fromC

viaA

viaB

viaC

viaD

to A 23 5 15

to B 26 2 12

to Cto D 33 9 5

fromD

viaA

viaB

viaC

viaD

to A 10

to B 7

to C 5

to D

None of the routers have any new shortest-paths to broadcast Therefore, none of the routersreceive any new information that might change their routing tables So the algorithm comesto a stop

In NS2 use the following command

Now make following topology and pass the traffic from n0 to n2 Disconnect the linkbetween n1 and n2 and run the example

To use dynamic routing to solve the link failure problem add the following line at thebeginning of your Tcl script, after the simulator object has been created

$ns rtproto DV

Start the simulation again, and you will see how at first a lot of small packets run throughthe network If you slow nam down enough to click on one of them, you will see that theyare 'rtProtoDV' packets which are being used to exchange routing information betweenthe nodes When the link goes down, again the routing will be updated and the traffic willbe re-routed through the nodes 6, 5 and 4

Page 27: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 27

B] Link State Routing

A link-state routing protocol is one of the two main classes of routing protocols used inpacket switching networks for computer communications Examples of link-state routingprotocols include OSPF and IS-IS

Steps:

Determining the neighbors of each node

First, each node needs to determine what other ports it is connected to, over fully-working links; it does this using a simple reachability protocol which it runs separatelywith each of its directly-connected neighbors

Distributing the information for the map

Next, each node periodically and in case of connectivity changes makes up a shortmessage, the link-state advertisement, which:

Identifies the node which is producing it Identifies all the other nodes to which it is directly connected Includes a sequence number, which increases every time the source node makes

up a new version of the message

Creating the map

Finally, with the complete set of link-state advertisements (one from each node in thenetwork) in hand, it is obviously easy to produce the graph for the map of the network

The algorithm simply iterates over the collection of link-state advertisements; for eachone, it makes links on the map of the network, from the node which sent that message, toall the nodes which that message indicates are neighbors of the sending node

No link is considered to have been correctly reported unless the two ends agree; i e if onenode reports that it is connected to another, but the other node does not report that it isconnected to the first, there is a problem, and the link is not included on the map

Notes about this stage

The link-state message giving information about the neighbors is recomputed, and thenflooded throughout the network, whenever there is a change in the connectivity betweenthe node and its neighbors, e g when a link fails Any such change will be detected bythe reachability protocol which each node runs with its neighbors

Calculating the routing table

Page 28: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 28

As initially mentioned, the second main stage in the link-state algorithm is to producerouting tables, by inspecting the maps This is again done with several steps

Calculating the shortest paths

Each node independently runs an algorithm over the map to determine the shortest pathfrom itself to every other node in the network; generally some variant of Dijkstra'salgorithm is used

Filling the routing table

With the shortest paths in hand, filling in the routing table is trivial

For any given destination node, the best next hop for that destination is the node which isthe first step from the root node, down the branch in the shortest-path tree which leadstoward the desired destination node

To create the routing table, it is only necessary to walk the tree, remembering the identityof the node at the head of each branch, and filling in the routing table entry for each nodeone comes across with that identity

Optimizations to the algorithm

The algorithm described above was made as simple as possible, to aid in ease ofunderstanding In practice, there are a number of optimizations which are used

Most importantly, whenever a change in the connectivity map happens, it is necessary torecompute the shortest-path tree, and then recreate the routing table Also, the routingtable would normally be filled in as the shortest-path tree is computed, instead of makingit a separate operation

Failure modes

If all the nodes are not working from exactly the same map, routing loops can form(These are situations in which, in the simplest form, two neighboring nodes each thinkthe other is the best next hop to a given destination Any packet headed to that destinationarriving at either node will loop between the two, hence the name Routing loopsinvolving more than two nodes are also possible )

REFFERENCE BOOK:- NS-2 Manuals1. Marc Greis' Tutorial for the Network Simulator "ns"2. NS2 Simulator for beginners3. NS2 6 829 tutorial

Books:1. Computer Networks by Tannenbaum,2. Data Communication and Networking by B.Ferouzan.

REQUIREMENT:- NS-2

Page 29: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 29

9.Local Area Network

AIM OF THE EXPERIMENT:-

Implement LAN topology

THEORY:-

LANs can be organized into various different structures. The key thing is that there arephysical and logical topologies. The physical topology is how wires are organized. Thelogical topology is how the network behaves logically.

1.1 Addressing

To support several transfer modes, there are several different addressing schemes.• Unicast: Addressing is one-to-one, where one computer sends a frame to anothercomputer. Even though many stations can receive the same data, they should ignore itsince it is no addressed to them.•Multicast: Addressing is one-to-many, where one computer is sending a frame to manyother computers. This can be done via a list of addresses, or some masking scheme thatselects a subset of addresses.•Broadcasting: Addressing is one-to-all, where one computer sends data to all computersconnected to the LAN.

1.2 Broadband vs. Baseband

Transmission on LANs can use either the whole bandwidth capacity of the medium, orsplit itinto channels. Baseband is when the whole capacity of the medium is used, whileBroadbandis when the medium capacity is split into channels.

Baseband is generally used for digital transmissions, while Broadband is generally usedfor analog transmissions.

1.2 Physical Topologies

There are three primary physical topologies: Bus, Ring, and Star.

Page 30: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 30

1.3 Bus

The bus topology is basically a wire that all devices connect to using a passiveinterface (they listen, but don’t amplify/repeat). There are terminators on both ends of thewire to remove the frame.

Since all computers are connected to the medium, they all get all the frames sent. Theterminators are responsible for the removal of the frame.

In baseband setup, each computer sends frames in all (both, as there are 2) directions.In broadband setup, the transmission is unidirectional (but then it can use a separatechannel for transmissions in the opposite direction).The bus topology generally uses coaxial cable.

Bus Topology

Characteristics of Bus topology:• Failure of the medium disrupts communication.• Failure of devices doesn’t affect the communication (passive interface).• There is a limit on the length of the network (devices don’t amplify/repeat the signal).• The propagation delay isn’t affected by the number of devices.

1.5 Ring

Ring topology is somewhat different from the bus topology. The major differences are:• There is no need for terminators (the receiving or sending stations remove the frame).• Devices are active: they receive a message and then they retransmit it.• All transmissions are baseband, and go in a single direction.

The connected devices can be in several modes, the bypass mode, and operationalmode.

In bypass mode, the device is not connected to the medium. In operational mode, thedevice can be either listening or transmitting.

Page 31: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 31

Ring Topology1.5.1 Removing Frames

The major issue in ring topology is who gets to remove the frame. If the frame isremoved by the destination, then we can only have unicast transmissions (one-to-one). Ifthe source removes the frame (after the frame has gone around the ring), then we canhave unicast, multicast, and broadcasting capability.

Characteristics of Ring topology:• Failure of the medium seriously disrupts communication.• Malfunctioning of the interface can seriously effect communication (devices are active).• There is no limitation on the length of the network (devices repeat/retransmit theFrame).• Propagation speed is affected by the number of stations (because each station readsand retransmits the frame).• The network can use any medium, like twisted pair, coax, or fiber.

1.6 Star

In a star topology, each station is connected to a central node, or hub (or switch). Eachstation only talks to the central node.

Each station generally has two connections to the hub; one to send data to the hub, andanother to get data from the hub. Thus, each connection is unidirectional.

The Star topology can use either broadband or baseband transmissions. Baseband isused for guided media (like wire), while broadband is used for unguided (wireless).

The central hub can be either active or passive. A passive hub just links all workstationstogether (without retransmitting). An active hub reads and then retransmits the frame toall workstations.

Normally, the hub retransmits data to all the connected stations. If a switch is used, itcan learn to only send data to the destination station. It does that by first operating like aregular hub, and then observing and recording which addresses appear on whichinterfaces.

If the star uses a hub, then addressing works just like in the bus network. If the star usesa switch, then the destination is determined by the switch (as in, unicast works just asexpected, while broadcasting and multicasting has to be supported by the switch).

Page 32: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 32

Star Topology

Characteristics of Star topology:• Failure of the medium does not seriously disrupt communication.• Malfunctioning of the station doesn’t seriously affect the communication.• The network can use guided or unguided media.• Failure of the hub disrupts the communication.

Page 33: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 33

10.Network Devices

AIM OF THE EXPERIMENT:-

Study of various network devices.

THEORY:-

Various devices are used to connect network of a computer

The most common devices are:

1. Routers2. Gateways3. Repeaters4. Bridges5. Hub6. Modem

ROUTER

Routers are devices which connect two are more networks that use similar protocol. Arouter consists of hard ware and software.

Hard ware can be a computer is specific device.

Software consists of special management program that controls flow of data betweennetworks.

Routers operate at a network layer of O.S.I model.

Routers use logical and physical address to connect two or more logically separatenetwork. They make this connection by organizing the large network into logical networksegment (some times small sub network or sub nets). Each of these sub nets is given alogical address. Data is grouped into packets or block of data.

Each packet in addition to having a physical device address has a logical address. Thenetwork address allows routers to calculate more accurately and efficiently the path of thecomputer.

Advantages of Router

They use high level of intelligence to rout data

Routers can also act as a bridge to handle non rout able protocols such as NetBEUI(Network Bios Extended User Interface)

Page 34: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 34

Disadvantages of Router:

High level of intelligence take more processing time which can effectperformance

Routers are very complicated which installation and maintenance difficult.

GATEWAYS

Gateways are devices which connect two are more networks that use differentprotocols. They are similar in function to routes but they are more powerful andintelligent devices. A gateway can actually convert data so that network with anapplication on a computers on the other side of the gateway e.g a get way can receiveemail messages in one format in convert them into another format. Gateway can operateat all seven layer of OSI model. Since Gateway perform data conversion so they areslower in speed and very expensive devices.

REPEATERS

Repeaters are used within network to extend the length of communication.Data process through transmission media in the farm of waves or signals. The

transmission media weaken signals that move through it. The weakening of signal iscalled attenuation. If the data is to be transmitted beyond the maximum length of acommunication media, signals have amplified. The devices that are used to amplify thesignals are called repeaters. Repeaters work at the physical layer of OSI model.

Repeaters are normally two ports boxes that connect two segments. As a signal comesin one port , it is Regenerated and send out to the other port.

The signal is read as 1s and 0s. As 1s and 0s are transmitted, the noise can be cleanedout.Advantages of Reapeater

Repeaters easily extend the length of network.

They require no processing over head, so very little if any performancedegradation occurs.

It can connect signals from the same network type that use different types ofcables.

Disadvantages of Repeaters Repeaters can not be used to connect segments of different network types.

They cannot be used to segment traffic on a network to reduce congestion .

Many types of network have a limit on the number of network s that can be usedat once .

Page 35: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 35

BRIDGES

Bridges are used to connect similar network segments.

A bridge does not pass or signals it receives. When a bridge receive a signal , itdetermines its destination by looking at its destination and it sends the signals towards it.For example in a above figure a bridge has been used to join two network segments AAND B.

When the bridge receives the signals it read address of both sender and receiver. If thesender is a computer in segment A and the receiver is also segment A, it would not passthe signals to the segments B. It will however pass signals if the sender is in one segmentand the receiver in other segment. Bridge works at the data link layer of O.S.I model.

Advantages of Bridges

Bridge extends network segments by connecting them together to make onelogical network.

They can affect the segment traffic between networks by filtering data if it doesnot need to pass.

Like repeaters they can connect similar network types with different cabling.

Disadvantages of Bridges

Bridge possess information about the data they receive with can slowperformance.

HUB

Hubs are basically multi ports repeaters for U.T.P cables. Some hubs have ports for othertype of cable such as coaxial cable. Hubs range in size from four ports up to and forspecific to the network types. These are some hubs which are

1. Passive Hub2. Active Hub3. Switch/ Intelligent Hub

Passive Hub

It provides no signal regeneration. They are simply cables connected together so that thesignal is broken out to other nodes with out regeneration. These are not used often todaybecause of loss of cable length that is allowed.

Active Hub

It acts as repeaters and regenerates the data signals to all ports. They have no realintelligence to tell whether the signal needs to go to all ports that is blindly repeated.

Switch Hub

Page 36: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 36

Switches are multi ports bridges. They filter traffic between the ports on the switch byusing the address of computers transmitting to them.

Switches can be used when data performance is needed or when collision need to bereduce.

Advantages of Hub

Hubs need almost no configuration. Active hub can extend maximum network media distance.

No processing is done at the hub to slow down performance

Disadvantages of Hub

Passive hubs can greatly limit maximum media distance. Hubs have no intelligence to filter traffic so all data is send out on all ports

whether it is need or not.

Since hubs can act as repeaters the network using them must follow the same rules asrepeaters

MODEM

The device that converts digital signals into analog signals and analog signals to digitalsignals is called Modem. The word modem stands for modulation and demodulation. Theprocess of converting digital signals to analog signals is called modulation. The processof converting analog signals to digital signals is called demodulation. Modems are usedwith computers to transfer data from one computer to another computer throughtelephone lines.

Modems have two connections these are.

Analog connection Digital connection

Analog connection.

The connection between the modem and the telephone line is called analog connection.

Types of Modem

THERE ARE TWO TYPES OF MODEMS

Internal modem External modem

Page 37: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 37

Digital connection.

The connection of modem to computer is called digital connection

INTERNAL MODEM

It fits into expansion slots inside the computer. It is directly linked to the telephone linesthrough the telephone jack. It is normally less inexpensive than external modem. Itstransmission speed is also less external modem.

EXTERNAL MODEM

It is the external unit of computer and is connected to the computer through serial port. Itis also linked to the telephone line through a telephone jack. External modems areexpensive and have more operation features and high transmission speed.

Advantages of Modem

i. Inexpensive hardware and telephone lines.

ii. Easy to setup and maintain.

Disadvantages of Modem

i. Very slow performance.

Page 38: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 38

11.Network Tools

AIM OF THE EXPERIMENT:-

Study of network management tools

THEORY:-

Page 39: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 39

12.Shell commands

AIM OF THE EXPERIMENT:-

To study basics of shell commands in Unix / Linux

THEORY:-

Basic Commands

1.ls -l for listing the files as well as directories those are kept in the particular workingdirectory

syntax

[root@nettech root]#ls -l

2.ls -la same as 'ls -l'but by this command we can also see the hiden files.

syntax

[root@nettech root]#ls -la

3.ls -li same as 'ls -la' but it will also shows us the inode number of each and every file

syntax

[root@nettech root]#ls -li

4.ls by this command we can see only file name nothing else syntax

[root@nettech root]#ls

5.clear it will clear the screen(short cut ctl+l)

syntax

Page 40: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 40

[root@nettech root]#clear

6.exit to end a current session as well current terminal logging syntax

[root@nettech root]exit

7.touchto create a new empty file syntax

[root@nettech root]#touch

8.cd to change the working/present directory syntax

[root@nettech root]#cd /home/mango

where '/home/mango' is the desired directory to be change from

'/root'

9.cat to view the contents of a file and it is also used for creating a new file with somecontents

syntax

[root@nettech root]#cat <file name> to view file contents

[root@nettech root]#cat > newfilename enter,then you can write something in thefile and then to save the file contents press clt+d then enter

10.mkdir to make a new directory syntax

[root@nettech root]#mkdir newdirname

you can also create a directory at your desired path without changing your presentworking directory

syntax

[root@nettech root]#mkdir /home/mango/newdirname

Page 41: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 41

11.rm to remove a empty file syntax

[root@nettech root]#rm filename

12.rmdir to remove a empty directory syntax

[root@nettech root]#rmdir directoryname

13.rm [-i/-r/-f] to remove a directory with its subdirectories as well as its files that is toremove a directory which already contains some files in it syntax

[root@nettech root]#rm -i directory/filename

-i stands for interactively

-r stands for recursively

-f stands for forcefully

14.cp to copy something in a destination file or directory syntax

[root@nettech root]#cp sourcepath destinationpath

example: [root@nettech root]#cp /home/mango/webmin.rpm /root/abcd

in this example the webmin.rpm file will be copied in

/root/abcd directory

15.mv to move one file or directory from one place to another place, it is also used forrenaming adirectory or file

syntax

[root@nettech root]#mv source destination

[root@nettech root]#mv oldfilename newfilename [to change the file name]

Page 42: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 42

16.manto view the mannual page of commands for syntax syntax

[root@nettech root]#man commandname

17.info to view the information about any command syntax

[root@nettech root]#mkdir info

18.--help to view the help doccuments of a command syntax

[root@nettech root]#commandname --help

19.dir to view the subdirectories and filesn under the directory syntax

[root@nettech root]#dir

20.su - to become a super user syntax

[mango@nettech mango]$su - output wil be

[root@nettech root#]

21.whoby this command you can see the user name and their ip addresses who haveloged in on your server

syntax

[root@nettech root]#who

22.whoami this command shows your current logged in terminal user name syntax

[root@nettech root]#whoami

Page 43: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 43

23.who am i this command shows you the logged in terminal number and user nameand more detailed information

syntax

[root@nettech root]#who am i

24.pwdto view the present working directory syntax

[root@nettech root]#pwd

25.rpm -ivh to intall a rpm package syntax

[root@nettech root]#rpm -ivh packagename.rpm

rpm stands for 'redhat package manager'

-i stands for install

-v stands for verbose mode

-h stands for with hash sign(#)

26.rpm -q to querry about any rpm package syntax

[root@nettech root]#rpm -q packagename

27.rpm -e to uninstall a rpm package synatx

[root@nettech root]#rpm -e package

28.find / -name to find any file or directory in linux file system syntax

[root@nettech root]#find / -name filename

Page 44: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 44

29.su username to switch from one user to another users home directory syntax

[root@nettech root]#su mango output will be

[mango@nettech root]#cd

[mango@nettech mango]#

30.su - username to switch from one user to another user users home directorydirectly

syntax

[root@nettech root]#su - mango

31.useradd to create a new user synatx

[root@nettech root]#useradd username

32.passwd to give a password of a user syntax

[root@nettech root]#passwd tarun output will be

give a password for user tarun:(here you have to type a password for tarun user)

confirm password:(again type the same password)

33.userdel to remove a user from linux syntax

[root@nettech root]#userdel tarun

34.groupadd to add a new group syntax

[root@nettech root]#groupadd groupname

Page 45: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 45

35.gruopdel to delete a group syntax

[root@nettech root]#groupdel groupname

36.chown to change the ownership of a file or directory syntax

[root@nettech root]#chown ownername filename example:

[root@nettech /]#ls -l output

drwxrw-rw- 2 root root 4096 Mar 11 12:03 abcd

(permission) (own) (group own)(size) (name)

[root@nettech root]#chown tarun /abcd

in this example /abcd directory owner will be change to tarun user effect

[root@nettech /]#ls -l

drwxrw-rw- 2 tarun root 4096 Mar 11 12:03 abcd

37.chgrp to change the group ownership of a file or directory syntax

[root@nettec root]#chgrp newgroupownername filename example

[root@nettech /]#ls -l

drwxrw-rw- 2 tarun root 4096 Mar 11 12:03 abcd

[root@nettech root]#chgrp tarun /abcd effect

[root@nettech /]#ls -l

drwxrw-rw- 2 tarun tarun 4096 Mar 11 12:03 abcd

Page 46: Ramrao Adik Institute Of Technology, Nerul, Navi Mumbaicebdiv.weebly.com/uploads/3/8/1/6/38163583/cn_lab_manual.pdf · 2015-08-23 · Computer Networks Manual 3 A adds parity bit

Computer Networks Manual 46

38.chmod to change the permission of a file or directory drwxrw-rw- 2 rootroot 4096 Mar 11 12:03 abcd

(permission) (ownr) (grpownr) (size) (name) IN OCTAL VALUE

d stands for directiry READ=4

r stands for read only permission WRITE=2

w stands for write only permission EXECUTE=1 x stands for executeonly permission

drwxrw-rw- FIRST OCTET FOR DENOTING THE DIRECTORY OR FILE ORLINK FILE ETC.

SECOND THREE OCTET FOR USER OR OWNER PERMISSION (rwx OR 7 IN

OCTAL VALUE)

SYNTAX

THIRD THREE OCTET FOR GROUP PERMISSION (rw- OR 6 IN OCTAL VALUE)FORTH THREE OCTET FOR OTHERS PERMISSION (rw- OR 6 IN OCTAL VALUE)

[root@nettec root]#chmod value fileordirectoryname example

[root@nettech /]#ls -l

drwxrw-rw- 2 tarun root 4096 Mar 11 12:03 abcd

[root@nettech /]#chmod 402 /abcd

[root@nettech /]#ls -l

drw-----w- 2 tarun tarun 4096 Mar 11 12:03 abcd

40.usermod to modify the user profile

synatx

[root@nettech root]#usermod -parameter groupname username