50% found this document useful (2 votes)
3K views49 pages

CN Lab Manual ECE 6th Sem

The document is a lab manual for a Computer Networks lab course. It provides an overview of the course details like contact hours, evaluation scheme, and objectives. It describes 12 experiments to be performed using the NCTuns network simulation tool and C programming. The experiments include simulating computer networks of varying topologies, implementing protocols like TCP, UDP, analyzing network performance by varying parameters, and implementing networking algorithms. The manual provides the necessary theory and instructions to complete each experiment.

Uploaded by

sachin ninganur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
3K views49 pages

CN Lab Manual ECE 6th Sem

The document is a lab manual for a Computer Networks lab course. It provides an overview of the course details like contact hours, evaluation scheme, and objectives. It describes 12 experiments to be performed using the NCTuns network simulation tool and C programming. The experiments include simulating computer networks of varying topologies, implementing protocols like TCP, UDP, analyzing network performance by varying parameters, and implementing networking algorithms. The manual provides the necessary theory and instructions to complete each experiment.

Uploaded by

sachin ninganur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Lab Manual - Semester – 6th Sem

Department of Electronics & Communication Engineering, Hirasugar Institute of


Technology, Nidasoshi-591236

Overview

Year / Semester 3rd Year Academic Year 2017 - 2018


Laboratory Title Computer Networks Lab Laboratory Code 15ECL68
Total Contact Hours 40 Hours Duration of SEE 3 Hours
IA Marks 20 Marks SEE Marks 80 Marks
Lab Manual Author Prof. Nyamatulla M Patel Sign - Date

Objectives
1. To plan the laboratory activities as to complete the experiments on time.
2. To write & complete the records at the end of each experiment.
3. To prepare the laboratory manual.

Description

1.0 Learning Objectives


1. NCTUns network simulator to simulate computer networks for the number of packets sent successfully,
number of packets dropped due to congestion, analyze network throughput, analyze network traffic, to
calculate bit error rate, to identify reasons for collision across different nodes.

2. NCTUns network simulator to simulate Wi-Fi networks.


3. Use CRC-CCITT (16-bits) to detect errors in data transmitted across the network.
4. How to control congestion in the network using Leaky Bucket algorithm.
5. Use Algorithms to find suitable path for data transmission.

2.0 Course Learning Outcomes


On the completion of this laboratory course, the students will be able to:
1. Use NCTUns network simulator for learning and practice for networking algorithms.
2. Illustrate the operations of network protocols and algorithms using C programming.
3. Simulate the network with different configurations to measure the performance parameters.
4. Implement the data link and routing protocols using C programming.

Prerequisites
The Lab requires the student to have the following prerequisites:
1. Student should have the basic knowledge of 'C' programming language.
2. Student should have the basic knowledge of Computer Networks algorithms like error detection and
correction, security, congestion control and routing algorithms.
3. Student should have the basic knowledge of networking protocols like TCP/IP, UDP, FTP and TELNET.
4. The student should have knowledge of client server programming using sockets and FIFO IPC channels.

Base Course

Page 1
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1. Networks Laboratory

Introduction
 A computer network, or simply a network, is a collection of computers and other hardware components
interconnected by communication channels that allow sharing of resources and information.
 Where at least one process in one device is able to send/receive data to/from at least one process residing in a
remote device, then the two devices are said to be in a network.
 Simply, more than one computer interconnected through a communication medium for information
interchange is called a computer network.
 Communications protocols define the rules and data formats for exchanging information in a computer
network, and provide the basis for network programming.
 In this course we will study simulation of networking protocols such as TCP, UDP, FTP, TELNET,
ETHERNET etc.
 We will study implementation of networking algorithms such as error detection and correction, routing, etc in
'C' programming.

Resources Required
The lab should have:
1. Intel based PC
2. GCC compiler
3. NCTUns simulation tool
4. Word processor

General Instructions
1. Student should be punctual to the Lab.
2. Required to prepare the Lab report every week.
3. Required to maintain the Lab record properly.
4. Should use the resources properly.

Page 2
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Contents

Expt. No. Experiments Date Planned Date Conducted


PART-A (Implement Using NCTuns Simulation Tool)
Implement a point to point network with four
nodes and duplex links between them.
1
Analyze the network performance by setting
the queue size and varying the bandwidth.
Implement a four node point to point network
with links n0-n2, n1-n2 and n2-n3. Apply TCP
agent between n0-n3 and UDP between n1-n3.
2 Apply relevant applications over TCP and
UDP agents changing the parameter and
determine the number of packets sent by
TCP/UDP.
Implement Ethernet LAN using n (6-10)
3 nodes. Compare the throughput by changing
the error rate and data rate.
Implement Ethernet LAN using n nodes and
assign multiple traffics to the nodes and obtain
4
congestion window for different sources/
destinations.
Implement ESS with transmission nodes in
5 Wireless LAN and obtain the performance
parameters.
Implementation of Link state routing
6
algorithm.
PART-B (Implement the following in C/C++)
Write a program for a HLDC frame to perform
the following.
7
i) Bit stuffing
ii) Character stuffing.
Write a program for distance vector algorithm
8
to find suitable path for transmission.
Implement Dijkstra’s algorithm to compute
9
the shortest routing path.
For the given data, use CRC-CCITT
polynomial to obtain CRC code. Verify the
10 program for the cases
a. Without error
b. With error
Implementation of Stop and Wait Protocol and
11
Sliding Window Protocol.
Write a program for congestion control using
12
leaky bucket algorithm.

Page 3
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Evaluation Scheme
1. Lab activity – Continues evaluation for each experiment – 10 Marks.
2. Internal exam at the end of semester – 10 Marks.
3. Sem End Exam – 80 Marks.

Reference
1. Communication Networks – Fundamental Concepts and Key architectures – Alberto Leon-Garcia and
Indra Widjaja:, 2nd Edition, Tata McGraw-Hill, 2004.
2. Computer Networks A Systems Approach – Larry L. Peterson and Bruce S. David – 4 th Edition, Elsevier,
2007.
3. Data and Computer Communication, William Stallings, 8th Edition, Pearson Education, 2007.

Experiments
Page 4
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.0 Experiment

Experiment No Date Planed Date Conducted Marks


01

TITLE:
Implement a point to point network with four nodes and duplex links between them. Analyze the network
performance by setting the queue size and varying the bandwidth.

1.1 Learning Objectives

 To make student comfortable in using NCTUns tool.


 Simulate point to point network.

1.2 Aim

 To compare the throughput by varying bandwidth.


 To find the number of packets dropped.

1.3 Material / Equipment Required

 Intel based PC.


 NCTUns tool
 Word processor

1.4 Theory / Hypothesis

The Point-to-Point Protocol (PPP) originally emerged as an encapsulation protocol for transporting IP traffic over point-
to-point links. PPP also established a standard for the assignment and management of IP address, asynchronous
(start/stop) and bit-oriented synchronous encapsulation, network protocol multiplexing, link configuration, link quality
testing, error detection, and option negotiation for such capabilities as network layer address negotiation and data-
compression negotiation. PPP supports these functions by providing an extensible Link Control Protocol (LCP) and a
family of Network Control Protocols (NCPs) to negotiate optional configuration parameters and facilities. In addition to
IP, PPP supports other protocols, including Novell's Internetwork Packet Exchange (IPX) and DECnet. PPP provides a
method for transmitting datagrams over serial point-to-point links. PPP contains three main components:
1. A method for encapsulating datagrams over serial links. PPP uses the High-Level Data Link Control (HDLC)
protocol as a basis for encapsulating datagrams over point-to-point links.
2. An extensible LCP to establish, configure, and test the data link connection.
3. A family of NCPs for establishing and configuring different network layer protocols. PPP is designed to allow
the simultaneous use of multiple network layer protocols.
To establish communications over a point-to-point link, the originating PPP first sends LCP frames to configure and
(optionally) test the data link. After the link has been established and optional facilities have been negotiated as needed
by the LCP, the originating PPP sends NCP frames to choose and configure one or more network layer protocols. When
each of the chosen network layer protocols has been configured, packets from each network layer protocol can be sent

Page 5
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

over the link. The link will remain configured for communications until explicit LCP or NCP frames close the link, or
until some external event occurs (for example, an inactivity timer expires or a user intervenes).

1.5 Procedure / Program / Activity

Step1: Drawing topology


1. Select/click the HOST icon on the tool bar and click the left mouse button on the editor, to place a HOST1
(Sender) on the editor. Repeat the above procedure and place another host HOST2 (Receiver) on the editor.
2. Select/click the HUB icon on the tool bar and click the left mouse button on the editor, to place HUB1 on the
editor.
3. Click on the LINK icon on the tool bar and connect HOST1 to SWITCH1 and SWITCH1 to HOST2
4. Click on the “E” icon on the tool bar to save the current topology e.g: file1.tpl (Look for the ******.tpl
extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
2. Select Add button on the HOST window to invoke the command window and provide the following command
in the command text box.
stg –u 1024 100 1.0.1.2 for UDP
or
stcp -p 7000 -l 1024 1.0.1.2 for TCP (Here 1.0.1.2 is receivers ip address)
3. Click OK button on the command window to exit and once again click on the OK button on the HOST window
to exit.
4. Double click the left mouse button while cursor is on HOST2 to open the HOST window.
5. Select Add button on the HOST window to invoke the command window and provide the following command
in the command text box.
rtg –u –w log1 for UDP
or
rtcp -p 7000 -l 1024 for TCP
6. Click OK button on the command window to exit.
7. Click NODE EDITOR Button on the HOST window and select the MAC tab from the modal window that
pops up.
8. Select LOG STATISTICS and select check boxes for Number of Drop Packet and Number of Collisions in the
MAC window
9. Click OK button on the MAC window to exit and once again click on the OK button on the HOST window to
exit.
10. Repeat the same process for HOST2 (Sender) and HOST3(Receiver).
Note: To set QUEUE size
1. Double click the left mouse button while cursor is on HOST2 to open the HOST window.
2. Click NODE EDITOR Button on the HOST window and select the FIFO tab from the modal window that pops
up.
3. Change Queue size (Default 50).
4. Click OK button on the FIFO window to exit and once again click on the OK button on the HOST window to
exit.

Step3: Simulate
1. Click “R” icon on the tool bar
2. Select Simulation in the menu bar and click/ select RUN in the drop down list to execute the simulation.
3. To start playback select “►” icon located at the bottom right corner of the editor.
4. To view results, Open Output throughput, Input Throughput and Drop log files from file1.results folder in
separate word processor.

Page 6
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Caution: file1 is the hypothetical name given to this simulation.

Changing configurations
Change 1
1. Open the above file,
2. Do not change the topology or any other configuration,
3. Select E icon on the tool bar
4. Reduce the bandwidth at link by double clicking the left mouse button
5. Repeat Step3 (Simulate)
Change 2
1. Open the above file,
2. Do not change the topology or any other configuration,
3. Select E icon on the tool bar
4. Change BER at receiver link.
5. Repeat Step3 (Simulate)
Change 3
1. Open the above file,
2. Remove HUB and replace it with HUB
3. Do not change anything in the configuration
4. Repeat Step3(Simulate)

1.6 Block / Circuit / Model / Reaction Diagram

1.7 Results & Analysis

Page 7
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

UDP Connection Using Switch


With Bandwidth 10 MBPS and BER 0.000000000

No. of Packets
Time
N1_Output Throughput N2_Input Throughput N2_Drop
1 1182.414 1185.624 0
2 1188.770 1188.770 0
3 1189.840 1190.910 0
4 1189.840 1189.840 0
5 1180.770 1191.980 0

TCP Connection
With Bandwidth 10 MBPS and BER 0.000000000

No. of Packets
Time
N1_Output Throughput N2_Input Throughput N2_Drop
1 1188.364 1189.882 0
2 1188.594 1190.112 0
3 1190.112 1188.594 0
4 1188.594 1190.112 0
5 1190.112 1188.594 0

With Bandwidth 10 MBPS and BER 0.000000500

No. of Packets
Time
N1_Output Throughput N2_Input Throughput N2_Drop
1 1185.328 1189.882 1
2 1190.112 1188.594 0
3 1187.076 1188.594 1
4 1190.112 1191.630 0
5 1190.112 1190.112 0

1.8 Outcome & Conclusion

Page 8
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.9 Remarks

FACULTY SIGNATURE

1.0 Experiment

Experiment No Date Planed Date Conducted Marks


02

TITLE:

Page 9
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Simulate a four node point-to-point network with the links connected as follows: n0–n2, n1–n2 and n2–n3. Apply TCP
agent between n0-n3 and UDP between n1-n3. Apply relevant applications over TCP and UDP agents changing the
parameter and determine the number of packets sent by TCP / UDP.

1.1 Learning Objectives

To understand the difference between TCP and UDP protocols.

1.2 Aim

 Simulation of TCP and UDP protocols using NCTUns


 Compare throughput of TCP and UDP protocols

1.3 Material / Equipment Required

 Intel based PC.


 NCTUns tool
 Word processor

1.4 Theory / Hypothesis

The Transmission Control Protocol (TCP) is one of the core protocols of the Internet protocol suite TCP is one of the
two original components of the suite, complementing the Internet protocol (IP), and therefore the entire suite is
commonly referred to as TCP/IP. TCP provides reliable, ordered delivery of a stream of octets from a program on one
computer to another program on another computer. TCP is the protocol used by major Internet applications such as the
world wide web, email and file transfer. Other applications, which do not require reliable data stream service, may use
the User datagram Protocol (UDP), which provides a Datagram service that emphasizes reduced latency over reliability.

The User Datagram Protocol (UDP) is one of the core members of the Internet protocol suite, the
set of network protocols used for the Internet. With UDP, computer applications can send messages,
in this case referred to as datagrams, to other hosts on an Internet protocol(IP) network without
requiring prior communications to set up special transmission channels or data paths. UDP uses a
simple transmission model with a minimum of protocol mechanism. It has no handshaking
dialogues, and thus exposes any unreliability of the underlying network protocol to the user's
program. As this is normally IP over unreliable media, there is no guarantee of delivery, ordering or
duplicate protection. UDP provides check sum for data integrity, and port numbers for addressing
different functions at the source and destination of the datagram. UDP is suitable for purposes
where error checking and correction is either not necessary or performed in the application,
avoiding the overhead of such processing at the network interface level. Time-sensitive applications
often use UDP because dropping packets is preferable to waiting for delayed packets, which may
not be an option in a real-time system. If error correction facilities are needed at the network
interface level, an application may use the TCP which are designed for this purpose.
1.5 Procedure / Program / Activity

Page 10
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Step1: Drawing topology


1. Select/click the HOST icon on the tool bar and click the left mouse button on the editor, to place a host on the
editor. Repeat the above procedure and place two other hosts “HOST2” and “HOST3” on the editor.
2. Select/click the HUB (or SWITCH) icon on the tool bar and click the left mouse button on the editor, to place
a HUB (or SWITCH) on the editor.
3. Click on the LINK icon on the tool bar and connect HOST1 to HUB, HOST2 to HUB and HUB to HOST3
4. Click on the “E” icon on the tool bar to save the current topology e.g: file2.tpl (Look for the ******.tpl
extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
2. Select Add button on the HOST window to invoke the command window and provide the following command
in the command text box.
stcp –p 7000 –l 1024 1.0.1.3 (for TCP start time 0.0 and end time 20.0)
3. Click OK button on the command window to exit
4. Click NODE EDITOR Button on the HOST window and select the MAC tab from the modal window that
pops up.
5. Select LOG STATISTICS and select check box for output throughput in the MAC window
6. Click OK button on the MAC window to exit and once again click on the OK button on the HOST window to
exit.
7. Double click the left mouse button while cursor is on HOST2 to open the HOST window.
8. Select Add button on the HOST window to invoke the command window and provide the following command
in the command text box.
stg –u 1024 100 1.0.1.3 (for UDP start time 21.0 and end time 40.0)
9. Click OK button on the command window to exit
10. Click NODE EDITOR Button on the HOST window and select the MAC tab from the modal window that
pops up.
11. Select LOG STATISTICS and select check box for output throughput in the MAC window
12. Click OK button on the MAC window to exit and once again click on the OK button on the HOST window to
exit.
13. Double click the left mouse button while cursor is on HOST3 to open the HOST window.
14. Select Add button on the HOST window to invoke the command window and provide the following command
in the command text box.
rtcp –p 7000 –l 1024 (for TCP start time 0.0 and end time 20.0)
15. Click OK button on the command window to exit.
16. Also add the following common on HOST3
rtg –u –w log1 (for UDP start time 21.0 and end time 40.0)
17. Click NODE EDITOR Button on the HOST window and select the MAC tab from the modal window that
pops up.
18. Select LOG STATISTICS and select check box for input and output throughput in the MAC window
19. Click OK button on the MAC window and once again click on the OK button on the HOST window to exit.

Step3: Simulate

1. Click “R” icon on the tool bar


2. Select Simulation in the menu bar and click/ select RUN in the drop down list to execute the simulation.
3. To start playback select “►” icon located at the bottom right corner of the editor.
4. To view results, Open input and output throughput log files from file2.results folder in separate word
processor.
Caution: file2 is the hypothetical name given to this simulation. (Refer Step 1.4)

Page 11
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.6 Block / Circuit / Model / Reaction Diagram

1.7 Results & Analysis

TCP Connection
With Bandwidth 10 MBPS and BER 0.000000000
No. of Packets
Time
N1_Output Throughput N2_Output Throughput Drop Packets
1 713.230 713.230 0
2 807.576 807.576 0
3 751.476 751.476 0
4 687.654 687.654 0
5 851.598 851.594 0

No. of Packets
Time
N1_Output Throughput N2_Output Throughput Drop Packets
22 1146.034 1146.034 0

Page 12
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

23 1179.140 1179.140 0
24 1177.000 1177.000 0
25 1178.070 1178.070 0
26 1178.070 1178.070 0

1.8 Outcome & Conclusion






1.9 Remarks




FACULTY SIGNATURE

1.0 Experiment

Experiment No Date Planed Date Conducted Marks


03

TITLE:

Page 13
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Simulate an Ethernet LAN using n nodes (6-10), compare throughput by changing error rate and data rate.

1.1 Learning Objectives


To understand the throughput analysis in Ethernet LAN.

1.2 Aim

 Simulation of Ethernet LAN consisting of 6 or more nodes using NCTUns.


 Compare throughput of Ethernet LAN by changing error rate and data rate.

1.3 Material / Equipment Required

 Intel based PC
 NCTUns tool
 Word processor

1.4 Theory / Hypothesis


Ethernet is the most popular physical layer LAN technology in use today. It defines the number of conductors that are
required for a connection, the performance thresholds that can be expected, and provides the framework for data
transmission. A standard Ethernet network can transmit data at a rate up to 10 Megabits per second (10 Mbps). Other
LAN types include Token Ring, Fast Ethernet, Gigabit Ethernet, 10 Gigabit Ethernet, Fiber Distributed Data Interface
(FDDI), Asynchronous Transfer Mode (ATM) and Local Talk.
Ethernet is popular because it strikes a good balance between speed, cost and ease of installation. These benefits,
combined with wide acceptance in the computer marketplace and the ability to support virtually all popular network
protocols, make Ethernet an ideal networking technology for most computer users today.
The Institute for Electrical and Electronic Engineers developed an Ethernet standard known as IEEE Standard 802.3.
This standard defines rules for configuring an Ethernet network and also specifies how the elements in an Ethernet
network interact with one another. By adhering to the IEEE standard, network equipment and network protocols can
communicate efficiently.
Ethernet is commonly described as being a packet delivery system. In reality, an Ethernet frame is made up of all the
necessary parts to fit the requirements and definition of a packet. An Ethernet frame has a header (Preamble - Length),
payload (LLC - Pad), and a trailer (Frame Check Sequence) that are bundled together in a specifically organized
manner for transmission (see Figure 2).

Header
 Preamble—Sets bit timing and signals that a frame is being sent (10 Mb/s Ethernet)
 Start Frame Delimiter—8-bit sequence (10101011) Note: 100 and 1000 Mb/s Ethernet systems signal
constantly and do not need preamble or start frame delimiter fields.
 Destination Address—48-bit receiving hardware media access control (MAC) address
 Source Address—48-bit transmitting hardware address
 Type—Indicates protocol sending the frame (DIX only)
 Length—Indicates the length of data field (number of LLC data bytes) (IEEE 802.3 only)

Payload
 Logical Link Control (LLC)—Governs the assembly of data at the data link (Layer 2) level

Page 14
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

 Data—Payload contained in a field (between 46 bytes and just over 1500 bytes in length)
 Pad—0 bits added to the data field if there are fewer than 46 bytes of data in that field

Trailer
 Cyclical Redundancy Check (CRC)—Detects DIX-only transmission errors
 Frame Check Sequence (FCS)—Detects transmission errors and provides quality of service at receiving end
Note: According to section 3.3 of the IEEE 802.3 standard, each octet of the Ethernet frame, with the exception of the
FCS, is transmitted low-order bit first.

Ethernet Address
Each Ethernet network interface card (NIC) has a unique identifier called a MAC address that is assigned by the card
manufacturer. Each manufacturer that complies with IEEE standards can apply to the IEEE Registration Authority for a
range of numbers for its cards. Each MAC address is a 48-bit number, of which the first 24 bits identify the
manufacturer. This part of the MAC address (manufacturer ID or organizational unique identifier [OUI]) is assigned by
the registration authority. The second half of the address (extension of board ID) is assigned by the manufacturer. The
number is usually programmed into the hardware so that it cannot be changed. Because the MAC address is assigned to
the NIC, it moves with the computer. Even if the interface card moves to another location across the world, the user is
reached at this address.

1.5 Procedure / Program / Activity

Step1: Drawing topology


1.
Select/click the HOST icon on the tool bar and click the left mouse button on the editor, to place HOST1 on
the editor.
i. Repeat the above procedure and place 5 other hosts “HOST2”, “HOST3”, “HOST4”, “HOST5”, and
“HOST6”on the editor.
2. Select/click the HUB icon on the tool bar and click the left mouse button on the editor, to place HUB1 on the
editor. Repeat the above procedure and place another host “HUB2” on the editor
3. Click on the LINK icon on the tool bar and connect HOST1, HOST2 and HOST3 to HUB1, HOST4, HOST5
and HOST6 to HUB2.
4. Select/click the SWITCH icon on the tool bar and click the left mouse button on the editor, to place SWITCH1
on the editor.
5. Click on the LINK icon on the tool bar and connect HUB1 to SWITCH1 and HUB2 to SWITCH1.
6. Click on the “E” icon on the tool bar to save the current topology e.g: file5.tpl (Look for the ******.tpl
extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
2. Select Add button on the HOST window to invoke the command window and provide the following command
in the command text box.
stcp –p 21 –l 1024 1.0.1.4 3.
3. Click OK button on the command window to exit and once again click on the OK button on the HOST window
to exit.
4. Repeat this step at HOST 2 and HOST3, but use different commands

Page 15
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

stcp –p 21 –l 1024 1.0.1.5 at HOST2


stcp –p 21 –l 1024 1.0.1.6 at HOST3
5. Double click the left mouse button while cursor is on HOST4 to open the HOST window.
6. Select Add button on the HOST window to invoke the command window and provide the following command
in the command textbox.
rtcp –p 21 –l 1024
7. Click OK button on the command window to exit.
8. Click NODE EDITOR Button on the HOST window and select the MAC tab from the modal window that
pops up.
9. Select LOG STATISTICS and select check box for output throughput in the MAC window
10. Click OK button on the MAC window to exit and once again click on the OK button on the HOST window to
exit.
11. Repeat this step at HOST 5 and HOST6, but use different commands
rtcp –p 21 –l 1024 at HOST5
rtcp –p 21 –l 1024 at HOST6
12. Double click the left mouse button while cursor is on HOST5 to open the HOST window.
13. Click NODE EDITOR Button on the HOST5 window and select the PHYSICAL tab from the modal window
that pops up.
14. Change Bit Error Rate
15. Click OK button on the PHYSICAL window to exit and once again click on the OK button to return to the
HOST window
16. Click NODE EDITOR Button on the HOST window and select the MAC tab from the modal window that
pops up.
17. Select LOG STATISTICS and select check box for output throughput in the MAC window
18. Click OK button on the MAC window to exit and once again click on the OK button on the HOST window to
exit.
19. Repeat this step HOST6, Change Bandwidth this time while undoing the change in Bit Error Rate, also select
the output throughput at HOST6.

Step3: Simulate
1. Click “R” icon on the tool bar
2. Select Simulation in the menu bar and click/ select RUN in the drop down list to execute the simulation.
3. To start playback select “►” icon located at the bottom right corner of the editor.
4. To view results, Open input and output throughput log files from file5.results folder in separate word
processor.
Caution: file5 is the hypothetical name we gave to this simulation (Refer Step 1.7)

1.6 Block / Circuit / Model / Reaction Diagram

Page 16
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.7 Results & Analysis

With Bandwidth 10 MBPS and BER 0.000000000


No. of Packets
Time
In_Throughput Out_Throughput
Node_N1 Node_N2 Node_N3 Node_N4 Node_N5 Node_N6
1 148.598 329.194 374.780 148.534 329.194 376.234
2 88.044 78.936 450.846 88.044 78.936 449.328
3 358.248 289.938 65.274 359.766 291.456 66.782
4 242.880 83.490 315.744 244.358 81.972 315.744
5 214.038 1.518 338.514 212.520 1.518 340.032

WITH BANDWIDTH 20 MBPS AND BER 0.0000000000

Time No. of Packets

Page 17
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

In _Throughput Out _Throughput


Node_N1 Node_N2 Node_N3 Node_N4 Node_N5 Node_N6
1 885.210 740.632 620.984 890.304 745.854 624.944
2 665.540 1079.630 497.550 671.960 1089.260 498.620
3 964.070 738.300 555.330 969.420 743.650 557.470
4 589.570 619.530 1035.760 593.860 628.090 1038.970
5 679.450 789.660 941.600 681.590 638.790 945.880

1.8 Outcome & Conclusion

1.9 Remarks

FACULTY SIGNATURE

1.0 Experiment

Experiment No Date Planed Date Conducted Marks


04

Page 18
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

TITLE:

Implement Ethernet LAN using n nodes and assign multiple traffics to the nodes and obtain congestion
window for different sources/ destinations.

1.1 Learning Objectives


To understand collision analysis in Ethernet LAN.

1.2 Aim

 Simulation of Ethernet LAN consisting of 6 or more nodes using NCTUns.


 Determining collision across different nodes by varying traffic.

1.3 Material / Equipment Required

 Intel based PC
 NCTUns tool
 Word processor

1.4 Theory / Hypothesis


Ethernet is the most popular physical layer LAN technology in use today. It defines the number of conductors that are
required for a connection, the performance thresholds that can be expected, and provides the framework for data
transmission. A standard Ethernet network can transmit data at a rate up to 10 Megabits per second (10 Mbps). Other
LAN types include Token Ring, Fast Ethernet, Gigabit Ethernet, 10 Gigabit Ethernet, Fiber Distributed Data Interface
(FDDI), Asynchronous Transfer Mode (ATM) and LocalTalk.
Ethernet is popular because it strikes a good balance between speed, cost and ease of installation. These benefits,
combined with wide acceptance in the computer marketplace and the ability to support virtually all popular network
protocols, make Ethernet an ideal networking technology for most computer users today.
The Institute for Electrical and Electronic Engineers developed an Ethernet standard known as IEEE Standard 802.3.
This standard defines rules for configuring an Ethernet network and also specifies how the elements in an Ethernet
network interact with one another. By adhering to the IEEE standard, network equipment and network protocols can
communicate efficiently.
Ethernet is commonly described as being a packet delivery system. In reality, an Ethernet frame is made up of all the
necessary parts to fit the requirements and definition of a packet. An Ethernet frame has a header (Preamble - Length),
payload (LLC - Pad), and a trailer (Frame Check Sequence) that are bundled together in a specifically organized
manner for transmission (see Figure 2).

Header
 Preamble—Sets bit timing and signals that a frame is being sent (10 Mb/s Ethernet)
 Start Frame Delimiter—8-bit sequence (10101011) Note: 100 and 1000 Mb/s Ethernet systems signal
constantly and do not need preamble or start frame delimiter fields.

Page 19
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

 Destination Address—48-bit receiving hardware media access control (MAC) address


 Source Address—48-bit transmitting hardware address
 Type—Indicates protocol sending the frame (DIX only)
 Length—Indicates the length of data field (number of LLC data bytes) (IEEE 802.3 only)

Payload
 Logical Link Control (LLC)—Governs the assembly of data at the data link (Layer 2) level
 Data—Payload contained in a field (between 46 bytes and just over 1500 bytes in length)
 Pad—0 bits added to the data field if there are fewer than 46 bytes of data in that field

Trailer
 Cyclical Redundancy Check (CRC)—Detects DIX-only transmission errors
 Frame Check Sequence (FCS)—Detects transmission errors and provides quality of service at receiving end
Note: According to section 3.3 of the IEEE 802.3 standard, each octet of the Ethernet frame, with the exception of the
FCS, is transmitted low-order bit first.

Ethernet Address
Each Ethernet network interface card (NIC) has a unique identifier called a MAC address that is assigned by the card
manufacturer. Each manufacturer that complies with IEEE standards can apply to the IEEE Registration Authority for a
range of numbers for its cards. Each MAC address is a 48-bit number, of which the first 24 bits identify the
manufacturer. This part of the MAC address (manufacturer ID or organizational unique identifier [OUI]) is assigned by
the registration authority. The second half of the address (extension of board ID) is assigned by the manufacturer. The
number is usually programmed into the hardware so that it cannot be changed. Because the MAC address is assigned to
the NIC, it moves with the computer. Even if the interface card moves to another location across the world, the user is
reached at this address.

1.5 Procedure / Program / Activity


Step1: Drawing topology

1.
Select/click the HOST icon on the toolbar and click the left mouse button on the editor, to place HOST1 on the
editor.
i. Repeat the above procedure and place 3 other hosts “HOST2”, “HOST3”, “HOST4”, “HOST5”, and
“HOST6”on the editor.
2. Select/click the HUB icon on the tool bar and click the left mouse button on the editor, to place HUB1 on the
editor. Repeat the above procedure and place another host “HUB2” on the editor
3. Click on the LINK icon on the tool bar and connect HOST1, HOST2 and HOST3 to HUB1, HOST4, HOST5
and HOST6 to HUB2.
4. Select/click the SWITCH icon on the tool bar and click the left mouse button on the editor, to place SWITCH1
on the editor.
5. Click on the LINK icon on the tool bar and connect HUB1 to SWITCH1 and HUB2 to SWITCH1.
6. Click on the “E” icon on the tool bar to save the current topology e.g: file6.tpl (Look for the ******.tpl
extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration

1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.

Page 20
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

2. Select Add button on the HOST window to invoke the command window and provide the following command
in the command text box.
stcp –p 21 –l 1024 1.0.1.4
3. Click OK button on the command window to exit and once again click on the OK button on the HOST window
to exit.
4. Repeat this step at HOST 2 and HOST3, but use different commands
stcp –p 23 –l 1024 1.0.1.5 at HOST2
stcp –p 25 –l 1024 1.0.1.6 at HOST3
5. Double click the left mouse button while cursor is on HOST4 to open the HOST window.
6. Select Add button on the HOST window to invoke the command window and provide the following command
in the command text box.
rtcp –p 21 –l 1024
7. Click OK button on the command window to exit.
8. Click NODE EDITOR Button on the HOST window and select the MAC tab from the modal window that
pops up.
9. Select LOG STATISTICS and select check box for Number of drop and collisions packets in the MAC
window
10. Click OK button on the MAC window to exit and once again click on the OK button on the HOST window to
exit.
11. Repeat this step at HOST 5 and HOST6, but use different commands
rtcp –p 23 –l 1024 at HOST5
rtcp –p 25 –l 1024 at HOST6
12. Double click the left mouse button while cursor is on HOST5 to open the HOST window.
13. Click NODE EDITOR Button on the HOST5 window and select the MAC tab from the modal window that
pops up.
14. Select LOG STATISTICS and select check box for Number of drop and collisions packets in the MAC
window
15. Click OK button on the MAC window to exit and once again click on the OK button on the HOST window to
exit.
16. Also select the drop and collisions at HOST6.

Step3: Simulate

1. Click “R” icon on the tool bar


2. Select Simulation in the menu bar and click/ select RUN in the drop down list to execute the simulation.
3. To start playback select “►” icon located at the bottom right corner of the editor.
4. To view results, Open input and output throughput log files from file6.results folder in separate word
processor.
5. To plot congestion window select Tools in the menu bar and select PLOT GRAPH in the drop down list.
6. In the Graph window, select File->OPEN, move to file7.results folder and the drop and collision log file.
7. To open another Graph window, Select File->New tab on the drop down list to open up to a maximum of 6
windows
Caution: file7 is the hypothetical name given to this simulation .

1.6 Block / Circuit / Model / Reaction Diagram

Page 21
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.7 Results & Analysis

WITH BANDWIDTH 10 MBPS AND BER 0.000000000

No. of Packets
Time Collisions Log
Node_N1 Node_N2 Node_N3 Node_N4 Node_N5 Node_N6
1 0.064 678.316 0.0320 0.0320 675.536 0.064
2 0 784.306 0 0 784.806 0
3 0 750.526 0 0 753.562 0
4 0 663.366 0 0 661.848 0
5 0 783.288 0 0 783.288 0

1.8 Graph

Page 22
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.9 Outcome & Conclusion

1.10 Remarks

FACULTY SIGNATURE
1.0 Experiment

Page 23
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Experiment No Date Planed Date Conducted Marks


05

TITLE:
Implement ESS with transmission nodes in Wireless LAN and obtain the performance parameters.

1.1 Learning Objectives


To understand the simulation of wireless LAN.

1.2 Aim
To compute the performance of wireless LAN with respect to transmission of packets.

1.3 Material / Equipment Required


 Intel based PC
 NCTUns tool
 Word processor

1.4 Theory / Hypothesis


A wireless network is very similar to the wired network in that all the same pieces are still required, a wireless NIC,
Access Point (similar to a wired network Ethernet Switch) and a wireless router. The only thing that's missing is the
cables.
First you will need to determine if your desktop or Laptop PC already has a wireless NIC built in. Again, check your
users guide to confirm this. Once your wireless NIC is installed you will need to configure the SSID (service set
identifier) on each of the PC's to use the same name. Also, you need to make sure all the wireless NICs are configured
to be on the same channel and set levels of encryption if desired. Your wireless access point or router should come with
detailed explanation of how to configure the SSID and security features such as encryption and access lists. Many of
today's wireless routers come with the access point functionality built right in.

1.5 Procedure / Program / Activity


Step1:
Drawing
topology

1. Select/click the HOST icon on the tool bar and click the left mouse button on the editor, to place HOST1 on
the editor.

Page 24
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

2. Select/click the ROUTER icon on the tool bar and click the left mouse button on the editor, to place
ROUTER1 on the editor.
3. Select/click the WIRELESS ACCESS POINT(802.11b) icon on the tool bar and click the left mouse button on
the editor, to place ACCESS POINT 1 on the editor.
4. Repeat this procedure and place ACCESS POINT 2 on the editor. Select/click the MOBILE NODE
(infrastructure mode) icon on the tool bar and click the left mouse button on the editor, to place MOBILE
NODE 1 on the editor. Repeat this procedure and place MOBILE NODE 2, MOBILE NODE3 and MOBILE
NODE 4 on the editor.
5. Click on the LINK icon on the tool bar and connect ACCESS POINT1 to ROUTER1 and ACCESS POINT2 to
ROUTER1
6. Click on the “Create a moving path” icon on the tool bar and draw moving path across MOBILE NODE 1 and
2, Repeat for MOBILE NODE 3and 4 (Accept the default speed value 10 and close the window, Click the right
mouse button to terminate the path).
To create Subnet
7. Select wireless subnet icon in the tool bar now select MOBILE NODE1 MOBILE NODE2 and ACCESS
POINT1 by clicking on left mouse button, and clicking right mouse button will create a subnet.
8. Repeat the above step for MOBILE NODE3, MOBILE NODE4 and ACCESS POINT2.
9. Click on the “E” icon on the tool bar to save the current topology e.g: file8.tpl (Look for the ******.tpl
extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration

1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
2. Select Add button on the HOST window to invoke the command window and provide the following command
in the command text box.
rtcp –r –u –s –p 8001
3. Click OK button on the command window to exit
4. Repeat this step and add the following commands at HOST1
rtcp –r –u –s –p 8002
rtcp –r –u –s –p 8003
rtcp –r –u –s –p 8004
5. Click NODE EDITOR Button on the HOST1 window and select the MAC tab from the modal window that
pops up.
6. Select LOG STATISTICS and select check box for Input throughput in the MAC window
7. Click OK button on the MAC window to exit and once again click on the OK button on the HOST window to
exit.
8. Double click the left mouse button while cursor is on MOBILE NODE 1 to open the MOBILE NODE
window.
9. Select Application tab and select Add button to invoke the command window and provide the following
command in the command text box.
rtcp –t –u –s –p 80011.0.2.2 (host’s ip address)
10. Click NODE EDITOR Button on the MOBILE NODE1 window and select the MAC tab from the nodal
window that pops up.
11. Select LOG STATISTICS and select check box for Output throughput in the MAC window
12. Click OK button on the MAC window to exit and once again click on the OK button on the MOBILE NODE1
window to exit.
13. Repeat the above steps (step 8 to step12) for the MOBILE NODE2,3 and 4 and add the following commands at
MOBILE NODE2:- rtcp –t –u –s –p 8002 1.0.2.2
MOBILE NODE 3:- rtcp –t–u –s –p 8003 1.0.2.2
MOBILE NODE4:- rtcp –t –u –s –p 8004 1.0.2.2 14.
14. Double click the left mouse button while cursor is on ROTER1 to open the ROUTER window.

Page 25
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

15. Click NODE EDITOR Button on the ROUTER1 window and you can see three stacks. two stacks for two
ACCESS POINTS and another stack for HOST1 which is connected to the ROUTER1.
16. Select the MAC tab of ACCESS POINT1 and Select LOG STATISTICS and select check box for Input
throughput in the MAC window. Click OK button on the MAC window to exit.
17. Select the MAC tab of ACCESS POINT2 and Select LOG STATISTICS and select check box for Input
throughput in the MAC window. Click OK button on the MAC window to exit.
18. Select the MAC tab of HOST1 and Select LOG STATISTICS and select check box for Output throughput in
the MAC window. Click OK button on the MAC window to exit.

Step3: Simulate

1. Click “R” icon on the tool bar


2. Select Simulation in the menu bar and click/ select RUN in the drop down list to execute the simulation.
3. To start playback select “►” icon located at the bottom right corner of the editor.
4. MOBILE NODE’s start moving across the paths already drawn.
Caution: file8 is the hypothetical name given to this simulation,

1.6 Block / Circuit / Model / Reaction Diagram

1.7 Results & Analysis

With Bandwidth 10 MBPS and BER 0.000000000

Page 26
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

No. of Packets
Time
Node_N1_Output_Throughput Mobile _ Node _ Input _Throughput

1 0 0.522

2 0 0.305

3 0 0.235

4 0 0.235

5 0 0.235

1.8 Outcome & Conclusion

1.9 Remarks

FACULTY SIGNATURE

1.0 Experiment

Experiment No Date Planed Date Conducted Marks

Page 27
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

07

TITLE:
Write a program for a HLDC frame to perform the following.
i) Bit stuffing
II) CHARACTER STUFFING.
1.1 Learning Objectives

 To understand bit stuffing and character stuffing used to bring bit stream to a common transmission rate.
 To understand how bit and character stuffing are used in HLDC.

1.2 Aim
Implementation of bit stuffing and character stuffing in HLDC.

1.3 Material / Equipment Required

 Intel based PC
 GCC Compiler

1.4 Theory / Hypothesis


HLDC: High level data link is a bit oriented code-transparent synchronous data link layer protocol developed by the
ISO. HLDC provides both connection oriented and connectionless service. HLDC can be used for point-to- multipoint
connections via the original master-slave modes Normal Response Mode (NRM) and Asynchronous Response Mode
(ARM), but they now rarely used; is now used almost exclusively to connect one device to another, using Asynchronous
Balanced Mode.

Bit Stuffing: Bit stuffing is the process of inserting non-information bits into data to break up bit patterns to affect the
synchronous transmission of information. Bit stuffing is commonly used to bring bit streams up to a common
transmission rate or to fill frames. Bit stuffing is also used for run-length limited coding. In order to fill bit frames, the
position where the new bits are stuffed is communicated to the receiving end of the data link. The receiver removes the
extra bits to return the bit streams to their original bit rate. This is used when a communication protocol requires a fixed
frame size. Bits are inserted to make the frame size equal to the defined frame size.

Character Stuffing: In this method, each frame starts with the ASCII character sequence DLE STX and ends with the
sequence DLE ETX (Where DLE is Data Link Escape, STX is start of Text and ETX is end of Text). This method
overcomes the drawback of the character count method. If destination ever loses synchronization, it has to only search
for DLE STX and DLE ETX.

1.5 Procedure / Program / Activity

 ALGORITHM

Page 28
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1. Given a bit string, with 5 ones in the bit stream, insert 0 after counting 5 ones.
2. Add DLE STX as bit stream of “011111110”
3. Add DLE ETX as bit stream of “011111110”

 PROGRAM (BIT STUFFING)

#include <stdio.h>
#include <conio.h>
int main()
{
int a[15];
int i, j, k, n, C=0, pos=0;
printf(“\n enter the no of bits”);
scanf(“%d”, &n);
for (i=0; i<n; i++)
scanf(“%d”, &a[i]);
for (i=0; i<n; i++)
{
If(a[i]==1)
{
C++
If(C==5)
{
Pos=i+1;
C=0;
For(j=n; j>=pos; j--)
{
K=j+1;
a[k]=a[j];
}
a[pos]=0;
n=n+1;
}
}
else
C=0;
}
printf(“\n data after stuffing”);
printf(“011111110”);
for (i=0; i<n; i++)
{
printf(“%d”, a[i]);
}
printf(“011111110”);

Page 29
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

return(0);
}

 PROGRAM (BIT STUFFING)

#include<stdio.h>
#include<string.h>
int main()
{
char messin[100]. messout[100];
int i, j=0, len=0;
printf (“Enter the message”)
for (i=0; 1<8; i++ )
scanf (“%S”, &messin[i]);
len = strlen (messin);
for (i=0; 1<len; i++ )
{
if (messin[i] == ‘s’ || messin[i] ==’d’|| messin[i] == ‘e’)
messout [j++] = ‘d’;
messout [j++] = messin[i];
}
printf (“After Character Stuffing” );
printf (“%S”, messout);
}

1.6 Formula / Calculations

1.7 Results & Analysis

FOR BIT STUFFING

Page 30
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

[root@localhost ~]# gccbs.c


[root@localhost ~]# ./a.out

Enter the number of bits: 7


0
1
1
1
1
1
0

Data after stuffing: 01111111001111100011111110

FOR CHARACTER STUFFING


Enter the message: schedule
After character stuffing: sdchedddled

1.8 Outcome & Conclusion

1.9 Remarks

FACULTY SIGNATURE

1.0 Experiment

Page 31
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Experiment No Date Planed Date Conducted Marks


08

TITLE:
Write a program for distance vector algorithm to find suitable path for transmission.

1.1 Learning Objectives


To understand the different routing algorithms.

1.2 Aim
To implement distance vector routing algorithm in 'C'.

1.3 Material / Equipment Required

 Intel based PC
 GCC Compiler

1.4 Theory / Hypothesis


Routing algorithm is a part of network layer software which is responsible for deciding which output line an incoming
packet should be transmitted on. If the subnet uses datagram internally, this decision must be made anew for every
arriving data packet since the best route may have changed since last time. If the subnet uses virtual circuits internally,
routing decisions are made only when a new established route is being set up. The latter case is sometimes called
session routing, because a rout remains in force for an entire user session (e.g., login session at a terminal or a file).
Routing algorithms can be grouped into two major classes: adaptive and nonadaptive. Nonadaptive algorithms do not
base their routing decisions on measurement or estimates of current traffic and topology. Instead, the choice of route to
use to get from I to J (for all I and J) is compute in advance, off line, and downloaded to the routers when the network
ids booted. This procedure is sometime called static routing. Adaptive algorithms, in contrast, change their routing
decisions to reflect changes in the topology, and usually the traffic as well. Adaptive algorithms differ in where they get
information (e.g., locally, from adjacent routers, or from all routers), when they change the routes (e.g., every T sec,
when the load changes, or when the topology changes), and what metric is used for optimization (e.g., distance, number
of hops, or estimated transit time). Two algorithms in particular, distance vector routing and link state routing are the
most popular. Distance vector routing algorithms operate by having each router maintain a table (i.e., vector) giving the
best known distance to each destination and which line to get there. These tables are updated by exchanging
information with the neighbors. The distance vector routing algorithm is sometimes called by other names, including
the distributed Bellman-Ford routing algorithm and the Ford-Fulkerson algorithm, after the researchers who developed
it (Bellman, 1957; and Ford and Fulkerson, 1962). It was the original ARPANET routing algorithm and was also used in
the Internet under the RIP and in early versions of DECnet and Novell’s IPX. AppleTalk and Cisco routers use
improved distance vector protocols.
In distance vector routing, each router maintains a routing table indexed by, and containing one entry for, each router in
subnet. This entry contains two parts: the preferred out going line to use for that destination, and an estimate of the time
or distance to that destination. The metric used might be number of hops, time delay in milliseconds, total number of
packets queued along the path, or something similar. The router is assumed to know the “distance” to each of its
neighbor. If the metric is hops, the distance is just one hop. If the metric is queue length, the router simply examines
each queue. If the metric is delay, the router can measure it directly with special ECHO packets hat the receiver just
time stamps and sends back as fast as possible.

The Count to Infinity Problem.


Distance vector routing algorithm reacts rapidly to good news, but leisurely to bad news.

Page 32
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Consider a router whose best route to destination X is large. If on the next exchange neighbor A
suddenly reports a short delay to X, the router just switches over to using the line to A to send
traffic to X. In one vector exchange, the good news is processed.
To see how fast good news propagates, consider the five node (linear) subnet of following
figure, where the delay metric is the number of hops. Suppose A is down initially and all the other
routers know this. In other words, they have all recorded the delay to A as infinity.
A B C D A B C D

∞ ∞ ∞ ∞ Initially 1 2 3 4 Initially

1 ∞ ∞ ∞ After 1 exchange 3 2 3 4 After 1 exchange

1 2 ∞ ∞ After 2 exchange 3 3 3 4 After 2 exchange

1 2 3 ∞ After 3 exchange 5 3 5 4 After 3 exchange

1 2 3 4 After 4 exchange 5 6 5 6 After 4 exchange

7 6 7 6 After 5 exchange

. . . . .

∞ ∞ ∞ ∞ After n exchange

Many ad hoc solutions to the count to infinity problem have been proposed in the literature, each one more complicated
and less useful than the one before it. The split horizon algorithm works the same way as distance vector routing, except
that the distance to X is not reported on line that packets for X are sent on (actually, it is reported as infinity). In the
initial state of right figure, for example, C tells D the truth about distance to A but C tells B that its distance to A is
infinite. Similarly, D tells the truth to E but lies to C.

1.5 Procedure / Program / Activity


 ALGORITHM
1. c(x,v) = cost for direct link from x to v
i. Node x maintains costs of direct links c(x,v)
2. Dx (y) = estimate of least cost from x to y
i. Node x maintains distance vector Dx = [Dx (y): y є N ]
3. Node x maintains its neighbors’ distance vectors
i. For each neighbor v, x maintains Dv = [Dv (y): y є N ]
4. Each node v periodically sends Dv to its neighbors
i. And neighbors update their own distance vectors
ii. Dx(y) ← minv {c(x,v) + Dv (y)} for each node y ∊ N
 PROGRAM

#include<stdlib.h>
#include<stdio.h>
#define nul 1000
#define nodes 10

Page 33
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

int no;

struct node
{
int a[nodes][3];
}router[nodes];

void init(int r)
{
inti;
for(i=1;i<=no;i++)
{
router[r].a[i][1]=i;
router[r].a[i][2]=999;
router[r].a[i][3]=nul;
}
router[r].a[r][2]=0;
router[r].a[r][3]=r;
}

void inp(int r)
{
inti;
printf("\nEnterdist from the node %d to other nodes",r);
printf("\nPls enter 999 if there is no direct route\n");
for(i=1;i<=no;i++)
{
if(i!=r)
{
printf("\nEnterdist to the node %d:",i);
scanf("%d",&router[r].a[i][2]);
router[r].a[i][3]=i;
}
}
}

void display(int r)
{
inti;
printf("\n\nThe routing table for node %d is as follows:",r);
for(i=1;i<=no;i++)
{
if(router[r].a[i][2]>=999)
printf("\n\t\t\t %d \t no link \t no hop",router[r].a[i][1]);
else
printf("\n\t\t\t %d \t %d \t\t %d",router[r].a[i][1],router[r].a[i][2],router[r].a[i][3]);
}
}

Page 34
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

void dv_algo(int r)
{
inti,j,z;
for(i=1;i<=no;i++)
{
if(router[r].a[i][2]!=999 && router[r].a[i][2]!=0)
{
for(j=1;j<=no;j++)
{
z=router[r].a[i][2]+router[i].a[j][2];
if(router[r].a[j][2]>z)
{
router[r].a[j][2]=z; router[r].a[j][3]=i;
}
}
}
}
}

int main()
{
int i,x,y;
int choice;
printf("Enter the no. of nodes required (less than 10 pls):");
scanf("%d",&no);
for(i=1;i<=no;i++)
{
init(i);
inp(i);
}
printf("\nThe configuration of the nodes after initialization is as follows:");
for(i=1;i<=no;i++)
display(i);
for(j=1;j<=no;j++)
for(i=1;i<=no;i++)
dv_algo(i);
printf("\nThe configuration of the nodes after computation of paths is as follows:");
for(i=1;i<=no;i++)
display(i);
while(1)
{
printf("\n\nEnter 1 to continue 0 to quit:");
scanf("%d",&choice);
if(choice!=1)
break;
printf("\nEnter the nodes btn which shortest path is to be found:\n");
scanf("%d%d",&x,&y);
printf("\nThe length of the shortest path is %d",router[x].a[y][2]);
}
return (0);

Page 35
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.6 Results & Analysis

Enter the no. of nodes required (less than 10 pls):4

Enter dist from the node 1 to other nodes


Pls enter 999 if there is no direct route
Enter dist to the node 2:2
Enter dist to the node 3:6
Enter dist to the node 4:999
Enter dist from the node 2 to other nodes
Pls enter 999 if there is no direct route
Enter dist to the node 1:2
Enter dist to the node 3:1
Enter dist to the node 4:5
Enter dist from the node 3 to other nodes
Pls enter 999 if there is no direct route
Enter dist to the node 1:6
Enter dist to the node 2:1
Enter dist to the node 4:2
Enter dist from the node 4 to other nodes
Pls enter 999 if there is no direct route
Enter dist to the node 1:999
Enter dist to the node 2:5
Enter dist to the node 3:2
The configuration of the nodes after initialization is as follows:

The routing table for node 1 is as follows:


1 0 1
2 2 2
3 6 3
4 no link no hop
The routing table for node 2 is as follows:
1 2 1
2 0 2
3 1 3
4 5 4
The routing table for node 3 is as follows:
1 6 1
2 1 2
3 0 3
4 2 4
The routing table for node 4 is as follows:
1 no link no hop
2 5 2
3 2 3
4 0 4
The configuration of the nodes after computation of paths is as follows:

Page 36
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

The routing table for node 1 is as follows:


1 0 1
2 2 2
3 3 2
4 5 3
The routing table for node 2 is as follows:
1 2 1
2 0 2
3 1 3
4 3 3
The routing table for node 3 is as follows:
1 3 2
2 1 2
3 0 3
4 2 4
The routing table for node 4 is as follows:
1 5 3
2 3 3
3 2 3
4 0 4

Enter 1 to continue 0 to quit:1


Enter the nodes btn which shortest path is to be found:
14
The length of the shortest path is 5
Enter 1 to continue 0 to quit:1
Enter the nodes btn which shortest path is to be found:
13
The length of the shortest path is 3
Enter 1 to continue 0 to quit:0

1.7 Outcome & Conclusion

1.8 Remarks

FACULTY SIGNATURE
Experiment No Date Planed Date Conducted Marks
09

Page 37
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

TITLE:
Write a program for to implement Dijkstra’s algorithm to compute the shortest path.

1.1 Learning Objectives


To understand shortest path algorithm to find suitable path.

1.2 Aim
To implement Dijkstra’s algorithm in 'C'.

1.3 Material / Equipment Required

 Intel based PC
 GCC Compiler

1.4 Theory / Hypothesis


Dijkstra’s algorithm is an algorithm for finding the shortest between nodes in a graph, which may represent for example
road network. It was conceived by computer scientist Edsger W. Dijkstra in 1956 and published three years later.
For a given source node in the graph, the algorithm finds the shortest path between that node and every other nodes. It
can also be used for finding shortest paths from single node to a single destination node by stopping the algorithm once
the shortest path to the destination node has been determined.
For example, if the nodes of the graph represent cities and edge path costs represent driving distances between pairs of
the cities connected by a direct node, Dijkstra algorithm can be used to find the shortest route between one city and all
other cities. As a result the shortest path algorithm is widely used in network routing protocols, most notably IS-IS
(Intermediate System to Intermediate System) and Open Shortest Path First (OSPF). It is also employed as a subroutine
in other algorithms such as Johnson’s.

1.5 Procedure / Program / Activity


 ALGORITHM

Cost Calculation:

Page 38
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

 PROGRAM

Dijkstra's Algorithm to Compute Shortest Path


#include<stdio.h>
//#include<conio.h>
#define infinity 999
void dij(int n,int v,int cost[10][10],int dist[100])
{
int i,u,count,w,flag[10],min;
for(i=1;i<=n;i++)
flag[i]=0,dist[i]=cost[v][i];
count=2;
while(count<=n)

Page 39
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

{
min=99;
for(w=1;w<=n;w++)
if(dist[w]<min && !flag[w])
min=dist[w],u=w;
flag[u]=1;
count++;
for(w=1;w<=n;w++)
if((dist[u]+cost[u][w]<dist[w]) && !flag[w])
dist[w]=dist[u]+cost[u][w];
}
}
int main()
{
int n,v,i,j,cost[10][10],dist[10];
//clrscr();
printf("\n Enter the number of nodes:");
scanf("%d",&n);
printf("\n Enter the cost matrix:\n");
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
scanf("%d",&cost[i][j]);
if(cost[i][j]==0)
cost[i][j]=infinity;
}
printf("\n Enter the source matrix:");
scanf("%d",&v);
dij(n,v,cost,dist);
printf("\n Shortest path:\n");
for(i=1;i<=n;i++)
if(i!=v)
printf("%d->%d,cost=%d\n",v,i,dist[i]);
return(0);
}

Page 40
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.6 Results & Analysis

1. Enter the number of nodes: 4


Enter the Cost Matrix

0 8 1 999
8 0 1 1
1 1 0 9
999 1 9 0

Enter the Source Matrix: 1

Shortest Path:
1 2; Cost: 2
1 3; Cost: 1
1 4; Cost: 3

1.7 Outcome & Conclusion

1.8 Remarks

FACULTY SIGNATURE

1.0 Experiment

Experiment No Date Planed Date Conducted Marks


10

TITLE:
Write a program for error detecting code using CRC-CCITT (16- bits).

1.1 Learning Objectives

 To understand different error detection and correction algorithms.


 To understand how to implement CRC-CCITT (16- bits) in 'C'.

1.2 Aim
Implementation of error detection code using CRC-CCITT (16- bits) in 'C'.

Page 41
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.3 Material / Equipment Required

 Intel based PC
 GCC Compiler

1.4 Theory / Hypothesis


Cyclic redundancy check polynomials are the theory which lie behind the checksum algorithm used in most modern
communication systems. A generator is chosen (using theory which will not be detailed here). This is a sequence of bits,
of which the first and last are 1. This sequence is used with the bits of the message to calculate a check sequence which
has 1 fewer bits than the generator. The check sequence is appended to the original message. At the receiver, the same
calculation is performed on the message and check sequence combined. If the result is 0 no transmission error is
assumed to have occurred.

1.5 Procedure / Program / Activity

 ALGORITHM

4. Given a bit string, append 0S to the end of it (the number of 0s is the same as the degree of the
generator polynomial) let B(x) be the polynomial corresponding to B.
5. Divide B(x) by some agreed on polynomial G(x) (generator polynomial) and determine the remainder
R(x). This division is to be done using Modulo 2 Division.
6. Define T(x) = B(x) –R(x)
7. (T(x)/G(x) => remainder 0)
8. Transmit T, the bit string corresponding to T(x).
9. Let T’ represent the bit stream the receiver gets and T’(x) the associated polynomial. The receiver
divides T1(x) by G(x). If there is a 0 remainder, the receiver concludes T = T’ and no error occurred
otherwise, the receiver concludes an error occurred and requires a retransmission.

 PROGRAM

#include<stdio.h>
#include<string.h>
int main()
{
char Frame[20],Gen[20]="10001000000100001",tData[20]; //Variables
inti,j,k,fLen,gLen,flag=0;
printf("\nEnter the Frame to be Transmitted:"); //Reads Data to be
Transmitted
scanf("%s",Frame);
fLen=strlen(Frame); //Length of Frame
gLen=strlen(Gen); //Length of Generator
strcpy(tData,Frame);
for(i=fLen;i<(fLen+gLen-1);i++)
tData[i]='0'; //Append gLen-1 number of Zeros

Page 42
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

tData[i]='\0'; //Append Null At the end of tData


for(i=0;i<fLen;i++) //Calculate CRC
{
if(tData[i]=='0')
continue;
k=i;
for(j=0;j<gLen;j++,k++)
{
if(tData[k]==Gen[j])
tData[k]='0';
else
tData[k]='1';
}
}
printf("\n\nCRC is: "); //Print CRC
for(i=fLen;i<(fLen+gLen-1);i++)
printf("%c",tData[i]);
tData[i]='\0';
for(i=0;i<fLen;i++)
tData[i]=Frame[i];
printf("\nTransmitted Data is: %s\n\n",tData); //Print Data to Transmitted after
Appending CRC
printf("\n\nEnter the recieved data:");
scanf("%s",tData);
for(i=0;i<fLen;i++) //Calculate CRC at receiver side
{
if(tData[i]=='0')
continue;
k=i;
for(j=0;j<gLen;j++,k++)
{
if(tData[k]==Gen[j])
tData[k]='0';
else
tData[k]='1';
}
}
printf("\n\nCRC is: "); //Print CRC at reciever side
for(i=fLen;i<(fLen+gLen-1);i++)
{
printf("%c",tData[i]);
}
for(i=fLen;i<(fLen+gLen-1);i++)
{
if(tData[i]=='1')
{

Page 43
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

flag=0;
break;
}
}
for(i=0;i<fLen;i++)
tData[i]=Frame[i];
if(flag==1)
printf("\n\nDatarecieved with no error/s\n");
else
printf("\n\nDatarecieved with error/s\n");
}

1.6 Formula / Calculations

Let frame=101
10001000000100001 ) 1010000000000000000
10001000000100001
0010100000010000100
10001000000100001
00101000010100101
Check sum is 0101000010100101

case 1: Let Received codeword is 1010101000010100101


10001000000100001) 1010101000010100101
10001000000100001
0010001000000100001
10001000000100001
00000000000000000
Data is received with no error
case 2: Let Received codeword is 1010101000010100111
10001000000100001) 1010101000010100111
10001000000100001
0010001000000100011
10001000000100001
00000000000000010
Data is received with error

1.7 Results & Analysis

[root@localhost ~]# gcccrc.c


[root@localhost ~]# ./a.out
Enter the Frame to be Transmitted:1001

CRC is: 1001000100101001

Transmitted Data is: 10011001000100101001


Enter the recieved data:10011001000100101001

CRC is: 0000000000000000

Page 44
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Data recieved with error/s

[root@localhost ~]# ./a.out


Enter the Frame to be Transmitted:1001
CRC is: 1001000100101001

Transmitted Data is: 10011001000100101001


Enter the recieved data:10011001000100111001
CRC is: 0000000000010000
Data recieved with error/s

1.8 Outcome & Conclusion

1.9 Remarks

F FACULTY SIGNATURE

1.0 Experiment

Experiment No Date Planed Date Conducted Marks


12

TITLE:
Write a program for congestion control using leaky bucket algorithm.

1.0 Learning Objectives


To understand congestion control mechanisms.

1.2 Aim
Implementation of leaky bucket algorithm is 'C'.

Page 45
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.3 Material / Equipment Required

 Intel based PC
 GCC Compiler

1.4 Theory / Hypothesis


The congesting control algorithms are basically divided into two groups: open loop and closed loop. Open loop
solutions attempt to solve the problem by good design, in essence, to make sure it does not occur in the first place. Once
the system is up and running, mid course corrections are not made. Open loop algorithms are further divided into ones
that act at source versus ones that act at the destination.

In contrast, closed loop solutions are based on the concept of a feedback loop if there is any congestion. Closed loop
algorithms are also divided into two sub categories: explicit feedback and implicit feedback. In explicit feedback
algorithms, packets are sent back from the point of congestion to warn the source. In implicit algorithm, the source
deduces the existence of congestion by making local observation, such as the time needed for acknowledgment to come
back.

Another open loop method to help manage congestion is forcing the packet to be transmitted at a more predictable rate.
This approach to congestion management is widely used in ATM networks and is called traffic shaping.

The other method is the leaky bucket algorithm. Each host is connected to the network by an interface containing a
leaky bucket, that is, a finite internal queue. If a packet arrives at the queue when it is full, the packet is discarded. In
other words, if one or more process are already queued, the new packet is unceremoniously discarded. This arrangement
can be built into the hardware interface or simulate d by the host operating system. In fact it is nothing other than a
single server queuing system with constant service time.

The host is allowed to put one packet per clock tick onto the network. This mechanism turns an uneven flow of packet
from the user process inside the host into an even flow of packet onto the network, smoothing out bursts and greatly
reducing the chances of congestion.

Page 46
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

1.5 Procedure / Program / Activity

 ALGORITHM

1. Start
2. Read number of packets, output rate and bucket size
3. For every packets
4. if packet size + remaining size > bucket size then
5. discard packet
6. else
7. transmit packet till next packet arrives
8. Stop

 PROGRAM

#include<stdio.h>
#include<math.h>
#include<stdlib.h>

intt_rand(int a)
{
intrn;
rn=random()%10;
rn=rn%a;
if(rn==0)
rn=1;
return(rn);
}

int main()
{
int packets[20], n, i, clk, b_size ,o_rate ,p_sz_rm=0, p_sz, p_time;
system("clear");
printf("\n Enter number of packets:");
scanf("%d",&n);
for(i=0;i<n;i++)
packets[i]=t_rand(6)*10;
printf("\n Enter the output rate:");
scanf("%d",&o_rate);
printf("\n Enter the Bucket Size:");
scanf("%d",&b_size);
for(i=0;i<n;i++)
{
if((packets[i]+p_sz_rm)>b_size)
{
if(packets[i]>b_size)
printf("\n Incoming packet size (%d) is Greater than bucket capacity REJECTED",packets[i]);

else

Page 47
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

printf("\nIncomming packet size is (%d) + remaining packet size is Greater than bucket capacity
REJECTED!!",packets[i]);
}
else
{
p_sz=packets[i];
p_sz_rm+=p_sz;
printf("\n Incoming Packet sz:%d",p_sz);
printf("\n Transmission left:%d",p_sz_rm);

p_time=t_rand(5);
printf("\n Next Packet Will come at :%d",p_time);
for(clk=0;clk<=p_time;clk+=1)
{
printf("\n Time Left:%d",p_time-clk);
sleep(1);
if(p_sz_rm)
{
if(p_sz_rm<=o_rate)
{
printf(" - %d Bytes Transmitted!!",p_sz_rm);
p_sz_rm=0;
}
else
{
printf(" - %d Bytes Transmitted!!",o_rate);
p_sz_rm-=o_rate;
}
printf(" - Bytes Remaining:%d",p_sz_rm);
}
else
printf(" - No packets to transmit!!");
}

}
}
printf("\n\n");
return(0);
}

1.6 Results & Analysis


Enter number of packets:5

Enter the output rate:7

Enter the Bucket Size:40

Incoming Packet sz:30


Transmission left:30
Next Packet Will come at :1
Time Left:1 - 7 Bytes Transmitted!! - Bytes Remaining:23
Time Left:0 - 7 Bytes Transmitted!! - Bytes Remaining:16

Page 48
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236

Incoming Packet sz:10


Transmission left:26
Next Packet Will come at :1
Time Left:1 - 7 Bytes Transmitted!! - Bytes Remaining:19
Time Left:0 - 7 Bytes Transmitted!! - Bytes Remaining:12
Incoming Packet sz:10
Transmission left:22
Next Packet Will come at :2
Time Left:2 - 7 Bytes Transmitted!! - Bytes Remaining:15
Time Left:1 - 7 Bytes Transmitted!! - Bytes Remaining:8
Time Left:0 - 7 Bytes Transmitted!! - Bytes Remaining:1
Incoming packet size (50) is Greater than bucket capacity REJECTED
Incoming Packet sz:30
Transmission left:31
Next Packet Will come at :4
Time Left:4 - 7 Bytes Transmitted!! - Bytes Remaining:24
Time Left:3 - 7 Bytes Transmitted!! - Bytes Remaining:17
Time Left:2 - 7 Bytes Transmitted!! - Bytes Remaining:10
Time Left:1 - 7 Bytes Transmitted!! - Bytes Remaining:3
Time Left:0 - 3 Bytes Transmitted!! - Bytes Remaining:0

1.7 Outcome & Conclusion

1.8 Remarks

FACULTY SIGNATURE

Page 49

You might also like