0% found this document useful (0 votes)
140 views

DCN Practical File 2024

Uploaded by

mritunjayp8140
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
0% found this document useful (0 votes)
140 views

DCN Practical File 2024

Uploaded by

mritunjayp8140
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
You are on page 1/ 90

Data communication and networking File

By

Name:
Enrollment No:
Branch:

BACHELOR OF TECHNOLOGY
In
ELECTRONICS AND COMMUNICATION ENGINEERING

1
2
INDEX

Inde Name of the Experient Remarks


S.No.

1 Exp – 1(a):Introduction to cisco packet tracer


Exp – 1(b):Installation of cisco packet tracer

2 Exp – 2(a): Introduction of NS-2/NS-3 and its


installation process
Exp – 2(b): Basic commands and properties of
NS-2/NS-3

3 Exp – 3: To study the difference between cross-


over cable, roll- over cable and straight -
through cable.

3
INDEX

4 Exp – 4: To implement a simple LAN between


two computer and to exchange data

5 Exp – 5: To implement Star Topology using hub


as a network device.

6 Exp – 6: To implement bus topology using


hubs.

7 Exp – 7: To implement mesh topology using


switch as network device.

8 Exp – 8: To implement hybrid topology using


hub and switch as network device

4
INDEX

9 Exp – 9: Simulation of address resolution


protocol (ARP) and Internet Control message
protocol (ICMP) using Cisco package tracer.

10 Exp – 10: Connection of Two different LAN


using router

11 Exp-11:To simulate and measure the round-trip


time of communication between an echo client
and server over a point-to-point network link in
an NS-3 network simulation.

12 Exp-12:To simulate a basic point-to-point network


scenario with two nodes, where an echo client on one
node sends a single 1024-byte packet to an echo server
on the other node over a 5 Mbps link with a 2 ms delay.

5
INDEX

Exp-13:To simulate a network topology with a


combination of point-to-point, CSMA, and Wi-Fi
13 connections and measure the performance of UDP echo
communication between various nodes.

Exp-14:To demonstrate how to create a custom


object in NS-3 that can be traced, and it connects a
14 trace function to monitor changes in an integer
value within that object.

Exp-15:To simulate and analyze the behavior of


an ns-3 TCP connection, focusing on monitoring
15
changes in the congestion window and handling
packet drops.

Exp-16:To stimulate and observe changes in ns-3


TCP congestion window and packet drops in a
16 network with a point-to-point connection and
custom applications.

Exp-17:To simulate and analyze the changes in the


ns-3 TCP congestion window, monitor packet
17 drops, and create graphs of packet byte counts over
time in a network with a point-to-point connection
and custom applications.

6
INDEX

18 Exp-18:Wireless router configuration using cisco


packet

7
INTRODUCTION TO CISCO PACKET TRACER

What is Cisco Packet Tracer


Cisco Packet Tracer as the name suggests, is a tool built by Cisco. This tool provides a network
simulation to practice simple and complex networks.
As Cisco believes, the best way to learn about networking is to do it.
The main purpose of Cisco Packet Tracer is to help students learn the principles of networking with
hands-on experience as well as develop Cisco technology specific skills. Since the protocols are
implemented in software only method, this tool cannot replace the hardware Routers or Switches.
Interestingly, this tool does not only include Cisco products but also many more networking devices.
Using this tool is widely encouraged as it is part of the curriculum like CCNA, CCENT where
Faculties use Packet Trace to demonstrate technical concepts and networking systems. Students
complete assignments using this tool, working on their own or in teams.
Engineers prefer to test any protocols on Cisco Packet Tracer before implementing them. Also,
Engineers who would like to deploy any change in the production network prefer to use Cisco Packet
8
Tracer to first test the required changes and proceed to deploy if and only if everything is working as
expected.
This makes the job easier for Engineers allowing them to add or remove simulated network devices,
with a Command line interface and a drag and drop user interface.

Workspace :
Logical:
Logical workspace shows the logical network topology of the network the user has built. It represents
the placing, connecting and clustering virtual network devices.
Physical:
Physical workspace shows the graphical physical dimension of the logical network. It depicts the
scale and placement in how network devices such as routers, switches and hosts would look in a real
environment. It also provides geographical representation of networks, including multiple buildings,
cities and wiring closets.

9
Key Features:

❖ Unlimited devices
❖ E-learning
❖ Customize single/multi user activities
❖ Interactive Environment
❖ Visualizing Networks
❖ Real-time mode and Simulation mode
❖ Self-paced
❖ Supports majority of networking protocols
❖ International language support
❖ Cross platform compatibility

10
EXPERIMENT - 1(a)

AIM: To study the software Cisco Packet Tracer.


SOFTWARE USED: Cisco Packet Tracer 8.0
THEORY: About Cisco Packet Tracer: It is a simulation software, also called ICT (Information
Communication Technology), which provides e-learning of a network tool which provides set up.
Packet tracer provides simulation, visualization, offering, assessment collaboration capabilities to
design complex network architecture.
Packet Trace modes:

1. Real - Time mode: In this, the network behaves as real devices do, with immediate real time
response for all network activities. The real time gives Students a viable alternative lo real
equipment and allows them to gain configuration practice before working with real
equipment.
2. Simulation Mode: In this, the user can see and control time intervals, the inner workings of
data transfer, and the propagation of data across the network. This helps students understand
the fundamental concepts behind network operations. A solid understanding of network
fundamentals can help accelerate learning about related concepts.
The features of Cisco Packet Tracer:

1. Simulates continuous real-time updates of underlying network logic and activities.


2. Empowers students to explore concepts, conduct experiments and tests their understanding.
3. Makes learning easier by providing a realization network simulation and visualization
environment.
DISCUSSIONS: We discussed about the introduction of the software and the evolution of the
versions. The user and applications of the Cisco Packet Tracer was also been discussed.
APPLICATIONS: Packet Tracer is a powerful network simulation platform enabling students to
experiment with network behaviour. It supplements physical example in the classroom by allowing
students to create network with an almost unlimited number of devices discovery and
troubleshooting.

11
Experiment –1(b)

Aim: Installation of Cisco Packet Tracer.

Theory

Cisco Packet Tracer is a network simulation and visualisation tool


developed by Cisco Systems. It is primarily used for teaching and
learning networking concepts, allowing users to create virtual network
environments and simulate network behaviours. Packet Tracer provides
a graphical interface that enables users to design, configure, and
troubleshoot networks without the need for physical hardware.

Key features of the Cisco Packet Tracer include:

1. Network topology creation: Users can create network topologies by


dragging and dropping devices such as routers, switches, PCs, servers,
and more onto a virtual workspace.

2. Device configuration: Users can configure the devices in the


network, including setting IP addresses, enabling routing protocols,
configuring security features, and implementing advanced network
configurations.

3. Network simulation: Packet Tracer simulates network behaviours


and allows users to observe the flow of data packets, inspect network
traffic, and analyse network performance.

4. Protocols and technologies: Packet Tracer supports a wide range of


networking protocols and technologies, including Ethernet, TCP/IP,
routing protocols (e.g., OSPF, EIGRP), switching protocols (e.g.,
VLANs, STP), wireless networking, and security features (e.g.,
12
firewalls, VPNs).

5. Collaboration and learning: Packet Tracer offers collaborative


features that enable users to work together on network projects and
share their work. It is widely

13
used in educational institutions to teach networking concepts and facilitate hands- on learning
experiences.

6. Assessment and evaluation: Packet Tracer includes built-in assessment tools that allow
instructors to create and distribute activities, quizzes, and exams to evaluate students'
understanding of networking concepts and their ability to configure and troubleshoot
networks.

7. Multi-platform support: Cisco Packet Tracer is available for Windows, macOS, and
Linux operating systems, making it accessible to a wide range of users.

Packet Tracer is widely used by networking students, instructors, and professionals to gain
practical experience in designing, configuring, and troubleshooting network environments. It
helps users develop their networking skills in a virtual, risk-free environment before working
with physical network equipment.

Installing Packet Tracer on Linux

1. Download Packet Tracer: Visit the Cisco Networking Academy website


(https://www.netacad.com/) and log in with your account. Navigate to the Packet Tracer
download page and download the Linux version of Packet Tracer. Ensure you select the
appropriate version for your Linux distribution.

2. Open the terminal: Launch the terminal application on your Linux system. You can
usually find it in the applications menu or by pressing Ctrl+Alt+T.

3. Navigate to the directory: Use the `cd` command to navigate to the directory where the
downloaded Packet Tracer file is located. For example, if it's in the Downloads folder, you
can use the following command:

cd ~/Downloads

14
4. Extract the archive: Extract the downloaded Packet Tracer archive using the
`tar` command. Replace `PacketTracer.tar.gz` with the actual name of the
downloaded file.

tar -xvzf PacketTracer.tar.gz

5. Navigate to the extracted directory: Use the `cd` command to navigate to the
extracted Packet Tracer directory.

cd PacketTracer

6. Run the installation script: Execute the installation script with administrative
privileges using the `sudo` command.

sudo ./install

Enter your password when prompted.

7. Follow the on-screen prompts: The installation script will guide you through the
installation process. Read and accept the end-user licence agreement, and follow the
prompts to complete the installation.

8. Launch Packet Tracer: After the installation completes successfully, you can launch
Packet Tracer from the applications menu or by running the following command:

packet
tracer

15
This will start Cisco Packet Tracer on the Linux system.

16
Experiment –2(a)

AIM : Introduction to NS-2/NS-3 and its installation process.

INTRODUCTION
NS-2 is a discrete event Network simulator program, developed at the university of California, NS2 is an open source
discrete event simulator used by the research community for research in network It includes many network objects such
as protocols, applications and traffic source behaviour. NS is a part of software of the VNIT project that is supported by
DARPA since 1995. It has support for both wired and wireless networks and can simulate several network protocols
such as TCP, UDP, multicast routing, etc.. Defining the different agents and their applications like TCP, FTP over TCP,
UDP, CBR and CBR over UDP etc. and Identifying and solving the installation error of NS2. The network simulator is
discrete event packet level simulator. The network simulator covers a very large number of applications of different kind
of protocols of different network types consisting of different network elements and traffic models. Network simulator is
a package of tools that simulates behaviour of networks such as creating network topologies, log events that happen
under any load, analyse the events and understand the network. Well the main aim of our first experiment is to learn how
to use network simulator and to get acquainted with the simulated objects and understand the operations of network
simulation and we also need to analyse the behaviour of the simulation object using network simulation.

Objectives:
• It helps to increase the efficiency of simulation.
• Its is used to provide details of the protocols and their operation.
• It is used to reduce packet and event processing time.
• OTcl helps in the following way:

Add the following lines AT THE END of the file.


Be sure to change "/path_to" to the path of where you have extracted the NS (e.g. '/home/user_name/Documents').
# LD_LIBRARY_PATH OTCL_LIB=/path_to/ns-allinone-2.35/otcl-1.14/ NS2_LIB=/path_to/ns-allinone-2.35/lib/
USR_Local_LIB=/usr/local/lib/ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_ LIB:$NS2_LIB:
$USR_Local_LIB # TCL_LIBRARY TCL_LIB=/path_to/ns-allinone-2.35/tcl8.5.10/library/ USR_LIB=/usr/lib/ export
TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LI B # PATH
17
XGRAPH=/path_to/ns-allinone-2.35/xgraph12.2/:/path_to/ns-allinone-2.35/bin/:/path_to/ns-allinone2.35/tcl8.5.10/
unix/:/path_to/ns-allinone2.35/tk8.5.10/unix/ NS=/path_to/ns-allinone-2.35/ns-2.35/
NAM=/path_to/ns-allinone-2.35/nam-1.15/ export PATH=$PATH:$XGRAPH:$NS:$NAM
Save the file and restart the system, alternatively we can just reload the .bashrc as:
1 source ~/.bashrc now run ns from a terminal window by executing: ns If we receive the "%" sign, it means that NS is
running
1d) Downloading and installing NS-3
The NS-3 Project started around mid-2006 which is still under heavy development NS-3 is a discrete event network
simulator written in C++ with an optional Python scripting API.
It allows researchers to study Internet protocols and large-scale systems in a controlled environment. NS-3 is a new
simulator (not backwards-compatible with NS-2).
It is a free, open source software project organized around research community development and maintenance. NS-3 is
not an extension of ns-2.
It is a new simulator, written from scratch. The project will continue to maintain NS-2 while NS-3 is being built, and will
study transition and integration mechanisms. NS-3 is a free software simulation platform which aims at network
technology and whose source code is open. Researchers can use it easily to develop network technology.NS-3 contains
an abundance of modules, almost relating to all the aspects of network technology.
A tarball is a particular format of software archive where multiple files are bundled together and the archive possibly
compressed. NS-3 software releases are provided via a downloadable tarball. The process for downloading NS-3 via
tarball is simple; you just have to pick a release, download it and decompress it.
1e) Difference between NS-2 and NS-3 The most visible difference between NS-2 and NS-3 is the choice of scripting
language. NS-2 is scripted in OTcl and results of simulations can be visualized using the Network Animator nam[10].
It is not possible to run a simulation in NS -2 purely from C++ (i.e., as a main () program without any OTcl). Moreover,
some components of NS -2 are written in C++ and others in OTcl. In NS-3, the simulator is written entirely in C++, with
optional Python bindings. User code protocols and scenarios also in C++ .
Simulation scripts can therefore be written in C++ or in Python. Furthermore, NS-3 generates pcap packet trace files;
other utilities such as Wireshark can be used to analyze traces as well. NS-3 does not have all of the models that NS-2
currently has, but on the other hand, NS-3 does have new capabilities. Some models from NS-2 have already been ported
from NS-2 to NS-3.

18
19
Experiment –2(b)

Aim : Basic of NS-2 commands and properties.


INTRODUCTION
NS-2 (Network Simulation version 2) : NS2 is an open-source simulation tool that runs on Linux. It
is a discreet event simulator targeted at networking research and provides substantial support for
simulation of routing, multicast protocols and IP protocols, such as UDP, TCP, RTP and SRM over
wired and wireless (local and satellite) networks.
• Widely known as NS2, is simply an event driven simulation tool. Useful in studying the dynamic
nature of communication networks.
• Simulation of wired as well as wireless network functions and protocols (e.g., routing algorithms,
TCP, UDP) can be done using NS2.

• In general, NS2 provides users with a way of specifying such network protocols and simulating
their corresponding behaviors. Basic Architecture of NS2 TCL – Tool Command Language Tcl is a
very simple programming language. If you have programmed before, you can learn enough to write
interesting Tcl programs within a few hours. This page provides a quick overview of the main features
of Tcl. After reading this you'll probably be able to start writing simple Tcl scripts on your own;
however, we recommend that you consult one of the many available Tcl books for more complete
information.
20
TCL – Tool Command Language Tcl is a very simple programming language. If you have
programmed before, you can learn enough to write interesting Tcl programs within a few hours. This
page provides a quick overview of the main features of Tcl. After reading this you'll probably be able
to start writing simple Tcl scripts on your own; however, we recommend that you consult one of the
many available Tcl books for more complete information.
Basic syntax Tcl scripts are made up of commands separated by newlines or semicolons. Commands
all have the same basic form illustrated by the following example:
expr 20 + 10
This command computes the sum of 20 and 10 and returns the result,
30.
You can try out this example and all the others in this page by typing them to a Tcl application such as
tclsh; after a command completes, tclsh prints its result.
Each Tcl command consists of one or more words separated by spaces.
In this example there are four words: expr, 20, +, and 10.
The first word is the name of a command and the other words are arguments to that command. All Tcl
commands consist of words, but different commands treat their arguments differently.
The expr command treats all of its arguments together as an arithmetic expression, computes the
result of that expression, and returns the result as a string. In the expr command the division into
words isn't significant: you could just as easily have invoked the same command as expr 20+10
However, for most commands the word structure is important, with each word used for a distinct
purpose. All Tcl commands return results. If a command has no meaningful result then it returns an
empty string as its result. Variables Tcl allows you to store values in variables and use the values later
in commands. The set command is used to write and read variables. For example, the following
command modifies the variable x to hold the value 32: set x 32 The command returns the new value
of the variable. You can read the value of a variable by invoking set with only a single argument:
set x
You don't need to declare variables in Tcl: a variable is created automatically the first time it is set.
Tcl variables don't have types: any variable can hold any value. To use the value of a variable in a
command, use variable substitution as in the following example:
expr $x*3
When a $ appears in a command, Tcl treats the letters and digits following it as a variable name, and
substitutes the value of the variable in place of the name.
In this example, the actual argument received by the expr command will be 32*3 (assuming that
variable x was set as in the previous example).
You can use variable substitution in any word of any command, or even multiple times within a word:
set cmd expr set x 11 $cmd $x*$x
Command substitution
You can also use the result of one command in an argument to another command. This is called
command substitution: set a 44 set b [expr $a*4] When a [ appears in a command, Tcl treats
everything between it and the matching ] as a nested Tcl command.
21
Tcl evaluates the nested command and substitutes its result into the enclosing command in place of
the bracketed text. In the example above the second argument of the second set command will be 176.
Quotes and braces Double-quotes allow you to specify words that contain spaces. For example,
consider the following script: set x 24 set y 18

set z "$x + $y is [expr $x + $y]"


After these three commands are evaluated variable z will have the value 24 + 18 is 42. Everything
between the quotes is passed to the set command as a single word.
Note that (a) command and variable substitutions are performed on the text between the quotes, and
(b) the quotes themselves are not passed to the command.
If the quotes were not present, the set command would have received 6 arguments, which would have
caused an error. Curly braces provide another way of grouping information into words.
They are different from quotes in that no substitutions are performed on the text between the curly
braces: set z {$x + $y is [expr $x + $y]}
This command sets variable z to the value "$x + $y is [expr $x + $y]".
Control structures Tcl provides a complete set of control structures including commands for
conditional execution, looping, and procedures.
Tcl control structures are just commands that take Tcl scripts as arguments. The example below
creates a Tcl procedure called power, which raises a base to an integer power: proc power {base p}
{ set result 1 while {$p > 0} { set result [expr $result * $base] set p [expr $p - 1] } return $result }
This script consists of a single command, proc.
The proc command takes three arguments: the name of a procedure, a list of argument names, and the
body of the procedure, which is a Tcl script.
Note that everything between the curly brace at the end of the first line and the curly brace on the last
line is passed verbatim to proc as a single argument.
The proc command creates a new Tcl command named power that takes two arguments. You can
then invoke power with commands like the following: power 2 6 power 1.15 5 When power is
invoked, the procedure body is evaluated.
While the body is executing it can access its arguments as variables: base will hold the first argument
and p will hold the second. The body of the power procedure contains three Tcl commands: set, while,
and return. The while command does most of the work of the procedure. It takes two arguments, an
expression ($p > 0) and a body, which is another Tcl script.
The while command evaluates its expression argument using rules similar to those of the C
programming language and if the result is true (nonzero) then it evaluates the body as a Tcl script. It
repeats this process over and over until eventually the expression evaluates to false (zero).

22
In this case the body of the while command multiplied the result value by base and then decrements p.
When p reaches zero the result contains the desired power of base. The return command causes the
procedure to exit with the value of variable result as the procedure's result.
Where do commands come from?
As you have seen, all of the interesting features in Tcl are represented by commands. Statements are
commands, expressions are evaluated by executing commands, control structures are commands, and
procedures are commands.
Tcl commands are created in three ways. One group of commands is provided by the Tcl interpreter
itself. These commands are called builtin commands. They include all of the commands you have
seen so far and many more (see below). The builtin commands are present in all Tcl applications. The
second group of commands is created using the Tcl extension mechanism.
Tcl provides APIs that allow you to create a new command by writing a command procedure in C or
C++ that implements the command.
You then register the command procedure with the Tcl interpreter by telling Tcl the name of the
command that the procedure implements.
In the future, whenever that particular name is used for a Tcl command, Tcl will call your command
procedure to execute the command. The builtin commands are also implemented using this same
extension mechanism; their command procedures are simply part of the Tcl library. When Tcl is used
inside an application, the application incorporates its key features into Tcl using the extension
mechanism. Thus the set of available Tcl commands varies from application to application. There are
also numerous extension packages that can be incorporated into any Tcl application. One of the best
known extensions is Tk, which provides powerful facilities for building graphical user interfaces.
Other extensions provide object-oriented programming, database access, more graphical capabilities,
and a variety of other features. One of Tcl's greatest advantages for building integration applications is
the ease with which it can be extended to incorporate new features or communicate with other
resources. The third group of commands consists of procedures created with the proc command, such
as the power command created above. Typically, extensions are used for lower-level functions where
C programming is convenient, and procedures are used for higher-level functions where it is easier to
write in Tcl.
Wired TCL Script Components
• Create the event scheduler
• Open new files & turn on the tracing
• Create the nodes
• Setup the links
• Configure the traffic type (e.g., TCP, UDP, etc)
• Set the time of traffic generation (e.g., CBR, FTP)
• Terminate the simulation UTKARSH, ECE-6A, 20113302818 16 Data Communication and
Network
• NS Simulator Preliminaries.
• Initialization and termination aspects of the ns simulator.
23
• Definition of network nodes, links, queues and topology.
• Definition of agents and of applications.
• The nam visualization tool.
• Tracing and random variables. Features of NS2 NS2 can be employed in most unix systems and
windows. Most of the NS2 code is in C++. It uses TCL as its scripting language, Otcl adds object
orientation to TCL.NS(version 2) is an object oriented, discrete event driven network simulator that is
freely distributed and open source.
• Traffic Models: CBR, VBR, Web etc
• Protocols: TCP, UDP, HTTP, Routing algorithms,MAC etc
• Error Models: Uniform, bursty etc
• Misc: Radio propagation, Mobility models , Energy Models
• Topology Generation tools
• Visualization tools (NAM), Tracing Structure of NS
● NS is an object oriented discrete event simulator. o Simulator maintains list of events and executes
one event after another o Single thread of control: no locking or race conditions
● Back end is C++ event scheduler. o Protocols mostly o Fast to run, more control
• Front end is OTCL o Creating scenarios, extensions to C++ protocols
Data Communication and Network Platforms
It can be employed in most unix systems(FreeBSD, Linux, Solaris) and Windows. Source code Most
of NS2 code is in C++ Scripting language It uses TCL as its scripting language OTcl adds object
orientation to TCL. Protocols implemented in NS2
• Transport layer(Traffic Agent) – TCP, UDP.
• Network layer(Routing agent)
• Interface queue – FIFO queue, Drop Tail queue, Priority queue
• Logic link contol layer – IEEE 802.2, AR How to use NS2
• Design Simulation.
• Determine simulation scenario.
• Build ns-2 script using tcl.
• Run simulation Simulation with NS2
• Define objects of simulation. Connect the objects to each other
• Start the source applications. Packets are then created and are transmitted through network.
• Exit the simulator after a certain fixed time. NS programming Structure
• Create the event scheduler
• Turn on tracing
24
• Create network topology
• Create transport connections
• Generate traffic
• Insert errors
Data Communication and Network Commands in NS-2:
1.SET COMMAND: set a 8 set b [expr $a/8] EXPLANATION: In the first line, the variable a is
assigned the value 8. In the second line, the result of the command [expr $a/8], which equals 1, is then
used as an argument to another command, which in turn assigns a value to the variable b.
The “$” sign is used to obtain a value contained in a variable and square brackets are an indication of
a command substitution
2.PROC COMMAND: proc factorial fact { if {$fact <= 1} { return 1 } expr $fact * [factorial [expr
$fact-1]] }
3.OPEN FILE COMMAND: set testfile [open hello.dat r]
4.TO WRITE DATA INTO THE FILE: set testfile [open hello.dat w] puts $testfile “hello1”
5.EXEC COMMAND: exec rm $testfile
6.ADDING NEW SIMULATION: set ns [new Simulator] Data Communication and Network
7.CREATING NODES: set n0 [$ns node]
8.CBR TRAFFIC SOURC USING UDP: set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 set
cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 $cbr0 set packet_size_ 512 9.FTP
TRAFFIC SOURCE USING TCP: set tcp0 [new Agent/TCP] $ns attach-agent $n0 $tcp0 set ftp0
[new Application/FTP] $ftp0 attach-agent $tcp0 $tcp0 set packet_size_ 512

25
EXPERIMENT - 3

AIM: To study the difference between cross- over cable, roll- over cable and straight -through cable.
SOFTWARE USED: Cisco Packet Tracer 8.0
THEORY:
Cross- Over Cables: An ethernet cross-over cable is a type of ethernet cable to connect computing
devices together directly. Normally, straight through cables were used to connect from a host network
interface controller to a network switch, hub or router.
Uses:

• Two devices in the same Category use a Cross-over cable.


• These are most widely used to Connect two hosts directly.
• Some connections standards use different balanced pairs to transmit data so cross-over cables
for them have different configuration to swap the transmit and receiver pairs.
Straight through Cables: This is a type of twisted pair cable for local area network use for which
the RI-45 connectors at each time and have the same pin out (i.e., a management of conductors).
Uses:

• Straight through cables are used for connecting unlike devices.


• It is used in the following situations-
1. Connecting a computer to switch.
2. Connecting a router to a hub.
3. Connecting a LAN port to a switch, hub or computer.
• Most commonly used to connect a host to client.

26
Rollover cables: This is a type of null modem cable that is often used to connect a computer terminal
to a routers console part. This cable typically flat to gelp distinguish it from other types of networking
cabling.
Uses:

• They primarily connect a device to a switch or router’s console part. This permits on engineer
or programmer to connect the network device and manipulate the programming as required.
• Although many networks programming task can be centrally completed there remains the
need for technicians to use rollover cables for network hardware upgrades, maintenance and
troubleshooting.
• Rollover cables are not intended to carry data but instead create and interface with the device.
DISCUSSIONS: We discussed about different types of wires to be used for connecting any two
systems and its applications.

27
APPLICATIONS:

1. Straight-through cable is used to connect computer and other end-devices to networking


devices such as hubs and switches.
2. Rollover cable is used to connect a computer terminal to a router’s port.
3. Crossover cable is used to connect two devices of the same type.

28
EXPERIMENT -4
Aim: to implement a simple LAN between two computer and to exchange data
Software used: Cisco Packet Tracer 8.0
Theory: local area network :it is a computer network that interconnects computer within a limited
area since as residence ,school, university campus or an office building .
IP Address: An internet protocol address is a numerical label assigned to each device connected to a
computer network that used the internet protocol for communication . it is the logical address
assigned to a computer .
Procedure:
1)open the cisco packet tracer software
2)then select two devices from end devices and drag and drop in the logicval area
3)now, click on each system and go to IP configuration settings to assign each system its IP address.
4)then, select wires from connecting devices ,xselect automatically choose wire and then right click
on first device .
5)if green dots occur on the wire,it means a LAN network has been established .
6)then,click on system,left click and go to command prompt and write command ping with IP address
of second system. Press enter and simulation window will open and will show that data has been
exchanged between the computers .

Discussions: We discussed about loacl area network and how to exchange data between two systems
in LAN using Cisco Packet Tracer .
Applications:
1)Personal computer LAN’s
2)Low cost
3)Limited data rate
4)High Speed office networks
Result: A simple LAN between two computer has been implemented.

29
Simulation:

30
EXPERIMENT - 5

AIM: To implement Star Topology using hub as a network device.


SOFTWARE USED: Cisco Packet Tracer 8.0
THEORY:
A Star topology is a network topology in which each network component is physically. connected to
a central node such as a router, hub of switch.
A hub is a physical layer networking device which is used to connect multiple devices in a
network. They used to connect Computers in Q LAN, A hob a are generally
has man be connected poste in it. A computer which intends to be connected to the network is
plugged in to one of these ports.

PROCEDURE:

1. Open Cisco Packet Tracer and take hub and place it.
2. Take 5 generic computer with hub at centre.
3. Connect each with hub using straight through wire.
4. Set IP address of each of generic Computer.
5. Take message and set the source and destination.
6. In simulation node, click on Starts play and Simulation.

RESULT:

Star Topology using hub is implemented correctly.

31
Simulation:

32
EXPERIMENT – 6

Aim: To implement bus topology using hubs.

Software used: Cisco packet tracer 8.0

Theory:
Bus topology is a network type in which every computer and network device is
connected to a single cable. It transmits the data from one end to another in a single
direction.
A hub is a physical layer networking device which is used to connect multiple devices in
a network. They are generally used to connect computers in a lan. A hub has many ports
in it.

Procedure:
1) Open cisco packet tracer and take 3 hubs and place them.
2) Take 6 generic computers.
3) Connect two computers with one hub using copper straight wire and also connect the
hubs with one another using copper cross-over wire.
4) Set ip of each generic computer.
5) Take a message and set the source and destination.
6) In the simulation node, click on play and simulation starts.

Result:
Bus topology using hubs is implemented correctly.

33
Simulation:

34
EXPERIMENT - 7

Aim: To implement mesh topology using a switch as a network device.

Software used: Cisco packet tracer 8.0.

Theory:
In mesh topology, every device is connected to another device via a particular channel.
A switch is a data link layer networking device which connects devices in a network and
uses packet switching to send and receive data over the network. Like a hub, a switch
also has many ports, to which computers are plugged in. However, when a data frame
arrives at any port of a switch, it examines the destination address and sends the frame to
the corresponding device. Thus, it supports both unicast and multicast communication.

Procedure:
1) Open Cisco packet tracer and take 4 switches and place them.
2) Take 7 generic computers.
3) Connect two computers with one switch using copper straight through wire and also
connect the switches with one another using copper cross-over wire.
4) Set the ip address of each generic computer.
5) Take a message and set the source and destination.
6) In the simulation node, click on play simulation starts.

35
Result:
Mesh topology using switch as a networking device is implemented correctly.

36
Simulation:

37
EXPERIMENT - 8

Aim: To implement hybrid topology using hub and switch as network device

Software used: Cisco packet tracer 8.0

Theory:
Hybrid topology is the combination of two or more different topologies .A hub is a physical layer
networking device in a network. They are generally used to connect computers in a lan . A hub
has many ports in it .
A switch is a data link layer networking device which connects devices in a network and uses the
network. Like a hub a switch also has many ports , to which computers are plugged in. However,
when a data frame arrives at any port of a switch it examines the destination address and switch it
examines the destination address and sends the frame to the corresponding device.

Procedure:
1) Open Cisco packet tracer and take switch , hub and generic computer.
2) Make star ,bus and mesh topology and connect the switches and hubs of these topologies
with each other to make hybrid topology using cross over wire .
3) In simulation mode , click on play and simulation starts.

Result:
Hybrid topology using hub and switch as network device is implemented correctly

38
Simulation:

39
EXPERIMENT - 9

Aim:
Simulation of address resolution protocol (ARP) and Internet Control message protocol (ICMP)
using Cisco package tracer.

Software used: Cisco Package Tracer 8.0

Theory:
Address Resolution Protocol is a protocol for mapping a dynamic IP address to a permanent physical
machine address in local area network (LAN).The physical machine address is also known as a
media access control mac address. The job of ARP is essentially to translate 32-bit addresses to 48 bit
addresses and vice versa. This is necessary because IP addresses in Io version 4 are 32 bits , but
MAC addresses are 48 bits.

Internet Control Message Protocol is a supporting Protocol suite. It is used by network devices ,
including routers , to indicate success or failure when communicating with another IP address.

Result:
The simulation of address resolution Protocol (ARP) and Internet Control Message Protocol (ICMP)
is implemented correctly.

40
Simulation:

41
42
EXPERIMENT - 10

Aim:
Connection of Two different LAN using router

Software used:
Cisco Packet Tracer 8.0

Theory:
A Local area (LAN) is a collection of devices connected together in one physical location,
such as a building , office or home . A LAN can be small or large , ranging from a home
network with one user to an enterprise network with thousands of users and devices in an
office or school . Regardless of the size of a LAN , A LAN’s single defining characteristic is
that it connects devices that are in a single , limited area.

A router is a physical or virtual appliance that passes information between two or more
packet - switched computer networks . A router inspects a given data packet’s destination
Internet Protocol Address (IP address) , calculates the best way for it to reach its destination
and then forwards it accordingly.

Result: Connection of two different LAN using router is implemented correctly.

43
Simulation:

44
Experiment- 11

Aim
To simulate and measure the round-trip time of communication between an echo client and
server over a point-to-point network link in an NS-3 network simulation.

Code
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”

Using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“FirstScriptExample”);

Int
Main (int argc, char *argv[])
{
CommandLine cmd;
Cmd.Parse (argc, argv);

Time::SetResolution (Time::NS);
LogComponentEnable (“UdpEchoClientApplication”, LOG_LEVEL_INFO);
LogComponentEnable (“UdpEchoServerApplication”,
LOG_LEVEL_INFO);

NodeContainer nodes;
Nodes.Create (2);

PointToPointHelper pointToPoint;

45
pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));
pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));

NetDeviceContainer devices;
Devices = pointToPoint.Install (nodes);

InternetStackHelper stack;
Stack.Install (nodes);

Ipv4AddressHelper address;
Address.SetBase (“10.1.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer interfaces = address.Assign (devices);

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));


serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);


echoClient.SetAttribute (“MaxPackets”, UintegerValue (1));
echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));
echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));

ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));


clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));

Simulator::Run ();
Simulator::Destroy ();
Return 0;
}

46
OUTPUT

Result
We have simulate and measure the round-trip time of communication between an echo
client and server over a point-to-point network link in an NS-3 network simulation.

47
Experiment- 12
Aim
To simulate a basic point-to-point network scenario with two nodes, where an echo client on
one node sends a single 1024-byte packet to an echo server on the other node over a 5 Mbps
link with a 2 ms delay.

Code
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”

Using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“FirstScriptExample”);

Int
Main (int argc, char *argv[])
{
CommandLine cmd;
Cmd.Parse (argc, argv);

Time::SetResolution (Time::NS);
LogComponentEnable (“UdpEchoClientApplication”, LOG_LEVEL_INFO);
LogComponentEnable (“UdpEchoServerApplication”, LOG_LEVEL_INFO);

NodeContainer nodes;
Nodes.Create (2);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));

48
pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));

NetDeviceContainer devices;
Devices = pointToPoint.Install (nodes);

InternetStackHelper stack;
Stack.Install (nodes);

Ipv4AddressHelper address;
Address.SetBase (“10.1.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer interfaces = address.Assign (devices);

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));


serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);


echoClient.SetAttribute (“MaxPackets”, UintegerValue (1));
echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));
echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));

ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));


clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));

Simulator::Run ();
Simulator::Destroy ();
Return 0;
}

49
OUTPUT

Result
We have simulate a basic point-to-point network scenario with two nodes, where an echo
client on one node sends a single 1024-byte packet to an echo server on the other node over a
5 Mbps link with a 2 ms delay.

50
Experiment-13
Aim
To simulate a network topology with a combination of point-to-point, CSMA, and Wi-Fi
connections and measure the performance of UDP echo communication between various
nodes.

Code
#include “ns3/core-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/network-module.h”
#include “ns3/applications-module.h”
#include “ns3/mobility-module.h”
#include “ns3/csma-module.h”
#include “ns3/internet-module.h”
#include “ns3/yans-wifi-helper.h”
#include “ns3/ssid.h”

// Default Network Topology


//
// Wifi 10.1.3.0
// AP
// * * * *
// | | | | 10.1.1.0
// n5 n6 n7 n0 -------------- n1 n2 n3 n4
// point-to-point | | | |
// ================
// LAN 10.1.2.0

Using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“ThirdScriptExample”);

Int
Main (int argc, char *argv[])
{
Bool verbose = true;
Uint32_t nCsma = 3;
Uint32_t nWifi = 3;

51
Bool tracing = false;

CommandLine cmd;
Cmd.AddValue (“nCsma”, “Number of \”extra\” CSMA nodes/devices”, nCsma);
Cmd.AddValue (“nWifi”, “Number of wifi STA devices”, nWifi);
Cmd.AddValue (“verbose”, “Tell echo applications to log if true”, verbose);
Cmd.AddValue (“tracing”, “Enable pcap tracing”, tracing);

Cmd.Parse (argc,argv);

// The underlying restriction of 18 is due to the grid position


// allocator’s configuration; the grid layout will exceed the
// bounding box if more than 18 nodes are provided.
If (nWifi > 18)
{
Std::cout << “nWifi should be 18 or less; otherwise grid layout exceeds the bounding
box” << std::endl;
Return 1;
}

If (verbose)
{
LogComponentEnable (“UdpEchoClientApplication”, LOG_LEVEL_INFO);
LogComponentEnable (“UdpEchoServerApplication”, LOG_LEVEL_INFO);
}

NodeContainer p2pNodes;
P2pNodes.Create (2);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));
pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));

NetDeviceContainer p2pDevices;
P2pDevices = pointToPoint.Install (p2pNodes);

NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);

52
CsmaHelper csma;
Csma.SetChannelAttribute (“DataRate”, StringValue (“100Mbps”));
Csma.SetChannelAttribute (“Delay”, TimeValue (NanoSeconds (6560)));

NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);

NodeContainer wifiStaNodes;
wifiStaNodes.Create (nWifi);
NodeContainer wifiApNode = p2pNodes.Get (0);

YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();


YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
Phy.SetChannel (channel.Create ());

WifiHelper wifi;
Wifi.SetRemoteStationManager (“ns3::AarfWifiManager”);

WifiMacHelper mac;
Ssid ssid = Ssid (“ns-3-ssid”);
Mac.SetType (“ns3::StaWifiMac”,
“Ssid”, SsidValue (ssid),
“ActiveProbing”, BooleanValue (false));

NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, wifiStaNodes);

mac.SetType (“ns3::ApWifiMac”,
“Ssid”, SsidValue (ssid));

NetDeviceContainer apDevices;
apDevices = wifi.Install (phy, mac, wifiApNode);

MobilityHelper mobility;

Mobility.SetPositionAllocator (“ns3::GridPositionAllocator”,
“MinX”, DoubleValue (0.0),
“MinY”, DoubleValue (0.0),

53
“DeltaX”, DoubleValue (5.0),
“DeltaY”, DoubleValue (10.0),
“GridWidth”, UintegerValue (3),
“LayoutType”, StringValue (“RowFirst”));

Mobility.SetMobilityModel (“ns3::RandomWalk2dMobilityModel”,
“Bounds”, RectangleValue (Rectangle (-50, 50, -50, 50)));
Mobility.Install (wifiStaNodes);

Mobility.SetMobilityModel (“ns3::ConstantPositionMobilityModel”);
Mobility.Install (wifiApNode);

InternetStackHelper stack;
Stack.Install (csmaNodes);
Stack.Install (wifiApNode);
Stack.Install (wifiStaNodes);

Ipv4AddressHelper address;

Address.SetBase (“10.1.1.0”, “255.255.255.0”);


Ipv4InterfaceContainer p2pInterfaces;
P2pInterfaces = address.Assign (p2pDevices);

Address.SetBase (“10.1.2.0”, “255.255.255.0”);


Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);

address.SetBase (“10.1.3.0”, “255.255.255.0”);


address.Assign (staDevices);
address.Assign (apDevices);

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));


serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);


echoClient.SetAttribute (“MaxPackets”, UintegerValue (1));

54
echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));
echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));

ApplicationContainer clientApps =
echoClient.Install (wifiStaNodes.Get (nWifi – 1));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

Simulator::Stop (Seconds (10.0));

If (tracing == true)
{
pointToPoint.EnablePcapAll (“third”);
phy.EnablePcap (“third”, apDevices.Get (0));
csma.EnablePcap (“third”, csmaDevices.Get (0), true);
}

Simulator::Run ();
Simulator::Destroy ();
Return 0;
}

OUTPUT

55
Result
We have simulate a network topology with a combination of point-to-point, CSMA, and Wi-
Fi connections and measure the performance of UDP echo communication between various
nodes.

56
Experiment 14
Aim
To demonstrate how to create a custom object in NS-3 that can be traced, and it connects a
trace function to monitor changes in an integer value within that object.

Code
#include “ns3/object.h”
#include “ns3/uinteger.h”
#include “ns3/traced-value.h”
#include “ns3/trace-source-accessor.h”

#include <iostream>

Using namespace ns3;

Class MyObject : public Object


{
Public:
/**
* Register this type.
* \return The TypeId.
*/
Static TypeId GetTypeId (void)
{
Static TypeId tid = TypeId (“MyObject”)
.SetParent<Object> ()
.SetGroupName (“Tutorial”)
.AddConstructor<MyObject> ()
.AddTraceSource (“MyInteger”,
“An integer value to trace.”,
MakeTraceSourceAccessor (&MyObject::m_myInt),
“ns3::TracedValueCallback::Int32”)
;
Return tid;
}

MyObject () {}
TracedValue<int32_t> m_myInt;

57
};

Void
IntTrace (int32_t oldValue, int32_t newValue)
{
Std::cout << “Traced “ << oldValue << “ to “ << newValue << std::endl;
}

Int
Main (int argc, char *argv[])
{
Ptr<MyObject> myObject = CreateObject<MyObject> ();
myObject->TraceConnectWithoutContext (“MyInteger”, MakeCallback (&IntTrace));

myObject->m_myInt = 1234;
}

OUTPUT

Result
We have demonstrated how to create a custom object in NS-3 that can be traced, and it
connects a trace function to monitor changes in an integer value within that object.

58
Experiment-15
Aim
To simulate and analyze the behavior of an ns-3 TCP connection, focusing on monitoring
changes in the congestion window and handling packet drops.

Code
#include <fstream>
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”

59
#include “ns3/applications-module.h”

Using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“FifthScriptExample”);

//
==================================================================
=========
//
// node 0 node 1
// +----------------+ +----------------+
// | ns-3 TCP | | ns-3 TCP |
// +----------------+ +----------------+
// | 10.1.1.1 | | 10.1.1.2 |
// +----------------+ +----------------+
// | point-to-point | | point-to-point |
// +----------------+ +----------------+
// | |
// +---------------------+
// 5 Mbps, 2 ms
//
//
// We want to look at changes in the ns-3 TCP congestion window. We need
// to crank up a flow and hook the CongestionWindow attribute on the socket
// of the sender. Normally one would use an on-off application to generate a
// flow, but this has a couple of problems. First, the socket of the on-off
// application is not created until Application Start time, so we wouldn’t be
// able to hook the socket (now) at configuration time. Second, even if we
// could arrange a call after start time, the socket is not public so we
// couldn’t get at it.
//
// So, we can cook up a simple version of the on-off application that does what
// we want. On the plus side we don’t need all of the complexity of the on-off
// application. On the minus side, we don’t have a helper, so we have to get
// a little more involved in the details, but this is trivial.
//
// So first, we create a socket and do the trace connect on it; then we pass
// this socket into the constructor of our simple application which we then

60
// install in the source node.
//
==================================================================
=========
//
Class MyApp : public Application
{
Public:

MyApp ();
Virtual ~MyApp();

Void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets,
DataRate dataRate);

Private:
Virtual void StartApplication (void);
Virtual void StopApplication (void);

Void ScheduleTx (void);


Void SendPacket (void);

Ptr<Socket> m_socket;
Address m_peer;
Uint32_t m_packetSize;
Uint32_t m_nPackets;
DataRate m_dataRate;
EventId m_sendEvent;
Bool m_running;
Uint32_t m_packetsSent;
};

MyApp::MyApp ()
: m_socket (0),
M_peer (),
M_packetSize (0),
M_nPackets (0),
M_dataRate (0),
M_sendEvent (),

61
M_running (false),
M_packetsSent (0)
{
}

MyApp::~MyApp()
{
M_socket = 0;
}

Void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t
nPackets, DataRate dataRate)
{
M_socket = socket;
M_peer = address;
M_packetSize = packetSize;
M_nPackets = nPackets;
M_dataRate = dataRate;
}

Void
MyApp::StartApplication (void)
{
M_running = true;
M_packetsSent = 0;
M_socket->Bind ();
M_socket->Connect (m_peer);
SendPacket ();
}

Void
MyApp::StopApplication (void)
{
M_running = false;

If (m_sendEvent.IsRunning ())
{
Simulator::Cancel (m_sendEvent);

62
}

If (m_socket)
{
M_socket->Close ();
}
}

Void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
M_socket->Send (packet);

If (++m_packetsSent < m_nPackets)


{
ScheduleTx ();
}
}

Void
MyApp::ScheduleTx (void)
{
If (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate
())));
M_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}
}

Static void
CwndChange (uint32_t oldCwnd, uint32_t newCwnd)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << “\t” << newCwnd);
}

Static void
RxDrop (Ptr<const Packet> p)

63
{
NS_LOG_UNCOND (“RxDrop at “ << Simulator::Now ().GetSeconds ());
}

Int
Main (int argc, char *argv[])
{
CommandLine cmd;
Cmd.Parse (argc, argv);

NodeContainer nodes;
Nodes.Create (2);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));
pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));

NetDeviceContainer devices;
Devices = pointToPoint.Install (nodes);

Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ();


Em->SetAttribute (“ErrorRate”, DoubleValue (0.00001));
Devices.Get (1)->SetAttribute (“ReceiveErrorModel”, PointerValue (em));

InternetStackHelper stack;
Stack.Install (nodes);

Ipv4AddressHelper address;
Address.SetBase (“10.1.1.0”, “255.255.255.252”);
Ipv4InterfaceContainer interfaces = address.Assign (devices);

Uint16_t sinkPort = 8080;


Address sinkAddress (InetSocketAddress (interfaces.GetAddress (1), sinkPort));
PacketSinkHelper packetSinkHelper (“ns3::TcpSocketFactory”, InetSocketAddress
(Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1));
sinkApps.Start (Seconds (0.));
sinkApps.Stop (Seconds (20.));

64
Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (nodes.Get (0),
TcpSocketFactory::GetTypeId ());
Ns3TcpSocket->TraceConnectWithoutContext (“CongestionWindow”, MakeCallback
(&CwndChange));

Ptr<MyApp> app = CreateObject<MyApp> ();


App->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate (“1Mbps”));
Nodes.Get (0)->AddApplication (app);
App->SetStartTime (Seconds (1.));
App->SetStopTime (Seconds (20.));

Devices.Get (1)->TraceConnectWithoutContext (“PhyRxDrop”, MakeCallback


(&RxDrop));

Simulator::Stop (Seconds (20));


Simulator::Run ();
Simulator::Destroy ();

Return 0;
}

OUTPUT

65
Result
We have simulate and analyze the behavior of an ns-3 TCP connection, focusing on
monitoring changes in the congestion window and handling packet drops.

Experiment-16
Aim

66
To stimulate and observe changes in ns-3 TCP congestion window and packet drops in a
network with a point-to-point connection and custom applications.

Code
#include <fstream>
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”

Using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“SixthScriptExample”);

//
==================================================================
=========
//
// node 0 node 1
// +----------------+ +----------------+
// | ns-3 TCP | | ns-3 TCP |
// +----------------+ +----------------+
// | 10.1.1.1 | | 10.1.1.2 |
// +----------------+ +----------------+
// | point-to-point | | point-to-point |
// +----------------+ +----------------+
// | |
// +---------------------+
// 5 Mbps, 2 ms
//
//
// We want to look at changes in the ns-3 TCP congestion window. We need
// to crank up a flow and hook the CongestionWindow attribute on the socket
// of the sender. Normally one would use an on-off application to generate a
// flow, but this has a couple of problems. First, the socket of the on-off
// application is not created until Application Start time, so we wouldn’t be
// able to hook the socket (now) at configuration time. Second, even if we
// could arrange a call after start time, the socket is not public so we

67
// couldn’t get at it.
//
// So, we can cook up a simple version of the on-off application that does what
// we want. On the plus side we don’t need all of the complexity of the on-off
// application. On the minus side, we don’t have a helper, so we have to get
// a little more involved in the details, but this is trivial.
//
// So first, we create a socket and do the trace connect on it; then we pass
// this socket into the constructor of our simple application which we then
// install in the source node.
//
==================================================================
=========
//
Class MyApp : public Application
{
Public:
MyApp ();
Virtual ~MyApp ();

/**
* Register this type.
* \return The TypeId.
*/
Static TypeId GetTypeId (void);
Void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets,
DataRate dataRate);

Private:
Virtual void StartApplication (void);
Virtual void StopApplication (void);

Void ScheduleTx (void);


Void SendPacket (void);

Ptr<Socket> m_socket;
Address m_peer;
Uint32_t m_packetSize;
Uint32_t m_nPackets;

68
DataRate m_dataRate;
EventId m_sendEvent;
Bool m_running;
Uint32_t m_packetsSent;
};

MyApp::MyApp ()
: m_socket (0),
M_peer (),
M_packetSize (0),
M_nPackets (0),
M_dataRate (0),
M_sendEvent (),
M_running (false),
M_packetsSent (0)
{
}

MyApp::~MyApp ()
{
M_socket = 0;
}

/* static */
TypeId MyApp::GetTypeId (void)
{
Static TypeId tid = TypeId (“MyApp”)
.SetParent<Application> ()
.SetGroupName (“Tutorial”)
.AddConstructor<MyApp> ()
;
Return tid;
}

Void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t
nPackets, DataRate dataRate)
{
M_socket = socket;

69
M_peer = address;
M_packetSize = packetSize;
M_nPackets = nPackets;
M_dataRate = dataRate;
}

Void
MyApp::StartApplication (void)
{
M_running = true;
M_packetsSent = 0;
M_socket->Bind ();
M_socket->Connect (m_peer);
SendPacket ();
}

Void
MyApp::StopApplication (void)
{
M_running = false;

If (m_sendEvent.IsRunning ())
{
Simulator::Cancel (m_sendEvent);
}

If (m_socket)
{
M_socket->Close ();
}
}

Void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
M_socket->Send (packet);

If (++m_packetsSent < m_nPackets)

70
{
ScheduleTx ();
}
}

Void
MyApp::ScheduleTx (void)
{
If (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate
())));
M_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}
}

Static void
CwndChange (Ptr<OutputStreamWrapper> stream, uint32_t oldCwnd, uint32_t newCwnd)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << “\t” << newCwnd);
*stream->GetStream () << Simulator::Now ().GetSeconds () << “\t” << oldCwnd << “\t”
<< newCwnd << std::endl;
}

Static void
RxDrop (Ptr<PcapFileWrapper> file, Ptr<const Packet> p)
{
NS_LOG_UNCOND (“RxDrop at “ << Simulator::Now ().GetSeconds ());
File->Write (Simulator::Now (), p);
}

Int
Main (int argc, char *argv[])
{
CommandLine cmd;
Cmd.Parse (argc, argv);

NodeContainer nodes;
Nodes.Create (2);

71
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));
pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));

NetDeviceContainer devices;
Devices = pointToPoint.Install (nodes);

Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ();


Em->SetAttribute (“ErrorRate”, DoubleValue (0.00001));
Devices.Get (1)->SetAttribute (“ReceiveErrorModel”, PointerValue (em));

InternetStackHelper stack;
Stack.Install (nodes);

Ipv4AddressHelper address;
Address.SetBase (“10.1.1.0”, “255.255.255.252”);
Ipv4InterfaceContainer interfaces = address.Assign (devices);

Uint16_t sinkPort = 8080;


Address sinkAddress (InetSocketAddress (interfaces.GetAddress (1), sinkPort));
PacketSinkHelper packetSinkHelper (“ns3::TcpSocketFactory”, InetSocketAddress
(Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1));
sinkApps.Start (Seconds (0.));
sinkApps.Stop (Seconds (20.));

Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (nodes.Get (0),


TcpSocketFactory::GetTypeId ());

Ptr<MyApp> app = CreateObject<MyApp> ();


App->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate (“1Mbps”));
Nodes.Get (0)->AddApplication (app);
App->SetStartTime (Seconds (1.));
App->SetStopTime (Seconds (20.));

AsciiTraceHelper asciiTraceHelper;
Ptr<OutputStreamWrapper> stream = asciiTraceHelper.CreateFileStream (“sixth.cwnd”);

72
Ns3TcpSocket->TraceConnectWithoutContext (“CongestionWindow”,
MakeBoundCallback (&CwndChange, stream));

PcapHelper pcapHelper;
Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (“sixth.pcap”, std::ios::out,
PcapHelper::DLT_PPP);
Devices.Get (1)->TraceConnectWithoutContext (“PhyRxDrop”, MakeBoundCallback
(&RxDrop, file));

Simulator::Stop (Seconds (20));


Simulator::Run ();
Simulator::Destroy ();

Return 0;
}

OUTPUT

73
Result
We have stimulate and observe changes in ns-3 TCP congestion window and
packet drops in a network with a point-to-point connection and custom
applications.

74
Experiment-17
Aim
To simulate and analyze the changes in the ns-3 TCP congestion window, monitor packet
drops, and create graphs of packet byte counts over time in a network with a point-to-point
connection and custom applications.

Code
#include <fstream>
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
#include “ns3/stats-module.h”

Using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“SeventhScriptExample”);

//
==================================================================
=========
//
// node 0 node 1
// +----------------+ +----------------+
// | ns-3 TCP | | ns-3 TCP |
// +----------------+ +----------------+
// | 10.1.1.1 | | 10.1.1.2 |
// +----------------+ +----------------+
// | point-to-point | | point-to-point |
// +----------------+ +----------------+
// | |
// +---------------------+
// 5 Mbps, 2 ms
//
//
// We want to look at changes in the ns-3 TCP congestion window. We need

75
// to crank up a flow and hook the CongestionWindow attribute on the socket
// of the sender. Normally one would use an on-off application to generate a
// flow, but this has a couple of problems. First, the socket of the on-off
// application is not created until Application Start time, so we wouldn’t be
// able to hook the socket (now) at configuration time. Second, even if we
// could arrange a call after start time, the socket is not public so we
// couldn’t get at it.
//
// So, we can cook up a simple version of the on-off application that does what
// we want. On the plus side we don’t need all of the complexity of the on-off
// application. On the minus side, we don’t have a helper, so we have to get
// a little more involved in the details, but this is trivial.
//
// So first, we create a socket and do the trace connect on it; then we pass
// this socket into the constructor of our simple application which we then
// install in the source node.
//
==================================================================
=========
//
Class MyApp : public Application
{
Public:
MyApp ();
Virtual ~MyApp ();

/**
* Register this type.
* \return The TypeId.
*/
Static TypeId GetTypeId (void);
Void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets,
DataRate dataRate);

Private:
Virtual void StartApplication (void);
Virtual void StopApplication (void);

Void ScheduleTx (void);

76
Void SendPacket (void);

Ptr<Socket> m_socket;
Address m_peer;
Uint32_t m_packetSize;
Uint32_t m_nPackets;
DataRate m_dataRate;
EventId m_sendEvent;
Bool m_running;
Uint32_t m_packetsSent;
};

MyApp::MyApp ()
: m_socket (0),
M_peer (),
M_packetSize (0),
M_nPackets (0),
M_dataRate (0),
M_sendEvent (),
M_running (false),
M_packetsSent (0)
{
}

MyApp::~MyApp ()
{
M_socket = 0;
}

/* static */
TypeId MyApp::GetTypeId (void)
{
Static TypeId tid = TypeId (“MyApp”)
.SetParent<Application> ()
.SetGroupName (“Tutorial”)
.AddConstructor<MyApp> ()
;
Return tid;
}

77
Void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t
nPackets, DataRate dataRate)
{
M_socket = socket;
M_peer = address;
M_packetSize = packetSize;
M_nPackets = nPackets;
M_dataRate = dataRate;
}

Void
MyApp::StartApplication (void)
{
M_running = true;
M_packetsSent = 0;
If (InetSocketAddress::IsMatchingType (m_peer))
{
M_socket->Bind ();
}
Else
{
M_socket->Bind6 ();
}
M_socket->Connect (m_peer);
SendPacket ();
}

Void
MyApp::StopApplication (void)
{
M_running = false;

If (m_sendEvent.IsRunning ())
{
Simulator::Cancel (m_sendEvent);
}

78
If (m_socket)
{
M_socket->Close ();
}
}

Void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
M_socket->Send (packet);

If (++m_packetsSent < m_nPackets)


{
ScheduleTx ();
}
}

Void
MyApp::ScheduleTx (void)
{
If (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate
())));
M_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}
}

Static void
CwndChange (Ptr<OutputStreamWrapper> stream, uint32_t oldCwnd, uint32_t newCwnd)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << “\t” << newCwnd);
*stream->GetStream () << Simulator::Now ().GetSeconds () << “\t” << oldCwnd << “\t”
<< newCwnd << std::endl;
}

Static void
RxDrop (Ptr<PcapFileWrapper> file, Ptr<const Packet> p)

79
{
NS_LOG_UNCOND (“RxDrop at “ << Simulator::Now ().GetSeconds ());
File->Write (Simulator::Now (), p);
}

Int
Main (int argc, char *argv[])
{
Bool useV6 = false;

CommandLine cmd;
Cmd.AddValue (“useIpv6”, “Use Ipv6”, useV6);
Cmd.Parse (argc, argv);

NodeContainer nodes;
Nodes.Create (2);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));
pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));

NetDeviceContainer devices;
Devices = pointToPoint.Install (nodes);

Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ();


Em->SetAttribute (“ErrorRate”, DoubleValue (0.00001));
Devices.Get (1)->SetAttribute (“ReceiveErrorModel”, PointerValue (em));

InternetStackHelper stack;
Stack.Install (nodes);

Uint16_t sinkPort = 8080;


Address sinkAddress;
Address anyAddress;
Std::string probeType;
Std::string tracePath;
If (useV6 == false)
{
Ipv4AddressHelper address;

80
Address.SetBase (“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = address.Assign (devices);
sinkAddress = InetSocketAddress (interfaces.GetAddress (1), sinkPort);
anyAddress = InetSocketAddress (Ipv4Address::GetAny (), sinkPort);
probeType = “ns3::Ipv4PacketProbe”;
tracePath = “/NodeList/*/$ns3::Ipv4L3Protocol/Tx”;
}
Else
{
Ipv6AddressHelper address;
Address.SetBase (“2001:0000:f00d:café::”, Ipv6Prefix (64));
Ipv6InterfaceContainer interfaces = address.Assign (devices);
sinkAddress = Inet6SocketAddress (interfaces.GetAddress (1,1), sinkPort);
anyAddress = Inet6SocketAddress (Ipv6Address::GetAny (), sinkPort);
probeType = “ns3::Ipv6PacketProbe”;
tracePath = “/NodeList/*/$ns3::Ipv6L3Protocol/Tx”;
}

PacketSinkHelper packetSinkHelper (“ns3::TcpSocketFactory”, anyAddress);


ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1));
sinkApps.Start (Seconds (0.));
sinkApps.Stop (Seconds (20.));

Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (nodes.Get (0),


TcpSocketFactory::GetTypeId ());

Ptr<MyApp> app = CreateObject<MyApp> ();


App->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate (“1Mbps”));
Nodes.Get (0)->AddApplication (app);
App->SetStartTime (Seconds (1.));
App->SetStopTime (Seconds (20.));

AsciiTraceHelper asciiTraceHelper;
Ptr<OutputStreamWrapper> stream = asciiTraceHelper.CreateFileStream
(“seventh.cwnd”);
Ns3TcpSocket->TraceConnectWithoutContext (“CongestionWindow”,
MakeBoundCallback (&CwndChange, stream));

PcapHelper pcapHelper;

81
Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (“seventh.pcap”, std::ios::out,
PcapHelper::DLT_PPP);
Devices.Get (1)->TraceConnectWithoutContext (“PhyRxDrop”, MakeBoundCallback
(&RxDrop, file));

// Use GnuplotHelper to plot the packet byte count over time


GnuplotHelper plotHelper;

// Configure the plot. The first argument is the file name prefix
// for the output files generated. The second, third, and fourth
// arguments are, respectively, the plot title, x-axis, and y-axis labels
plotHelper.ConfigurePlot (“seventh-packet-byte-count”,
“Packet Byte Count vs. Time”,
“Time (Seconds)”,
“Packet Byte Count”);

// Specify the probe type, trace source path (in configuration namespace), and
// probe output trace source (“OutputBytes”) to plot. The fourth argument
// specifies the name of the data series label on the plot. The last
// argument formats the plot by specifying where the key should be placed.
plotHelper.PlotProbe (probeType,
tracePath,
“OutputBytes”,
“Packet Byte Count”,
GnuplotAggregator::KEY_BELOW);

// Use FileHelper to write out the packet byte count over time
FileHelper fileHelper;

// Configure the file to be written, and the formatting of output data.


fileHelper.ConfigureFile (“seventh-packet-byte-count”,
FileAggregator::FORMATTED);

// Set the labels for this formatted output file.


fileHelper.Set2dFormat (“Time (Seconds) = %.3e\tPacket Byte Count = %.0f”);

// Specify the probe type, trace source path (in configuration namespace), and
// probe output trace source (“OutputBytes”) to write.
fileHelper.WriteProbe (probeType,

82
tracePath,
“OutputBytes”);

Simulator::Stop (Seconds (20));


Simulator::Run ();
Simulator::Destroy ();

Return 0;
}

OUTPUT

Result
We havesimulate and analyze the changes in the ns-3 TCP congestion window, monitor
packet drops, and create graphs of packet byte counts over time in a network with a point-to-
point connection and custom applications.

83
Experiment-18

84
Aim
Wireless router configuration using cisco packet

Apparatus Required
Computer with Cisco Packet Tracer installed

Wireless router configuration is a fundamental aspect of network management and plays a


crucial role in providing wireless connectivity to devices. In this experiment, you will
configure a wireless router using Cisco Packet Tracer. Here’s a theoretical background to
help you understand the key concepts involved:

Router
A router is a networking device that connects different networks together. It acts as a
gateway, routing data packets between devices on a local network and external networks
such as the internet. Routers use routing tables to determine where to forward data packets.

Wireless Networking
Wireless networking, also known as Wi-Fi, enables devices to connect to a network without
physical cables. Wireless routers provide this functionality. They broadcast wireless signals
using radio waves, allowing devices like laptops and smartphones to connect to the network.

SSID (Service Set Identifier)


SSID is the name of the wireless network. It allows devices to identify and connect to the
correct network. You can think of it as the “name” of your wireless network.

Wireless Security

85
Ensuring the security of your wireless network is crucial. Cisco routers offer various security
protocols like WPA (Wi-Fi Protected Access) and WPA2 to encrypt data and protect your
network from unauthorized access.

DHCP (Dynamic Host Configuration Protocol)


DHCP is a network protocol used to assign IP addresses and other network configuration
information to devices in a network. In the context of a wireless router, DHCP simplifies the
process of connecting devices by automatically assigning IP addresses.

Configuration
Configuring a router involves setting up parameters such as the router’s hostname, IP
addresses, subnet masks, and more. It also includes enabling and configuring the wireless
interface, setting up DHCP, and defining security settings.

Testing and Troubleshooting


After configuring the router, it’s essential to test the network to ensure that devices can
connect and access the internet. Troubleshooting is often required to address any issues that
may arise during the configuration process

Procedure
1. Open Cisco Packet Tracer and create a new topology.
2. Add a wireless router and a switch to the topology.
3. Connect the wireless router to the switch using a straight-through Ethernet cable.
4. Connect a laptop to the switch using a straight-through Ethernet cable.
5. Configure the wireless router with a basic SSID and security.
6. Double-click on the wireless router icon to open the configuration window.
7. Click on the Wireless tab.
8. Enter a name for your wireless network in the SSID field.
9. Select a security mode from the Security drop-down list.
10. Enter a password for your wireless network in the Password field.
11. Click OK to save the configuration.
12. Connect the laptop to the wireless network.
13. On the laptop, open the Wi-Fi settings.
14. Select the name of your wireless network from the list of available networks.
15. Enter the password for your wireless network.
16. Click Connect.
17. Verify that the laptop is connected to the wireless network and can access the
internet.
18. Open a web browser and navigate to a website, such as https://

86
OUTPUT

87
Result: We have simulate wireless router configuration using cisco packet

88
89
90

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy