CN Lab Manual ECE 6th Sem
CN Lab Manual ECE 6th Sem
Overview
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
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
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
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.2 Aim
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).
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
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)
Page 7
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
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
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
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
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.2 Aim
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
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
Page 11
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
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.9 Remarks
FACULTY SIGNATURE
1.0 Experiment
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.2 Aim
Intel based PC
NCTUns tool
Word processor
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.
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
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)
Page 16
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
Page 17
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
1.9 Remarks
FACULTY SIGNATURE
1.0 Experiment
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.2 Aim
Intel based PC
NCTUns tool
Word processor
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
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.
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
Page 21
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
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.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
TITLE:
Implement ESS with transmission nodes in Wireless LAN and obtain the performance parameters.
1.2 Aim
To compute the performance of wireless LAN with respect to transmission of packets.
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
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.9 Remarks
FACULTY SIGNATURE
1.0 Experiment
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.
Intel based PC
GCC Compiler
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.
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”
#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);
}
#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);
}
Page 30
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
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
TITLE:
Write a program for distance vector algorithm to find suitable path for transmission.
1.2 Aim
To implement distance vector routing algorithm in 'C'.
Intel based PC
GCC Compiler
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
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.
#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
Page 36
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
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.2 Aim
To implement Dijkstra’s algorithm in 'C'.
Intel based PC
GCC Compiler
Cost Calculation:
Page 38
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
PROGRAM
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
0 8 1 999
8 0 1 1
1 1 0 9
999 1 9 0
Shortest Path:
1 2; Cost: 2
1 3; Cost: 1
1 4; Cost: 3
1.8 Remarks
FACULTY SIGNATURE
1.0 Experiment
TITLE:
Write a program for error detecting code using CRC-CCITT (16- bits).
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
Intel based PC
GCC Compiler
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
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");
}
Let frame=101
10001000000100001 ) 1010000000000000000
10001000000100001
0010100000010000100
10001000000100001
00101000010100101
Check sum is 0101000010100101
Page 44
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
1.9 Remarks
F FACULTY SIGNATURE
1.0 Experiment
TITLE:
Write a program for congestion control using leaky bucket algorithm.
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
Intel based PC
GCC Compiler
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
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);
}
Page 48
Lab Manual - Semester – 6th Sem
Department of Electronics & Communication Engineering, Hirasugar Institute of
Technology, Nidasoshi-591236
1.8 Remarks
FACULTY SIGNATURE
Page 49