You are on page 1of 35

Gandhi Engineering College

Lab objectives

1. To identify and analyze various networking devices.


2. To discuss various categories of network and distinguish them in detail.
3. To understand the use of client/server architecture in application development
4. To get acquainted with unix system internals like Socket files, IPC structures.
5. To Design reliable servers using both TCP and UDP sockets

Lab outcomes

1. Students get a thorough understanding of various aspects of networking devices.


2. Students get the basics of IP addressing.
3. Students will be able to understand the basics of sliding window protocol.
4. Students get a thorough understanding of the routing protocols and implement them
successfully.
LIST OF EXPERIMENTS
SL.NO EXPERIMENT NAME

1. Study of different types of Network cables and Practically implement the cross-
wired cable and straight through cable using clamping tool.

2. Study of following Network Devices in Detail

3. Connect the computers in Local Area Network.

4. Write a program to generate CRC code for checking error

5. To Plot Efficiency of pure Aloha and slotted ALOHA in MATLAB

6. To implement client-server socket programming.

7. To determine the Host name and IP address of a system and implementation of


URL class.

8. To plot Channel Efficiency for Ethernet in MATLAB.

9. To write a C program to perform sliding window.

10. To simulate the OPEN SHORTEST PATH FIRST routing protocol based on
the cost assigned to the path.

EXPERIMENTS BEYOND THE SYLLABUS

1 Implementation of the Go Back N sliding window protocol

2 Implementation of the data link framing methods for the bit stuffing in a
frame.

3 To implement wired network topology and wireless network Topology in NS2.


PCCS7302COMPUTER NETWORK LAB (0-0-3)

1. Some Network protocol simulation using NetSim, NS2, etc. for

1. Analysing number of transmitting nodes vs. collision count, mean delay for
Ethernet LAN .
2. Analysing bus vs. star-switch with respect to number of collisions (for a fixed
number of transmitting nodes) for Ethernet LAN
3. Analysing performance of token ring with number of nodes vs. response time,
mean delay using NetSim.
4. Comparing the throughput and normalized throughput for token ring and token
bus for different transmitting nodes.
5. Comparing the CSMA/CD vs. CSMA/CA protocols (for a fixed number of
transmitting nodes).
6. Analysing the difference between unicast and broadcast transmission (for a fixed
number of transmitting nodes).
7. Verification of stop-and-wait protocol.
8. Verification of Go-back-N protocol.
9. Verification of Selective repeat protocol.
10. Verification of distance vector routing algorithm.
11. Verification of link state routing algorithm.

2. Some programming techniques in socket programming.


EXPERIMENT 1

Aim:
Study of different types of Network cables and Practically implement the cross-wired cable and
straight through cable using clamping tool.

Apparatus:
RJ-45 connector, Climping Tool, Twisted pair Cable
Procedure: To do these practical following steps should be done:

Procedure:

Start by stripping off about 2 inches of the plastic jacket off the end of the cable. Be very
careful at this point, as to not nick or cut into the wires, which are inside. Doing so could
alter the characteristics of your cable, or even worse render is useless. Check the wires,
one more time for nicks or cuts. If there are any, just whack the whole end off, and start
over.
Spread the wires apart, but be sure to hold onto the base of the jacket with your other
hand. You do not want the wires to become untwisted down inside the jacket. Category 5
cable must only have 1/2 of an inch of 'untwisted' wire at the end; otherwise it will be 'out
of spec'. At this point, you obviously have ALOT more than 1/2 of an inch of un-twisted
wire.
You have 2 end jacks, which must be installed on your cable. If you are using a pre-made
cable, with one of the ends whacked off, you only have one end to install - the crossed
over end. Below are specified the color combination for Straight cable and Cross over
cable which show how you need to arrange the cables for each type of cable end.

To make a straight cable, the tips must be crimped typically the same way at each end by
respecting the twisted pair size. In general, the code used is:

1. Orange-white
2. Orange
3. Green-white
4. Blue
5. Blue-white
6. Green
7. Brown-white
8. Brown

For a crossover cable, swap 1 with 3, and 2 with 6, in the list above. This gives:

1. Green-white
2. Green
3. Orange and white
4. Blue
5. Blue-white
6. Orange
7. Brown-white
8. Brown

Viva-voce questions:

1. Distinguish between Straight-wired cable and Cross-wired cable.


2. What are the various types of network cables.
3. What is RJ-45.
4. What is the advantage of using Twisted pair cable and what are its types.
5. Define Transmission media. What are the various transmission media.
EXPERIMENT 2

Aim: Study of following Network Devices in Detail


Repeater
Hub
Switch
Bridge
Router
GateWay

Apparatus:
Any simulator may be needed

Repeater:Functioning at Physical Layer.A repeater is an electronic device that


receives a signal and retransmits it at a higher level and/or higher power, or onto
the other side of an obstruction, so that the signal can cover longer distances.
Repeater have two ports ,so cannot be used to connect for more than two devices

Repeater

Fig.1 A Repeater

Hub: An Ethernet hub, active hub, network hub, repeater hub, hub or concentrator
is a device for connecting multiple twisted pair or fiber optic Ethernet devices
together and making them act as a single network segment. Hubs work at the
physical layer (layer 1) of the OSI model. The device is a form of multiport
repeater. Repeater hubs also participate in collision detection, forwarding a jam
signal to all ports if it detects a collision.
Fig.2 A Hub

Switch: A network switch or switching hub is a computer networking device that


connects network segments.The term commonly refers to a network bridge that
processes and routes data at the data link layer (layer 2) of the OSI model.
Switches that additionally process data at the network layer (layer 3 and above)
are often referred to as Layer 3 switches or multilayer switches.

Fig.3 A Switch

Bridge: A network bridge connects multiple network segments at the data link
layer(Layer 2) of the OSI model. In Ethernet networks, the term bridge formally
means a device that behaves according to the IEEE 802.1D standard. A bridge
and switch are very much alike; a switch being a bridge with numerous ports.
Switch or Layer 2 switch is often used interchangeably with bridge.Bridges can
analyze incoming data packets to determine if the bridge is able to send the given
packet to another segment of the network.
Fig.4 How a Bridge works

Router: A router is an electronic device that interconnects two or more computer


networks, and selectively interchanges packets of data between them. Each data
packet contains address information that a router can use to determine if the
source and destination are on the same network, or if the data packet must be
transferred from one network to another. Where multiple routers are used in a
large collection of interconnected networks, the routers exchange information
about target system addresses, so that each router can build up a table showing the
preferred paths between any two systems on the interconnected networks.

Fig.5 A Router
Gateway: A gateway is normally a computer that operates in all five layers of the
Internet or seven layers of OSI model. A gateway takes an application message,
reads it, and interprets it. This means that it can be used as a connecting device
between two internetworks that use different models. For example, a network
designed to use the OSI model can be connected to another network using the
Internet model. The gateway connecting the two systems can take a frame as it
arrives from the first system, move it up to the OSI application layer, and remove
the message.

Fig.6 A SNA Gateway

Viva-voce questions:

1. What are the various networking devices available.


2. In which layer of OSI model following devices are implemented:
a. Repeater
b. Bridge
c. Switch
d. Router
3. Why a repeater is used.
4. Distinguish between Bridge and Router.
5. What is the advantage of gateways in networking.
EXPERIMENT 3

Aim: Study of basic networking commands

Apparatus:
A system with Unix operating system.

Theory:
a. hostname
hostname with no options displays the machines host name
hostname d displays the domain name the machine belongs to
hostname f displays the fully qualified host and domain name
hostname i displays the IP address for the current machine

b. ping
It sends packets of information to the user-defined source. If the packets are received, the
destination device sends packets back. Ping can be used for two purposes:
1. To ensure that a network connection can be established.
2. Timing information as to the speed of the connection.
If you do ping www.yahoo.com it will display its IP address. Use ctrl+ to stop the test.

c. ifconfig
View network configuration, it displays the current network adapter configuration. It is
handy to determine if you are getting transmit (TX) or receive (RX) errors.

d. netstat
Most useful and very versatile for finding connection to and from the host. You can find
out all the multicast groups (network) subscribed by this host by issuing "netstat -g"
netstat -nap | grep port will display process id of application which is using that port
netstat -a or netstat all will display all connections including TCP and UDP
netstat --tcp or netstat t will display only TCP connection
netstat --udp or netstat u will display only UDP connection
netstat -g will display all multicast network subscribed by this host.

e. nslookup
If you know the IP address it will display hostname. To find all the IP addresses for a
given domain name, the command nslookup is used. You must have a connection to the
internet for this utility to be useful.
E.g. nslookup blogger.com
You can also use nslookup to convert hostname to IP Address and from IP Address from
hostname.
f. traceroute
A handy utility to view the number of hops and response time to get to a remote system
or web site is traceroute. Again you need an internet connection to make use of this tool.

g. finger
View user information, displays a users login name, real name, terminal name and write
status. this is pretty old unix command and rarely used now days.

h. telnet
Connects destination host via telnet protocol, if telnet connection establish on any port
means connectivity between two hosts is working fine.
EXPERIMENT 4

Aim:
Write a program to generate CRC code for checking error.

Apparatus:
Turbo C software

Cyclic Redundancy Check:


The cyclic redundancy check or CRC is a technique for detecting error in digital data but not for
making correction when errors are detected, it is used primarily in data transmissions. In the
CRC method a certain number of check bits, often called a checksum, are appended to the
message being transmitted. The receiver can determine whether or not the check bits agree with
the data, to ascertain with a certain degree of probability whether or not an error occurred in
transmission. If an error occurred, the receiver sends a negative acknowledgment (NAK) back
to the sender, requesting that message is to be retransmitted.

Fig. 7 CRC generator at sender site


Fig. 8 CRC generator at receiver site

Program:

#include <stdio.h>
#include <conio.h>
#include<string.h>
#define poly 0xd8 int crc(int msg)
{
int rem,i;
rem=msg;
for(i=8;i>0;--i)
{
if(rem & 0x80)
{ rem^=poly;
}
rem=rem<<1;
} return (rem>>4);
} void main()
{ int msg=0xe5,c;
clrscr();
c=crc(msg);
printf("%d",c);
getch();
}

Here the polynomial is 0xd8 means 11011000 and msg is 0xe5 means 11100101. So at last we
get as an answer means remainder
Viva-voce questions:

1. What is a cyclic code.


2. State the advantages of using CRC.
3. In CRC, show the relationship between the following entities (size means the number of
bits):
a. The size of the dataword and the size of the codeword
b. The size of the divisor and the remainder
4. Can CRC correct error. Justify your answer.
5. Why Checksum is used.
EXPERIMENT 5

Aim :
To Plot Efficiency of pure Aloha and slotted ALOHA in MATLAB

Apparatus:
MATLAB software

Procedure:
In pure ALOHA, frames are transmitted at completely arbitrary times.
Invalid frames may be caused by channel noise or because other station(s) transmitted at the
same time: collision. Collision happens even when the last bit of a frame overlaps with the first
bit of the next frame.
S = G e-2G, where S is the throughput (rate of successful transmissions) and G is the offered load.
S = Smax = 1/2e = 0.184 for G=0.5.
Pure ALOHA has a vulnerable time of 2 x Tfr . This is so because there is no rule that defines
when the station can send. A station may send soon after another station has started or soon
before another station has finished. Slotted ALOHA was invented to improve the efficiency of
pure ALOHA. In slotted ALOHA we divide the time into slots of Tfr s and force the station to
send only at the beginning of the time slot.Doubles performance of ALOHA. Frames can only be
transmitted at beginning of slot:
Vulnerable period is halved.
S = G e-G.
S = Smax = 1/e = 0.368 for G = 1.

Given below is the code:

G=0:0.1:3;
S=G.*exp(-G);
plot(G,S,'b+:');
text(1,.38,'MAX THROUGHPUT FOR SLOTTED ALOHA')
xlabel('load offered');
ylabel('throughput');
title('aloha protocol');
hold on;
S1=G.*exp(-2*G);
plot(G,S1,'rd:');
text(0.5,.2,'MAX THROUGHPUT FOR PURE ALOHA') xlabel ('load offered');
ylabel ('throughput');
title ('aloha protocol');
legend ('Slotted ALOHA','Pure ALOHA','Location','NorthEastOutside')
Result:

Fig. 9 Pure ALOHA VS Slotted ALOHA

Viva-voce questions:

1. What is ALOHA protocol.


2. Distinguish between pure ALOHA nad slotted ALOHA.
3. Define round-trip propagation delay.
4. Define Vulenerable time.
5. State the relation between Vulenerable time and Average frame transmission time for
ALOHA.
EXPERIMENT 6

Aim:
To implement client-server socket programming.

Apparatus:
JDK1.8

Socket Programming:

Fig.10 Socket Programming

Socket programming is performed for communication between the machines. Socket


programming can be connection-oriented or connectionless. Socket and Server Socket classes are
used for connection-oriented socket programming. The client in socket programming must know
two information:
1. IP address of Server, and
2. Port number.
Socket class:
A socket is simply an endpoint for communications between the machines. The Socket class
can be used to create a socket. Commonly used methods of Socket class:
1) public InputStream getInputStream()
2) public OutputStream getOutputStream()
3) public synchronized void close()

ServerSocket class:
The Server Socket class can be used to create a server socket. This object is used to establish
communication with the clients.
Commonly used methods of ServerSocket class:
1) public Socket accept()
2) public InputStream getInputStream()
3) public OutputStream getOutputStream()
4) public synchronized void close() Example of Socket Programming:

ALGORITHM: CLIENT
1. Include necessary package in java
2. The client establishes a connection to the server.
3. The client accept the connection and to send the data from client to server and vice
versa
4. The client communicate the server to send the end of the message
5. Stop the program.
ALGORITHM: SERVER
1. Include necessary package in java
2. The server establishes a connection to the client.
3. The server accept the connection and to send the data from server to client and vice
versa
4. The server communicate the client to send the end of the message
5. Stop the program.

//MyServer.java

import java.io.*;
import java.net.*;

public class MyServer {


public static void main(String[] args){
try{
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();//establishes connection

DataInputStream dis=new DataInputStream(s.getInputStream());

String str=(String)dis.readUTF();
System.out.println("message= "+str);

ss.close();

}catch(Exception e){System.out.println(e);}
}
}

//MyClient.java
import java.io.*;
import java.net.*;

public class MyClient {


public static void main(String[] args) {
try{
Socket s=new Socket("localhost",6666);

DataOutputStream dout=new DataOutputStream(s.getOutputStream());

dout.writeUTF("Hello Server");
dout.flush();

dout.close();
s.close();

}catch(Exception e){System.out.println(e);} } }

To execute this program open two command prompts and execute each program at each
command prompt as displayed in the below figure.

Viva-voce questions:

1. What is the function of Serversocket class.


2. Define a Socket.
3. What are the methods of Serversocket class.
4. What are the information that the client must know in socket programming.
5. Describe the Client-Server model.
EXPERIMENT 7

Aim:
To determine the Host name and IP address of a system and implementation of URL class.

Apparatus:
JDK1.8

InetAddress class:
The java.net.InetAddress class represents an IP address. The Inet Address class provides
methods to get the IP of any host name.

Commonly used methods of InetAddress class:


public static InetAddress getByName(String host) throws
UnknownHostException: it returns the IP of the given host.
public static InetAddress getLocalHost() throws UnknownHostException: it
returns the LocalHost IP and name.
public String getHostName(): it returns the host name of the IP address.
public String getHostAddress(): it returns the IP address in string format.

Example of InetAddress class:


//InetDemo.java

import java.io.*;
import java.net.*;
public class InetDemo{
public static void main(String[] args){
try{
InetAddress ip=InetAddress.getByName("www.gec.com");

System.out.println("Host Name: "+ip.getHostName());


System.out.println("IP Address: "+ip.getHostAddress());

}catch(Exception e){System.out.println(e);}
}
}

Output:

Host Name: www.gec.com


IP Address: 206.51.231.148
URL class:
The URL class represents a URL. URL is an acronym for Uniform Resource Locator. It points to
a resource on the World Wide Web. For example: http://www.gec.com/sushruta/index.jsp

A URL contains much information:

Protocol: In this case, http is the protocol.


Server name or IP Address: In this case, www.gec.com is the server name.
Port Number: It is an optional attribute.
File Name or directory name: In this case, index.jsp is the file name.

Commonly used methods of URL class:


public String getProtocol(): it returns the protocol of the URL.
public String getHost(): it returns the host name of the URL.
public String getPort(): it returns the Port Number of the URL.
public String getFile(): it returns the file name of the URL.

Example of URL class:

//URLDemo.java
import java.io.*;
import java.net.*;

public class URLDemo{


public static void main(String[] args){
try{
URL url=new URL("http://www.gec.com/kailash/index.jsp ");

System.out.print("Protocol: "+url.getProtocol());
System.out.print("Host Name: "+url.getHost());
System.out.print("Port Number: "+url.getPort());
System.out.print("File Name: "+url.getFile());

}catch(Exception e){System.out.println(e);}
}
}

Output:

Protocol: http
Host Name: www.gec.com
Port Number: -1
File Name: /sushruta/index.jsp

Viva-voce questions:
1. What is the role of InetAddress class.
2. Name any two methods available in InetAddress class.
3. What is IP address and what are its versions used in networking.
4. What is URL.
5. State the methods of URL class.
EXPERIMENT No: 8

Aim :
To plot Channel Efficiency for Ethernet in MATLAB.

Apparatus:
MATLAB software

Procedure:

Ethernet(pronounced "eether net") is a local area network, connecting computers together with
cables so the computers can share information. Within each main branch of the network,
Ethernet can connect up to 1,024 personal computers and workstations. Ethernet is a SHARED
MEDIUM network technology, where all the workstations are connected to the same cable and
must contend with one another to send signals over it. The algorithm used to resolve collisions -
that is, when two workstations try to speak at the same time - is called CSMA/CD, and works by
forcing both workstations to back off for random (and hence probably different) intervals before
trying again. The maximum data rate of the original Ethernet technology is 10 megabits per
second (Mbps), but a second generation FAST ETHERNET carries 100 Mbps, and the latest
version called GIGABIT ETHERNET works at 1000 Mbps. SWITCHED ETHERNET involves
adding switches so that each workstation can have its own dedicated 10 Mbps connection rather
than sharing the medium, which can improve network throughput - it has the advantage over
rival switched technologies such as ASYNCHRONOUS TRANSFER MODE that it employs the
same low-level protocols, cheap cabling and NETWORK INTERFACE CARDS as ordinary
Ethernet.

Given below is the code:

clc;
b=input('enter the b.w.');
l=input('enter the input length');
c=input('enter the input capacity');
k=1:256;
f1=64*8;
f2=128*8; f3=256*8;
p=((k-1)/k).^(k-1);
x=(2*b*l)./(c.*p);
a1=x./f1;
a2=x./f2;
a3=x./f3;
n1=1./(1+a1);
n2=1./(1+a2);
n3=1./(1+a3);
plot(k,n1,'rd:');
hold on;
plot(k,n2,'gp:');
hold on;
plot(k,n3,'bh:');
xlabel('no of attempts');
ylabel('efficiency');
title('channel efficiency');
legend('64*a','128*8','256*8','location','northeastoutside');

Result:

BW : 20000000
Enter the input length:2500
Enter the input capacity:1000000

Fig.11 Channel efficiency of Ethernet


Viva-voce questions:

1. What is the role of Ethernet.


2. What are the various categories of Ethernet.
3. Mention four important features of Ethernet.
4. What is the data rate of Giga Ethernet.
5. If an Ethernet destination address is 07:01:02:03:04:05, what is the type of the
address (unicast, multicast, or broadcast)
EXPERIMENT 9

Aim:
To write a C program to perform sliding window.

Apparatus:
Turbo C/C++ software

Theory:
the sliding window is an abstract concept that defines the range of sequence numbers that is the
concern of the sender and receiver. In other words,the sender and receiver need to deal with only
part of the possible sequence numbers. The range which is the concern of the sender is called the
send sliding window; the range that is the concern of the receiver is called the receive sliding
window. We discuss both here. The send window is an imaginary box covering the sequence
numbers of the data frames which can be in transit. In each window position, some of these
sequence numbers define the frames that have been sent; others define those that can be sent.
The maximum size of the window is 2m 1. The send window is an abstract concept defining an
imaginary box of size 2m ~ 1 with three variables: Sp Sm and Ssize. The send window can slide
one or more slots when a valid acknowledgment arrives. The receive window is an abstract
concept defining an imaginary box of size 1 with one single variable Rn The window slides
when a correct frame has arrived; sliding occurs one slot at a time.

Fig.12 Sliding window at receiver site


Fig.13 Sliding window at sender site

Algorithm:
1. Start the program.
2. Get the frame size from the user
3. To create the frame based on the user request.
4. To send frames to server from the client side.
5. If your frames reach the server it will send ACK signal to client otherwise it will send NACK
signal to client.
6. Stop the program

Result:
Thus the above program sliding window protocol was executed and successfully

Viva-voce:

1. Define Sliding window concept.


2. What is the size of send window and receive window.
3. What are the variables in send window and its functions.
4. Receive window slides only one slot at a time. Justify.
5. Name two protocols where sliding window concept is implemented.
EXPERIMENT 10

Aim:
To simulate the OPEN SHORTEST PATH FIRST routing protocol based on the cost assigned to
the path.

Apparatus:
Turbo C/C++ software

ALGORITHM:
1.Read the no. of nodes n
2.Read the cost matrix for the path from each node to another node.
3.Initialize SOURCE to 1 and include 1
4. Compute D of a node which is the distance from source to that corresponding
node.
5.Repeat step 6 to step 8 for n-l nodes.
6.Choose the node that has not been included whose distance is minimum
and include that node.
7.For every other node not included compare the distance directly from the
source with the distance to reach the node using the newly included node
8.Take the minimum value as the new distance.
9.Print all the nodes with shortest path cost from source node

Viva-voce questions:

1. What is the basic idea behnd OSPF protocol.


2. Why routers are used in OSPF protocol.
3. State various types of Routing protocols.
4. How OSPF implements a dynamic routing table.
5. Open Shortest Path First (OSPF) is an implementation of the link state protocol. Justify.
EXPERIMENTS BEYOND THE SYLLABUS

EXPERIMENT 1

Aim:
Implementation of the Go Back N sliding window protocol

Apparatus:
Turbo C software

Logic:
Two basic approaches are available foe dealing with errors in the presence of the pipelining. One
way, called go back n, is for the receiver simply to discard all subsequent frames, sending no
acknowledgements for the discarded frames. This strategy corresponds to a receive window of
size 1. In other words, the data link layer refuses to accept any frame except the next one it must
give to the network layer. If the senders window fills up before the timer runs out, the pipeline
will begin to empty. Eventually, the sender will time out and retransmit all unacknowledged
frames in order, starting with the damaged or lost one. This approach can waste a lot of
bandwidth if the error rate is high. We see go back n for the case in which the receivers window
is large. Frames 0 and 1 are correctly received and acknowledged. Frame 2 however, is damaged
or lost. The sender unaware of this problem, continues to send frames until the timer for frame 2
expires. Then it backs up frame 2 and starts all over with it, sending 2, 3, 4, etc all over again.

PseudoCode:

Void protocol5(void)
{
MAX3SEQ > 1; used for outbound stream oldest
frame as yet unacknowledged next frame expected
on inbound stream initialize scratch variable
buffers for the outbound stream

while(true)
{
four possibilities: see event_type above the
network layer has a packet to send fetch new
packet
expand the senders window
transmit the frame
advance senders upper window edge a data
or control frame has arrived
get incoming frame from physical layer
}
} /*end of protocol5*/

Input And Output:

Enter the no. of frames: 2


Enter the msg: ab
Transmission in one direction
M1=80
Error in transmission re-send all the frames
Enter the msg: df
Transmission in one direction
M1=86
Frame arrived
Acknowledgement to network layer
Transmission in opposite direction
M1=86
Enter thr msg: df
Transmission in one direction
M1=93
Frame arrived
Acknowledgement to network layer
Transmission in opposite direction
M1=93

Viva-voce questions:

1. What is the benefit of using Go-Back-N Automatic Repeat Request protocol.


2. Size of send window in Go-Back-N Automatic Repeat Request must be less than 2m.
Justify.
3. Differentiate between Go-Back-N ARQ and Stop-and- Wait ARQ.
4. Name one demerit of Go-Back-N ARQ protocol.
5. Why the name of this protocol is Go-Back-N ARQ.
EXPERIMENT 2

Aim:
Implementation of the data link framing methods for the bit stuffing in a frame.

Apparatus:
Turbo C/C++ software

LOGIC:
In a bit-oriented protocol, the data section of a frame is a sequence of bits to be interpreted by the
upper layer as text, graphic, audio, video, and so on. However, in addition to headers (and
possible trailers), we still need a delimiter to separate one frame from the other. Most protocols
use a special 8-bit pattern flag 01111110 as the delimiter to define the beginning and the end of
the frame. In bit-oriented protocols, we use bit stuffing; an extra 0 is added to the data section of
the frame when there is a sequence of bits with the same pattern as the flag. Stuffing a 0 bit in a
data frame in order to differentiate the header, trailer and data. if the flag pattern appears in the
data, we need to somehow inform the receiver that this is not the end of the frame. We do this by
stuffing 1 single bit (instead of I byte) to prevent the pattern from looking like a flag. The
strategy is called bit stuffing. In bit stuffing, if a 0 and five consecutive I bits are encountered, an
extra 0 is added. This extra stuffed bit is eventually removed from the data by the receiver. Note
that the extra bit is added after one 0 followed by five 1s regardless of the value of the next bit.
This guarantees that the flag field sequence does not inadvertently appear in the frame.

Fig.14 Bit stuffing

PSEUDO CODE:

/* For given data */


1. a flag 01111110 is embedded at the starting and the ending of the data. /*
stuffing of data */
2. if data bit is 1 increment count else count is zero.
3. If count is five store a zero bit after the five 1s in the data array.
4. Repeat step 3 till the end of data. /* De stuffing of data */
5. If the data bit is 1 increment count else count is zero.
6. If the count is five and the next bit is zero then store the next bit after zero in the
data array. /* transmit the data */
7. De stuffed data is transmitted with out flags.

At sender:

INPUT:

Enter the string


1111110101

OUTPUT:

Transmitted data is: 01111110111111010101111110 Stuffed data


is: 011111101111101010101111110

At Receiver:

OUTPUT:

De stuffed data is: 11111110101

Viva-voce questions:

1. Compare and contrast byte-oriented and bit-oriented protocols. Which category has been
popular in the past. Which category is popular now.
2. State the main logic in bit stuffing.
3. Define Framing.
4. Distinguish between Flow control and Error control.
5. Give one real life example where bit stuffing is used.
EXPERIMENT No: 3

Aim:
To implement wired network topology and wireless network Topology in NS2.

Apparatus:
NS2 simulator

NS2:
The Network Simulator version 2 (NS-2) is a deterministic discrete event network simulator,
initiated at the Lawrence Berkeley National Laboratory (LBNL) through the DARPA funded
Virtual Internetwork Test bed (VINT) project. NS-2 was initially created in 1989 as an
alternative to the REAL Network Simulator. Since then there is significant growth in uses and
width of NS project. Although there are several different network simulators available today, ns-
2 is one of the most common. NS-2 differs from most of the others by being open source
software, supplying the source code for free to anyone that wants it. Whereas most commercial
network simulators will offer support and a guarantee but keeping the moneymaking source code
for themselves.

FOR WIRED TOPOLOGY ALGORITHMS:


(1) Define new simulator.
(2) Create n numbers of nodes.
(3) Set the link between each of the nodes.
(4) Create agent
(5) Attach the agent
(6) Trace the protocols using CBR & FTP.
(7) Define a finish procedure to flush trace record in the trace and trace output files.
(8) Schedule events for simulation.
(9) Run the simulation.

FOR WIRELESS TOPOLOGY ALGORITHMS:


(1) Define new simulator.
(2) Define the network components. Such as the type of antenna, the radio- propagation
model, the type of ad-hoc routing protocol used by mobile node.
(3) Create n numbers of nodes.
(4) Set the link between each of the nodes
(5) Create agent.
(6) Attach the agent.
(7) Trace the protocols using application type.
(8) Define a finish procedure to flush trace record in the trace and trace output files.
(9) Schedule events for simulation.
(10) Run the simulation.
Viva-voce questions:

1. What is the advantage of wireless network over wired network.


2. Why and where NS2 is used.
3. What is an agent in NS2.
4. Name the programing language used in NS2 simulator.
5. Name any two simulators each for wireless network and wired network.

You might also like