Computer Network
Computer Network
To Gift the Nation with Eminent Engineers & Managers, Capable of Contributing Towards Technological
Advancement and Betterment of the Society.
To advance the well being of society through excellence in teaching, research and service that
exploits the rapidly changing technical diversity via collaborative environment that stimulates
faculty, staff and students to reach their highest potential through continuous learning.
Instill the foundation of professionalism and provide the tools required to advance the technological
world.
Inculcate knowledge and ethics, and nurture/foster innovation and team man ship among the
graduates/alumnae.
Endow eminent education to serve the society with graduates/alumnae possessing ace skills and
potential.
Sustain highest reception of the institute’s alumnae among the stakeholders.
To be the best technical education offering centre by producing competent professionals to meet the global
challenges in the field of information science and engineering.
To Provide good Teaching and Research environment with best teaching methods and mentoring
along with extra-curricular activities
Inculcate moral ethics in students enabling them to become socially committed with
entrepreneurship attitude & leadership qualities.
Apply the knowledge of mathematics, basic sciences and engineering fundamentals to find solutions
for engineering related problems.
Excel with IT proficiency in the field of Information Science and Engineering by preparing
graduates to face the competitive world.
Exhibit professionalism, leadership qualities, team work and expose to current trends towards
continuous learning.
MAHARAJA INSTITUTE OF TECHNOLOGY MYSORE
BELAWADI, SRIRANGAPATNA Taluk, MANDYA-571438
Department of Information Science & Engineering
Program Outcome
PO1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an
engineering specialization to the solution of complex engineering problems.
PO2. Problem analysis: Identify, formulate, research literature, and analyze complex engineering problems reaching
substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences.
PO3. Design/development of solutions: Design solutions for complex engineering problems and design system
components or processes that meet the specified needs with appropriate consideration for the public health and safety,
and the cultural, societal, and environmental considerations.
PO4. Conduct investigations of complex problems: Use research-based knowledge and research methods including
design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid
conclusions.
PO5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and IT
tools including prediction and modeling to complex engineering activities with an understanding of the limitations.
PO6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health,
safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice.
PO7. Environment and sustainability: Understand the impact of the professional engineering solutions in societal and
environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
PO8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.
PO9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams,
and in multidisciplinary settings.
PO10. Communication: Communicate effectively on complex engineering activities with the engineering community
and with society at large, such as, being able to comprehend and write effective reports and design documentation,
make effective presentations, and give and receive clear instructions.
PO11. Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to manage projects and
in multidisciplinary environments.
PO12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and
life-long learning in the broadest context of technological change.
MAHARAJA INSTITUTE OF TECHNOLOGY MYSORE
BELAWADI, SRIRANGAPATNA Taluk, MANDYA-571438
Department of Information Science & Engineering
Overview
Course content opens up with simulation of network layer protocols and demonstration of various network
topologies. Allows the implantation of GSM & CDMA concepts. It elaborates the implementation of varied
routing methods/algorithms. Provides the opportunities for error checking through CRC & RSA
implementation. Students can also experience traffic management methods at packet/flow level through
leaky bucket.
Through this course students are able to design simple applications to demonstrate error checking and traffic
policing through CRC, RSA & leaky bucket algorithm implementation. Students are able to demonstrate the
working of various routing protocols through the implementation of TCP & UDP protocols. Students are
able to simulate simple networking topologies using NS2 / NS3. Students will implement CDMA and GSM
networks using NS2 / NS3
PART-B
Implement the following in Java:
7. Write a program for error detecting code using CRC-CCITT (16- bits).
8. Write a program to find the shortest path between vertices using bellman-ford algorithm.
9. Using TCP/IP sockets, write a client – server program to make the client send the file name and to
make the server send back the contents of the requested file if present.
10. Write a program on datagram socket for client/server to display the messages on client side, typed at
the server side.
11. Write a program for simple RSA algorithm to encrypt and decrypt the data.
12. Write a program for congestion control using leaky bucket algorithm.
For the experiments above modify the topology and parameters set for the experiment and
take multiple rounds of reading and analyze the results available in log files. Plot necessary
graphs and conclude. Use NS2/NS3.
List of URLs, Text Books, Notes, Multimedia Content, etc
1. www.tutorialspoint.com/computer.../computer_networking.html
2. https://www.coursera.org/course/comnetworks
3. www.journals.elsevier.com/computer-networks
4. https://www.udacity.com/course/computer-networking--ud436
1. Implement, analyze and evaluate networking protocols in NS2 / NS3
Course
2. Implement and demonstrate the working of different concepts of networking using
Outcomes
Java.
Conduction of Practical Examination:
1. All laboratory experiments are to be included for practical examination.
2. Students are allowed to pick one experiment from part A and part B with lot.
3. Strictly follow the instructions as printed on the cover page of answer script
4. Marks distribution: Procedure + Conduction + Viva: 80
Part A: 10+25+5 =40
Part B: 10+25+5 =40
5. Change of experiment is allowed only once and marks allotted to the procedure part to bemade zero.
MAHARAJA INSTITUTE OF TECHNOLOGY MYSORE
BELAWADI, SRIRANGAPATNA Taluk, MANDYA-571438
Department of Information Science & Engineering
Date: 27/02/18
Course Outcome
15CSL57.1 Design and develop simple applications to demonstrate error checking and traffic
policing.
15CSL57.2 Demonstrate working of various routing protocols.
15CSL57.3 Simulate simple networking topologies using NS2 / NS3
15CSL57.4 Implement CDMA and GSM networks using NS2 / NS3
PO No PSO
CO No
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3
CO1 3 3 3 2 - - - - 3 - - 2 3 3 2
CO2 3 3 3 2 - - - - 3 - - 2 3 3 2
CO3 3 3 3 3 3 - - - 3 - - 2 - 3 -
CO4 3 3 3 3 3 - - - 3 - - 2 - 3 3
CO 3 3 2.33
Average 3 3 3 2.5 3 - - - 3 - - 2
Shantha S Hemavathi M N
Hemavathi M N
Faculty Course Coordinator
Approval of the COs and their mapping with POs and PSOs was given on 27/02/18
Convener Principal
MAHARAJA INSTITUTE OF TECHNOLOGY MYSORE
BELAWADI, SRIRANGAPATNA Taluk, MANDYA-571438
Department of Information Science & Engineering
Students should maintain an observation book and unit test book along with record.
Unit test will be evaluated for 05 Marks and Record for 05 Marks and final IA for 10 Marks.
Students should complete the observation book which should include the logic and tracing of the
respective program and should get it evaluated before departing from the lab.
They should produce the lab record Next week which should include lab set programs with comments
and necessary Board Layout and Circuit diagram if any.
If in case the student is unable to attend the regular batch, He / She should take prior permission from
the concerned faculty and try to attend the next batch.
Do‟s
1. Know the location of the fire extinguisher and the first aid box and how to use them in case of an
emergency.
2. Read and understand how to carry out an activity thoroughly before coming to the laboratory.
3. Report fires or accidents to your faculty/laboratory technician immediately.
4. Report any broken plugs or exposed electrical wires to your faculty/laboratory technician immediately.
Don‟ts
1. Do not eat or drink in the laboratory.
2. Avoid stepping on electrical wires or any other computer cables.
3. Do not open the system unit casing or monitor casing particularly when the power is turned on. Some
internal components hold electric voltages of up to 230 volts, which can be fatal.
4. Do not insert metal objects such as clips, pins and needles into the computer casings. They may cause
fire.
5. Do not remove anything from the computer laboratory without permission.
6. Do not touch, connect or disconnect any plug or cable without your faculty /laboratory technician‟s
permission.
7. Do not misbehave in the computer laboratory.
NETWORK SIMULATION
Introduction:
Network simulation is an important tool in developing, testing and evaluating network protocols.
Simulation can be used without the target physical hardware, making it economical and practical for
almost any scale of network topology and setup. It is possible to simulate a link of any bandwidth and
delay, even if such a link is currently impossible in the real world. With simulation, it is possible to set
each simulated node to use any desired software. This means that meaning deploying software is not
an issue. Results are also easier to obtain and analyze, because extracting information from important
points in the simulated network is as done by simply parsing the generated trace files.
MIT's NETSIM
NIST
CPSIM
INSANE
NEST
REAL
NS
OPNET
NCTUns
ns (from network simulator) is a name for series of discrete event network simulators,
specifically ns-1, ns-2 and ns-3. All of them are discrete-event network simulators, primarily used in
research and teaching. ns-3 is free software, publicly available under the GNU GPLv2 license for
research, development, and use.
The goal of the ns-3 project is to create an open simulation environment for networking research that
will be preferred inside the research community
Since the process of creation of a network simulator that contains a sufficient number of high-quality
validated, tested and actively maintained models requires a lot of work, ns-3 project spreads this
workload over a large community of users and developers.
ns-2
In 1996-97, ns version 2 (ns-2) was initiated based on a refactoring by Steve McCanne. Use of Tcl was
replaced by MIT'sObject Tcl (OTcl), an object-oriented dialect Tcl. The core of ns-2 is also written in
C++, but the C++ simulation objects are linked to shadow objects in OTcl and variables can be linked
between both language realms. Simulation scripts are written in the OTcl language, an extension of the
Tcl scripting language.
Presently, ns-2 consists of over 300,000 lines of source code, and there is probably a comparable
amount of contributed code that is not integrated directly into the main distribution (many forks of ns-
2 exist, both maintained and unmaintained). It runs on GNU/Linux, FreeBSD, Solaris, Mac OS X and
Windows versions that support Cygwin. It is licensed for use underversion 2 of the GNU General
Public License.
Design
ns-3 is built using C++ and Python with scripting capability. The ns-3 library is wrapped to python
thanks to the pybindgen library which delegates the parsing of the ns-3 C++ headers to gccxml and
pygccxml to generate automatically the corresponding C++ binding glue. These automatically-
generated C++ files are finally compiled into the ns-3 python module to allow users to interact with
the C++ ns-3 models and core through python scripts. The ns-3 simulator features an integrated
attribute-based system to manage default and per-instance values for simulation parameters. All of the
configurable default values for parameters are managed by this system, integrated with command-line
argument processing, Doxygen documentation, and an XML-based and optional GTK-based
configuration subsystem.
The large majority of its users focuses on wireless simulations which involve models for Wi-Fi,
WiMAX, or LTE for layers 1 and 2 and routing protocols such as OLSR and AODV.
1. vi filename.tcl
It will open page, there you can write tcl scripts.
2. save file
Press esc-> colon (shift + semicolon) ->wq (save and quit)
It save the file
2.Turn on tracing
3.Creating network
4. Monitoring
Note: every tcl script must write in small letters only except protocol agents i.e. TCP, FTP
Template
Every ns2 script starts with creating simulator object set ns [new Simulator]
Creating link
This line tells the simulator object to connect the nodes n0 and n1 with a duplex link with
the bandwidth.1Megabit, a delay of 10ms and a DropTail queue.
1. generic trace
for use with xgraph, and other things
2. nam trace
for use with visualization
Since we have started tracing, we should end also. For this we use finish procedure.
$ns run
UDP communication
In UDP communication, data is flows from UDP agent to Null agent.
# create a null agent which act as traffic sink and attach it to node n1
set null0 [new Agent/Null]
$ns attach-agent $n1 $null0
TCP Communication
# create a tcpsink agent which act as traffic sink and attach it to node n1
set tcpsink0 [new Agent/TCPSink]
$ns attach-agent $n1 $tcpsink0
Traffic generator
For actual data to flow, we need traffic generators.They simulate some application traffic.
Simple example using CBR
cbr0 will start at a time of 1.0 ms and whole process will stops at 5.0ms.we can also stop
each and traffic generator. for example
Introduction to NS-2:
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.
Tcl scripting
• Tcl is a general purpose scripting language. [Interpreter]
• Tcl runs on most of the platforms such as Unix, Windows, and Mac.
• The strength of Tcl is its simplicity.
• It is not necessary to declare a data type for variable prior to the usage.
Basics of TCL
Syntax: command arg1 arg2 arg3
Hello World!
puts stdout{Hello, World!}
Hello, World!
Variables Command Substitution
set a 5 set len [string length foobar]
set b $a set len [expr [string length foobar] + 9]
Simple Arithmetic
expr 7.2 / 4
Procedures
proc Diag {a b} {
set c [expr sqrt($a * $a + $b * $b)]
return $c }
NS Simulator Preliminaries.
1. Initialization and termination aspects of the ns simulator.
2. Definition of network nodes, links, queues and topology.
3. Definition of agents and of applications.
4. The nam visualization tool.
5. Tracing and random variables.
Which is thus the first line in the tcl script? This line declares a new variable as using the set
command, you can call this variable as you wish, In general people declares it as ns because it is an
instance of the Simulator class, so an object the code[new Simulator] is indeed the installation of the
class Simulator using the reserved word new.
In order to have output files with data on the simulation (trace files) or files used for visualization
(nam files), we need to create the files using “open” command:
The above creates a dta trace file called “out.tr” and a nam visualization trace file called
“out.nam”.Within the tcl script,these files are not called explicitly by their names,but instead by
pointers that are declared above and called “tracefile1” and “namfile” respectively.Remark that they
begins with a # symbol.The second line open the file “out.tr” to be used for writing,declared with the
letter “w”.The third line uses a simulator method called trace-all that have as parameter the name of
the file where the traces will go.
The last line tells the simulator to record all simulation traces in NAM input format.It also
gives the file name that the trace will be written to later by the command $ns flush-trace.In our
case,this will be the file pointed at by the pointer “$namfile”,i.e the file “out.tr”.
The termination of the program is done using a “finish” procedure.
$ns flush-trace
Close $tracefile1
Close $namfile
Exit 0
The word proc declares a procedure in this case called finish and without arguments. The word
global is used to tell that we are using variables declared outside the procedure. The simulator method
“flush-trace” will dump the traces on the respective files. The tcl command “close” closes the trace
files defined before and exec executes the nam program for visualization. The command exit will ends
the application and return the number 0 as status to the system. Zero is the default for a clean exit.
Other values can be used to say that is a exit because something fails.
At the end of ns program we should call the procedure “finish” and specify at what time the
termination should occur. For example,
$ns at 125.0 “finish”
will be used to call “finish” at time 125sec.Indeed,the at method of the simulator allows us to schedule
events explicitly.
The simulation can then begin using the command
$ns run
The node is created which is printed by the variable n0. When we shall refer to that node in the script
we shall thus write $n0.
Once we define several nodes, we can define the links that connect them. An example of a
definition of a link is:
$ns duplex-link $n0 $n2 10Mb 10ms DropTail
Which means that $n0 and $n2 are connected using a bi-directional link that has 10ms of
propagation delay and a capacity of 10Mb per sec for each direction.
To define a directional link instead of a bi-directional one, we should replace “duplex-link” by
“simplex-link”.
In NS, an output queue of a node is implemented as a part of each link whose input is that
node. The definition of the link then includes the way to handle overflow at that queue. In our case, if
the buffer capacity of the output queue is exceeded then the last packet to arrive is dropped. Many
alternative options exist, such as the RED (Random Early Discard) mechanism, the FQ (Fair
Queuing), the DRR (Deficit Round Robin), the stochastic Fair Queuing (SFQ) and the CBQ (which
including a priority and a round-robin scheduler).
In ns, an output queue of a node is implemented as a part of each link whose input is that node.
We should also define the buffer capacity of the queue related to each link. An example would be:
#set Queue Size of link (n0-n2) to 20
The command $ns attach-agent $n0 $tcp defines the source node of the tcp connection.
The command
set sink [new Agent /TCPSink]
Defines the behavior of the destination node of TCP and assigns to it a pointer called sink.
#Setup a UDP connection
set udp [new Agent/UDP]
The command $ns attach-agent $n4 $sink defines the destination node. The command $ns
connect $tcp $sink finally makes the TCP connection between the source and destination nodes.
TCP has many parameters with initial fixed defaults values that can be changed if mentioned
explicitly. For example, the default TCP packet size has a size of 1000bytes.This can be changed to
another value, say 552bytes, using the command $tcp set packetSize_ 552.
When we have several flows, we may wish to distinguish them so that we can identify them
with different colors in the visualization part. This is done by the command $tcp set fid_ 1 that assigns
to the TCP connection a flow identification of “1”.We shall later give the flow identification of “2” to
the UDP connection.
Scheduling Events
NS is a discrete event based simulation. The tcp script defines when event should occur. The
initializing command set ns [new Simulator] creates an event scheduler, and events are then scheduled
using the format:
The scheduler is started when running ns that is through the command $ns run.
The beginning and end of the FTP and CBR application can be done through the following command
1. The first field is the event type. It is given by one of four possible symbols r, +, -, d which
correspond respectively to receive (at the output of the link), enqueued, dequeued and dropped.
2. The second field gives the time at which the event occurs.
3. Gives the input node of the link at which the event occurs.
4. Gives the output node of the link at which the event occurs.
5. Gives the packet type (eg CBR or TCP)
6. Gives the packet size
7. Some flags
8. This is the flow id (fid) of IPv6 that a user can set for each flow at the input OTcl script one can
further use this field for analysis purposes; it is also used when specifying stream color for the
NAM display.
XGRAPH
The xgraph program draws a graph on an x-display given data read from either data file or
from standard input if no files are specified. It can display upto 64 independent data sets using
different colors and line styles for each set. It annotates the graph with a title, axis labels, grid lines or
tick marks, grid labels and a legend.
Syntax:
Xgraph [options] file-name
Awk- An Advanced
awk is a programmable, pattern-matching, and processing tool available in UNIX. It works equally
well with text and numbers. awk is not just a command, but a programming language too. In other
words, awk utility is a pattern scanning and processing language. It searches one or more files to see if
they contain lines that match specified patterns and then perform associated actions, such as writing
the line to the standard output or incrementing a counter each time it finds a match.
Syntax:
awk option ‘selection_criteria {action}’ file(s)
Here, selection_criteria filters input and select lines for the action component to act upon. The
selection_criteria is enclosed within single quotes and the action within the curly braces. Both the
selection_criteria and action forms an awk program.
Example: $ awk „/manager/ {print}‟ emp.lst
Variables
Awk allows the user to use variables of there choice. You can now print a serial number, using
the variable kount, and apply it those directors drawing a salary exceeding 6700:
$ awk –F”|” „$3 == “director” && $6 > 6700 {
kount =kount+1
printf “ %3f %20s %-12s %d\n”, kount,$2,$3,$6 }‟ empn.lst
BEGIN {action}
END {action}
These two sections, when present, are delimited by the body of the awk program. You can use
them to print a suitable heading at the beginning and the average salary at the end.
Built-In Variables
Awk has several built-in variables. They are all assigned automatically, though it is also
possible for a user to reassign some of them. You have already used NR, which signifies the record
number of the current line. We‟ll now have a brief look at some of the other variable.
The FS Variable: as stated elsewhere, awk uses a contiguous string of spaces as the default field
delimiter. FS redefines this field separator, which in the sample database happens to be the |. When
used at all, it must occur in the BEGIN section so that the body of the program knows its value before
it starts processing:
BEGIN {FS=”|”}
This is an alternative to the –F option which does the same thing.
The OFS Variable: when you used the print statement with comma-separated arguments, each
argument was separated from the other by a space. This is awk‟s default output field separator, and can
reassigned using the variable OFS in the BEGIN section:
BEGIN { OFS=”~” }
When you reassign this variable with a ~ (tilde), awk will use this character for delimiting the print
arguments. This is a useful variable for creating lines with delimited fields.
The NF variable: NF comes in quite handy for cleaning up a database of lines that don‟t contain the
right number of fields. By using it on a file, say emp.lst, you can locate those lines not having 6 fields,
and which have crept in due to faulty data entry:
$awk „BEGIN {FS = “|”}
NF! =6 {
Print “Record No “, NR, “has”, “fields”}‟ empx.lst
➢ After the files get extracted, we get ns-allinone-2.34 folder as well as zip file ns-all in one-
2.34.tar.gz
[root@localhost opt]#ns-allinone-2.34 ns-allinone-2.34.tar.gz
➢ When we open this file, we get a line in that file which is shown below
PATH=$PATH:$HOME/bin
To this line we must paste the path which is present in the previous terminal where ns was installed.
First put “:” then paste the path in-front of bin. That path is shown below. “:/opt/ns-allinone-
2.33/bin:/opt/ns-allinone-2.33/tcl8.4.18/unix:/opt/ns-allinone- 2.33/tk8.4.18/unix”.
“/opt/ns-allinone-2.33/otcl-1.13:/opt/ns-allinone-2.33/lib”
➢ In the next line type “TCL_LIBRARY=$TCL_LIBRARY:” and paste the path which is
present in previous terminal i.e Important Notices section(2)
“/opt/ns-allinone-2.33/tcl8.4.18/library”
➢ In the next line type “exportLD_LIBRARY_PATH”
➢ In the next line type “exportTCL_LIBRARY”
➢ The next two lines are already present the file “export PATH” and “unsetUSERNAME”
➢ Save the program ( ESC + shift : wq and press enter)
➢ Nowintheterminalwherewehaveopened.bash_profilefile,typethefollowingcommand to check if
path is updated correctly ornot
[root@localhost ~] # vi.bash_profile
[root@localhost ~] # source.bash_profile
➢ If path is updated properly, then we will get the prompt as shown below
[root@localhost ~]#
➢ Now open the previous terminal where you have installedns
[root@localhost ns-allinone-2.33] #
➢ Here we need to configure three packages “ns-2.33”, “nam-1.13” and“xgraph-12.1”
➢ First, configure “ns-2.33” package as shown below
Dept of ISE MIT, Mysore Page 19
15CSL57 COMPUTER NETWORKS LABORATORY 2017-18
%
➢ If we get “%” symbol it indicates that nam-1.13 configuration was successful.
➢ Third, configure “xgraph-12.1” package as shown below
[root@localhost nam-1.13] # cd ..
[root@localhost ns-allinone-2.33] # cd xgraph-12.1
[root@localhost xgraph-12.1] # ./configure
[root@localhost xgraph-12.1] # make clean
[root@localhost xgraph-12.1] # make [root@localhost
xgraph-12.1] # make install [root@localhost xgraph-12.1]
#ns
%
This completes the installation process of “NS-2” simulator.
Step1: Open text editor, type the tcl program and save with extension .tcl (prog1.tcl )
set ns [new Simulator]
set nf [open prog1.nam w]
$ns namtrace-all $nf
proc finish { } {
global ns nf nd
$ns flush-trace
close $nf
close $nd
exec nam prog1.nam &
exit 0
}
Step2: Open text editor, type the awk program and save with extension .awk (prog1.awk )
/* prog1.awk*/
BEGIN {
dcount = 0;
rcount = 0;
}
{
event = $1;
if(event == "d")
{
dcount++;
}
if(event == "r")
{
rcount++;
}
}
END {
printf("The no.of packets dropped : %d\n ",dcount);
printf("The no.of packets recieved : %d\n ",rcount);
}
Step 4: Now press the play button in the simulation window and the simulation will begins.
Step 5: After simulation is completed run awk file to see the output ,
[root@localhost~]# awk –f prog1.awk prog1.tr
Number of packets droped = 16
[root@localhost~]# vi prog1.tr
Aim: To implement transmission of ping messages/trace route over a network topology consisting of 6
nodes and find the number of packets dropped due to congestion.
Step1: Open text editor, type the below program and save with extension .tcl (prog2.tcl )
proc finish {} {
global ns nf nd
$ns flush-trace
close $nf
close $nd
exec nam prog2.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
Step2: Open text editor, type the below program and save with extension .awk (prog3.awk )
/*prog2.awk*/
BEGIN {
count=0;
}
{
event=$1;
if(event=="d")
{
count++;
}
}
END {
printf("No of packets dropped : %d\n",count);
}
Step 4: Now press the play button in the simulation window and the simulation will begins.
Step 5: After simulation is completed run awk file to see the output ,
[root@localhost~]# awk –f prog2.awk prog2.tr
Aim: To Implement an Ethernet LAN using n nodes and set multiple traffic nodes and plot congestion
window for different source / destination.
Step1: Open text editor, type the below program and save with extension .tcl (Lab3.tcl )
proc End {} {
global ns na nt
$ns flush-trace
close $na
close $nt
exec nam Lab3.nam &
exec xgraph tcp1.xg tcp2.xg &
exit 0
}
Topology
Output
Experiment 4: ESS
Aim: To implement simple ESS and with transmitting nodes in wire-less LAN by simulation and
determine the performance with respect to transmission of packets.
Step1: Open text editor, type the below program and save with extension .tcl (prog4.tcl )
create-god 3
set n0 [$ns node]
set n1 [$ns node]
Dept of ISE MIT, Mysore Page 31
15CSL57 COMPUTER NETWORKS LABORATORY 2017-18
$n0 set X_ 50
$n0 set Y_ 50
$n0 set Z_ 0
$n1 set X_ 100
$n1 set Y_ 100
$n1 set Z_ 0
$n2 set X_ 600
$n2 set Y_ 600
$n2 set Z_ 0
$ns at 0.1 "$n0 setdest 50 50 15"
$ns at 0.1 "$n1 setdest 100 100 25"
$ns at 0.1 "$n2 setdest 600 600 25"
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
set sink1 [new Agent/TCPSink]
$ns attach-agent $n1 $sink1
$ns connect $tcp0 $sink1
set tcp1 [new Agent/TCP]
$ns attach-agent $n1 $tcp1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
set sink2 [new Agent/TCPSink]
$ns attach-agent $n2 $sink2
$ns connect $tcp1 $sink2
$ns at 5 "$ftp0 start"
$ns at 5 "$ftp1 start"
$ns at 100 "$n1 setdest 550 550 15"
$ns at 190 "$n1 setdest 70 70 15"
proc finish { } {
global ns nf tf
$ns flush-trace
exec nam prog6.nam &
close $tf
exit 0
}
$ns at 250 "finish"
$ns run
Step2: Open text editor, type the below program and save with extension .awk (prog6.awk )
/*prog4.awk*/
BEGIN{
count1=0
count2=0
pack1=0
pack2=0
time1=0
time2=0
}
{ if($1=="r"&& $3=="_1_" && $4=="AGT")
{ count1++
pack1=pack1+$8
time1=$2 }
if($1=="r" && $3=="_2_" && $4=="AGT")
{ count2++
pack2=pack2+$8
time2=$2 }
}
END{
printf("The Throughput from n0 to n1: %f Mbps \n", ((count1*pack1*8)/(time1*1000000)));
printf("The Throughput from n1 to n2: %f Mbps", ((count2*pack2*8)/(time2*1000000)));
}
Step 4: Now press the play button in the simulation window and the simulation will begins.
Step 5: After simulation is completed run awk file to see the output ,
[root@localhost~]# awk –f prog4.awk prog4.tr
Here “M” indicates mobile nodes, “AGT” indicates Agent Trace, “RTR” indicates Router
Experiment 5: GSM
Aim: To implement and study the performance of GSM on NS2/NS3 (Using MAC layer) or
equivalent environment.
Step1: Open text editor, type the below program and save with extension .tcl (Lab5.tcl )
set bwDL(gsm) 9600
set bwUL(gsm) 9600
set propDL(gsm) .500
set propUL(gsm) .500
set buf(gsm) 10
set Total 0
proc cell_topo {} {
global ns nodes
$ns duplex-link $nodes(c1) $nodes(bs1) 3Mbps 10ms DropTail
$ns duplex-link $nodes(bs1) $nodes(ms) 1 1 RED
$ns duplex-link $nodes(ms) $nodes(bs2) 1 1 RED
$ns duplex-link $nodes(bs2) $nodes(c2) 3Mbps 50ms DropTail
}
switch gsm {
gsm -
gprs -
umts {cell_topo}
}
$ns bandwidth $nodes(bs1) $nodes(ms) $bwDL(gsm) simplex
$ns bandwidth $nodes(ms) $nodes(bs1) $bwUL(gsm) simplex
$ns bandwidth $nodes(bs2) $nodes(ms) $bwDL(gsm) simplex
$ns bandwidth $nodes(ms) $nodes(bs2) $bwUL(gsm) simplex
proc End {} {
global ns nt
$ns flush-trace
close $nt
exec awk -f Lab5.awk Lab5.tr &
exec xgraph -P -bar -x TIME -y DATA gsm.xg &
exit 0
}
Step2: Open text editor, type the below program and save with extension .awk (Lab5.awk )
/*Lab5.awk*/
BEGIN {Total_no_of_pkts=0;}
{
if($1 == "r")
{
Total_no_of_pkts = Total_no_of_pkts + $6;
printf("%f %d\n",$2,Total_no_of_pkts) >> "gsm.xg"
}
}
END{}
Step 5: After simulation is completed run awk file to see the output ,
[root@localhost~]# awk –f Lab5.awk Lab5.tr
Experiment 6: CDMA
Step1: Open text editor, type the below program and save with extension .tcl (Lab6.tcl )
set bwDL(cdma) 384000
set bwUL(cdma) 64000
set propDL(cdma) .150
set propUL(cdma) .150
set buf(cdma) 20
proc cell_topo {} {
global ns nodes
$ns duplex-link $nodes(c1) $nodes(bs1) 3Mbps 10ms DropTail
$ns duplex-link $nodes(bs1) $nodes(ms) 1 1 RED
$ns duplex-link $nodes(ms) $nodes(bs2) 1 1 RED
$ns duplex-link $nodes(bs2) $nodes(c2) 3Mbps 50ms DropTail
}
switch umts {
cdma -
umts {cell_topo}
}
$ns bandwidth $nodes(bs1) $nodes(ms) $bwDL(cdma) simplex
$ns bandwidth $nodes(ms) $nodes(bs1) $bwUL(cdma) simplex
$ns bandwidth $nodes(bs2) $nodes(ms) $bwDL(cdma) simplex
$ns bandwidth $nodes(ms) $nodes(bs2) $bwUL(cdma) simplex
proc End {} {
global ns nt
$ns flush-trace
close $nt
exec awk -f Lab6.awk Lab6.tr &
exec xgraph -P -bar -x TIME -y DATA cdma.xg &
exit 0
}
Step2: Open text editor, type the below program and save with extension .awk (Lab6.awk )
/*Lab6.awk*/
BEGIN {Total_no_of_pkts=0;}
{
if($1 == "r")
{
Total_no_of_pkts = Total_no_of_pkts + $6;
printf("%f %d\n",$2,Total_no_of_pkts) >> "cdma.xg"
}
}
END{}
Step 4: Now press the play button in the simulation window and the simulation will begins.
Step 5: After simulation is completed run awk file to see the output ,
[root@localhost~]# awk –f Lab5.awk Lab5.tr
The Java compiler (Javac) compiles java program and generates a byte-code with the same
file name and .class extension.
2. Run Java program from CommandPrompt
[root@host ~]# java Filename
The java interpreter (Java) runs the byte-code and gives the respective output. It is important
to note that in above command we have omitted the .class suffix of thebyte-
code(Filename.class).
Experiment 7: CRC-CCITT
Aim: To write a program for error detecting code using CRC-CCITT (16 bits).
Theory
CRC(Cyclic Redundancy Check) is an error detecting technique used in digital networks and storage
devices to detect the accidental changes to raw data. It cannot be used for correcting errors.
The CRC does error checking via polynomial division. The generated polynomial g(x) =
x +x +x5+x0
16 12
16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 17 bits.
Algorithm:
1. Given a bit string (message to be sent), append 16 0S to the end of it (the number of 0s is the
same as the degree of the generator polynomial) let this string + 0S be called as modified string
B
2. Divide B by agreed on polynomial g(x) and determine the remainder R(x). The 16-bit
remainder received is called as checksum.
3. The message string is appended with checksum and sent to the receiver.
4. At the receiver side, the received message is divided by generator polynomial g(x).
5. If the remainder is 0, the receiver concludes that there is no error occurred otherwise, the
receiver concludes an error occurred and requires a retransmission.
Program:
import java.util.*;
public class crc {
int n;
System.out.println("enter the size of the data:");
n=s.nextInt();
int data[]=new int[n];
System.out.println("enter the data ,bit by bit:");
for(int i=0; i < n; i++){
data[i]=s.nextInt();
}
System.out.println("enter ther size of the divisor:");
n=s.nextInt();
int divisor[]=new int[n];
System.out.println("enter the divisor,bit by bit:");
for(int i=0; i < n; i++)
divisor[i]=s.nextInt();
int remainder[]=divide(data,divisor);
System.out.println("\n the crc code generated is:");
for(int i=0; i < data.length; i++)
System.out.print(data[i]);
for(int i=0; i < remainder.length-1; i++)
System.out.print(remainder[i]);
System.out.println();
int sent_data[]=new int[data.length+remainder.length-1];
System.out.println("enter the data to be sent:");
for(int i=0; i < sent_data.length; i++)
sent_data[i]=s.nextInt();
recieve(sent_data,divisor);
}
static int[] divide(int old_data[],int divisor[]){
int remainder[],i;
int data[]=new int[old_data.length+divisor.length];
System.arraycopy(old_data, 0,data, 0,old_data.length);
System.out.println("message bits after appending divisor_length-1 0's:");
for(i=0; i<data.length-1; i++)
System.out.println(data[i]);
remainder=new int[divisor.length];
System.arraycopy(data, 0, remainder, 0, divisor.length);
for(i=0; i < old_data.length; i++){
if(remainder[0]==1){
for(int j=1; j<divisor.length; j++){
remainder[j-1]=exor(remainder[j],divisor[j]);
}
}
else{
for(int j=1; j < divisor.length; j++)
remainder[j-1]=exor(remainder[j],0);
}
remainder[divisor.length-1]=data[i+divisor.length];
}
return remainder;
}
static int exor(int a,int b){
if(a==b)
return 0;
return 1;
}
static void recieve(int data[],int divisor[]){
int remainder[]=divide(data,divisor);
for(int i=0; i < remainder.length; i++){
if(remainder[i] != 0){
System.out.println("there is an error in recieved data...");
return;
}
}
System.out.println("data was recieved without any error");
}
}
Experiment 8: BELLMAN-FORD
Aim:To write a program to find the shortest path between vertices using bellman-ford algorithm.
Theory
Routing algorithm is a part of network layer software which is responsible for deciding which output line an
incoming packet should be transmitted on. If the subnet uses datagram internally, this decision must be made
anew for every arriving data packet since the best route may have changed since last time. If the subnet uses
virtual circuits (connection Oriented), routing decisions are made only when a new established route is being set
up.
Routing algorithms can be grouped into two major classes: adaptive and nonadaptive. Nonadaptive
algorithms do not base their routing decisions on measurement or estimates of current traffic and topology.
Instead, the choice of route to use to get from I to J (for all I and J) is compute in advance, offline, and
downloaded to the routers when the network ids booted. This procedure is sometime called static routing.
Adaptive algorithms, in contrast, change their routing decisions to reflect changes in the topology, and
usually the traffic as well. Adaptive algorithms differ in where they get information (e.g., locally, from adjacent
routers, or from all routers), when they change the routes (e.g., every ∆T sec, when the load changes, or when
the topology changes), and what metric is used for optimization (e.g., distance, number of hops, or estimated
transit time).
Two algorithms in particular, distance vector routing and link state routing are the most popular. Distance
vector routing algorithms operate by having each router maintain a table (i.e., vector) giving the best known
distance to each destination and which line to get there. These tables are updated by exchanging information
with the neighbors.
The distance vector routing algorithm uses Bellman-Ford routing algorithm and Ford-Fulkerson algorithm.
In distance vector routing, each router maintains a routing table that contains two parts: the preferred out going
line to use for that destination, and an estimate of the time or distance to that destination. The metric used might
be number of hops, time delay in milliseconds, total number of packets queued along the path, or something
similar.
The Routing tables are shared among the neighbors, and the tables at the router are updated, such that the
router will know the shortest path to the destination.
Program:
import java.util.Scanner;
public class BellmanFord {
private int D[];
private int num_ver;
D = new int[num_ver+1];
}
public void BellmanFordEvaluation(int source,int a[][]){
for(int node=1 ;node <= num_ver ;node++){
D[node]=MAX_VALUE;
}
D[source]=0;
for(int node=1 ;node <= num_ver; node++){
for(int sn=1; sn <= num_ver; sn++){
for(int dn=1; dn <= num_ver; dn++){
if(a[sn][dn] < 0)
D[dn]=0;
else{
if(a[sn][dn] != MAX_VALUE){
if(D[dn] > D[sn]+a[sn][dn])
D[dn] = D[sn]+a[sn][dn];
}
}
}
}
}
for(int sn=1; sn <= num_ver; sn++){
for(int dn=1; dn <= num_ver; dn++){
if(a[sn][dn] != MAX_VALUE){
if(D[dn] > D[sn]+a[sn][dn]){
System.out.println("the graph contains negative edge
cycle");
}
}
}
}
for(int vertex=1; vertex <= num_ver; vertex++){
System.out.println("distance of source "+ source + " to "+ vertex +" is
"+D[vertex]);
}
public static void main(String args[]){
int num_ver=0,source;
}
Input graph:
5
A B
3
4
C D
2
Output:
Aim: Using TCP/IP sockets, write a client – server program to make the client send the file name
and to make the server send back the contents of the requested file if present. Implement the above
program using as message queues or FIFOs as IPC channels.
Theory:
Socket is an interface which enables the client and the server to communicate and pass on
information from one another. Sockets provide the communication mechanism between two
computers using TCP. A client program creates a socket on its end of the communication and
attempts to connect that socket to a server. When the connection is made,
theservercreatesasocketobjectonitsendofthecommunication.Theclientandthe server can now
communicate by writing to and reading from the socket.
Procedure:
import java.net.*;
import java.io.*;
import java.net.*;
import java.io.*;
System.out.println(str);
pwrite.close();
SocketRead.close();
keyRead.close();
}
}
}
OUTPUT:
Create a text file say abc.txt and type some content in it.
Compile and execute server side program
Aim: Write a program on datagram socket for client/server to display the messages on client side,
typed at the server side.
Theory
A datagram socket is the one for sending or receiving point for a packet delivery
service. Each packet sent or received on a datagram socket is individually addressed and routed.
Multiple packets sent from one machine to another may be routed differently, and may arrive in
any order.
Procedure:
import java.io.*;
import java.net.*;
import java.net.*;
class udpser {
public static void main(String args[]) throws Exception
{
import java.io.*;
import java.net.*;
class udpcl {
public static void main(String[]args) throws Exception
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
DatagramSocket clientsocket=new DatagramSocket();
InetAddress IPaddress=InetAddress.getByName("localhost");
byte[] sendData=new byte[1024];
byte[] receiveData=new byte[1024];
String sentence="hello server";
sendData=sentence.getBytes();
DatagramPacket sendPacket=new DatagramPacket(sendData,sendData.length,IPaddress,9876);
clientsocket.send(sendPacket);
DatagramPacket receivePacket=new DatagramPacket(receiveData,receiveData.length);
clientsocket.receive(receivePacket);
String modifiedsentence=new String(receivePacket.getData());
System.out.println("FROM SERVER:" +modifiedsentence);
clientsocket.close();
}
}
OUTPUT
Compile and execute server side program
Aim: To write a program for simple RSA algorithm to encrypt and decrypt the data.
Theory
Cryptography is the study of creating ciphers(cipher text) and breaking them (cryptanalysis). The message to
be encrypted, known as the plaintext, are transformed by a function that is parameterized by a key. The output
of the encryption process, known as the ciphertext, is then transmitted. often by messenger or radio. The hacker,
or intruder, hears and accurately copies down the complete ciphertext. However, unlike the intended recipient,
he does not know the decryption key and so cannot decrypt the ciphertext easily.
There are several ways of classifying cryptographic algorithms. They are generally categorized based on the
number of keys that are employed for encryption and decryption, and further defined by their application and
use. The three types of algorithms are as follows:
1. Secret Key Cryptography (SKC): Uses a single key for both encryption and decryption. It is also known as
symmetric cryptography.
2. Public Key Cryptography (PKC): Uses one key for encryption and another for decryption. It is also known
as asymmetric cryptography.
3. Hash Functions: Uses a mathematical transformation to irreversibly "encrypt" information
Public-key cryptography has been said to be the most significant new development in cryptography. Modern
PKC was first described publicly by Stanford University professor Martin Hellman and graduate student
Whitfield Diffie in 1976. In public key cryptography, one key is used to encrypt the plaintext and the other key
is used to decrypt the ciphertext.
In PKC, one of the keys is designated the public key and may be advertised as widely as the owner wants.
The other key is designated the private key and is never revealed to another party. It is straight forward to send
messages under this scheme. Public key of the receiver is used for encryption, so that only the receiver can
decrypt the message (using his private key).
The RSA algorithm is named after Ron Rivest, Adi Shamir and Len Adleman, who invented it in 1977. The
RSA algorithm can be used for both public key encryption and digital signatures.
Algorithm
1. Generate two large random primes, P and Q, of approximately equal size.
2. Compute N = P x Q
3. Compute Z = (P-1) x (Q-1).
4. Choose an integer E, 1 < E < Z, such that GCD (E, Z) = 1
5. Compute the secret exponent D, 1 < D < Z, such that E x D ≡ 1 (mod Z)
6. The public key is (N, E) and the private key is (N, D).
The message is encrypted using public key and decrypted using private key.
Note that we don't have to calculate the full value of 13 to the power 7 here. We can make use of the fact that
a = bc mod n = (b mod n).(c mod n) mod n so we can break down a potentially large number into its
components and combine the results of easier, smaller calculations to calculate the final value.
Program:
import java.io.DataInputStream;
import java.io.IOException;
import java.math.*;
import java.util.Random;
public class rsa {
private BigInteger p,q,n,phi,e,d;
private int bitlength=1024;
private Random r;
public rsa(){
r =new Random();
p=BigInteger.probablePrime(bitlength,r);
q=BigInteger.probablePrime(bitlength,r);
n=p.multiply(q);
phi=p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE));
e=BigInteger.probablePrime(bitlength,r);
while(phi.gcd(e).compareTo(BigInteger.ONE)>0 && e.compareTo(phi)<0){
e.add(BigInteger.ONE);
}
d=e.modInverse(phi);
}
public rsa(BigInteger e,BigInteger d,BigInteger n){
this.e=e;
this.d=d;
this.n=n;
}
public static void main(String[] args)throws IOException {
rsa rsa=new rsa();
DataInputStream in=new DataInputStream(System.in);
String teststring;
System.out.println("enter the plain text:");
teststring=in.readLine();
System.out.println("encrypting string:"+teststring);
System.out.println("string in bytes:"+bytestostring(teststring.getBytes()));
byte[]encrypted=rsa.encrypt(teststring.getBytes());
byte[]decrypted=rsa.decrypt(encrypted);
System.out.println("decrypting bytes:"+bytestostring(decrypted));
System.out.println("decrypting string:"+new String(decrypted));
}
private static String bytestostring(byte[]encrypted){
String test=" ";
for(byte b:encrypted){
test+=Byte.toString(b);
}
return test;
}
public byte[]encrypt(byte[]message){
return(new BigInteger(message)).modPow(e,n).toByteArray();
}
public byte[]decrypt(byte[]message){
return(new BigInteger(message)).modPow(d,n).toByteArray();
}
}
Output:
Aim: To write a program for congestion control using leaky bucket algorithm.
Theory
The congesting control algorithms are basically divided into two groups: open loop and closed loop. Open
loop solutions attempt to solve the problem by good design, in essence, to make sure it does not occur in the
first place. Once the system is up and running, midcourse corrections are not made. Open loop algorithms are
further divided into ones that act at source versus ones that act at the destination.
In contrast, closed loop solutions are based on the concept of a feedback loop if there is any congestion.
Closed loop algorithms are also divided into two sub categories: explicit feedback and implicit feedback. In
explicit feedback algorithms, packets are sent back from the point of congestion to warn the source. In implicit
algorithm, the source deduces the existence of congestion by making local observation, such as the time needed
for acknowledgment to come back.
The presence of congestion means that the load is (temporarily) greater than the resources (in part of the
system) can handle. For subnets that use virtual circuits internally, these methods can be used at the network
layer.
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.
Program:
import java.math.*;
import java.util.*;
import java.util.Random;
import java.io.*;
import java.lang.*;
public class leaky{
public static void main(String[]args){
int drop=0,mini,i,o_rate,b_size,nsec,p_remain=0;
int packet[]=new int[100];
Scanner in=new Scanner(System.in);
System.out.print("enter the bucket size");
b_size=in.nextInt();
System.out.print("enter output rate");
o_rate=in.nextInt();
System.out.print("enter the number of seconds to simulate");
nsec=in.nextInt();
Random rand=new Random();
for(i=0;i<nsec;i++)
packet[i]=(rand.nextInt(1000));
System.out.println("seconds packet received packet sent packets left packets dropped");
System.out.println("----------------------");
for(i=0;i<nsec;i++){
p_remain+=packet[i];
if(p_remain>b_size){
drop=p_remain-b_size;
p_remain=b_size;
System.out.print(i+1 +" ");
System.out.print(packet[i] +" ");
mini=Math.min(p_remain,o_rate);
System.out.print(mini +" ");
p_remain=p_remain-mini;
System.out.print(p_remain +" ");
System.out.println(drop +" ");
System.out.print(" " );
drop=0;
}
}
while(p_remain!=0){
if(p_remain>b_size){
drop=p_remain-b_size;
}
mini=Math.min(p_remain,o_rate);
System.out.print(" "+p_remain +" " +mini);
p_remain=p_remain-mini;
System.out.println(" "+p_remain +" " +drop);
drop=0;
}
}
Output:
1) What is a Link?
A link refers to the connectivity between two devices. It includes the type of cables and protocols used
in order for one device to be able to communicate with the other.
4) What is a LAN?
LAN is short for Local Area Network. It refers to the connection between computers and other
network devices that are located within a small physical location.
5) What is a node?
A node refers to a point or joint where a connection takes place. It can be computer or device that is
part of a network. Two or more nodes are needed in order to form a network connection.
Data encapsulation is the process of breaking down information into smaller manageable chunks
before it is transmitted across the network. It is also in this process that the source and destination
addresses are attached into the headers, along with parity checks.
15) What is the job of the Network Layer under the OSI reference model?
The Network layer is responsible for data routing, packet switching and control of network congestion.
Routers operate under this layer.
16) How does a network topology affect your decision in setting up a network?
Network topology dictates what media you must use to interconnect devices. It also serves as basis on
what materials, connector and terminations that is applicable for the setup.
The physical layer does the conversion from data bits to electrical signal, and vice versa. This is where
network devices and cable types are considered and setup.
23) What are proxy servers and how do they protect computer networks?
Proxy servers primarily prevent external users who identifying the IP addresses of an internal network.
Without knowledge of the correct IP address, even the physical location of the network cannot be
identified. Proxy servers can make a network virtually invisible to external users.
25) What is the importance of implementing a Fault Tolerance System? Are there
limitations?
A fault tolerance system ensures continuous data availability. This is done by eliminating a single
point of failure. However, this type of system would not be able to protect data in some cases, such as
in accidental deletions.
30) What is OSI and what role does it play in computer networks?
OSI (Open Systems Interconnect) serves as a reference model for data communication. It is made up
of 7 layers, with each layer defining a particular aspect on how network devices connect and
communicate with one another. One layer may deal with the physical media used, while another layer
dictates how data is actually transmitted across the network.
31) What is the purpose of cables being shielded and having twisted pairs?
The main purpose of this is to prevent crosstalk. Crosstalks are electromagnetic interferences or noise
that can affect data being transmitted across cables.
34) What is the equivalent layer or layers of the TCP/IP Application layer in terms of OSI
reference model?
The TCP/IP Application layer actually has three counterparts on the OSI model: the Session layer,
Presentation Layer and Application Layer.
Gateways provide connectivity between two or more network segments. It is usually a computer that
runs the gateway software and provides translation services. This translation is a key in allowing
different systems to communicate on the network.
TCP/IP is short for Transmission Control Protocol / Internet Protocol. This is a set of protocol layers
that is designed to make data exchange possible on different types of computer networks, also known
as heterogeneous network.
51) What protocol can be applied when you want to transfer files between different platforms,
such between UNIX systems and Windows servers?
Use FTP (File Transfer Protocol) for file transfers between such different servers. This is possible
because FTP is platform independent.
53) One way of securing a network is through the use of passwords. What can be considered as
good passwords?
Good passwords are made up of not just letters, but by combining letters and numbers. A password
that combines uppercase and lowercase letters is favorable than one that uses all upper case or all
lower case letters. Passwords must be not words that can easily be guessed by hackers, such as dates,
names, favorites, etc. Longer passwords are also better than short ones.
57) What happens when you use cables longer than the prescribed length?
Cables that are too long would result in signal loss. This means that data transmission and reception
would be affected, because the signal degrades over length.
63) What advantages does fiber optics have over other media?
One major advantage of fiber optics is that is it less susceptible to electrical interference. It also
supports higher bandwidth, meaning more data can be transmitted and received. Signal degrading is
also very minimal over long distances.
65) What are the different network protocols that are supported by Windows RRAS services?
There are three main network protocols supported: NetBEUI, TCP/IP, and IPX.
66) What are the maximum networks and hosts in a class A, B and C network?
For Class A, there are 126 possible networks and 16,777,214 hosts
For Class B, there are 16,384 possible networks and 65,534 hosts
For Class C, there are 2,097,152 possible networks and 254 hosts
67) What is the standard color sequence of a straight-through cable?
orange/white, orange, green/white, blue, blue/white, green, brown/white, brown.
68) What protocols fall under the Application layer of the TCP/IP stack?
The following are the protocols under TCP/IP Application layer: FTP, TFTP, Telnet and SMTP.
69) You need to connect two computers for file sharing. Is it possible to do this without using a
hub or router?
Yes, you can connect two computers together using only one cable. A crossover type cable can be use
in this scenario. In this setup, the data transmit pin of one cable is connected to the data receive pin of
the other cable, and vice versa.
74) When you move the NIC cards from one PC to another PC, does the MAC address gets
transferred as well?
Yes, that's because MAC addresses are hard-wired into the NIC circuitry, not the PC. This also means
that a PC can have a different MAC address when the NIC card was replace by another one.
76) In a network that contains two servers and twenty workstations, where is the best place to
install an Anti-virus program?
An anti-virus program must be installed on all servers and workstations to ensure protection. That's
because individual users can access any workstation and introduce a computer virus when plugging in
their removable hard drives or flash drives.
77) Describe Ethernet.
Ethernet is one of the popular networking technologies used these days. It was developed during the
early 1970s and is based on specifications as stated in the IEEE. Ethernet is used in local area
networks.
In case one workstation on the network suffers a malfunction, it can bring down the entire network.
Another drawback is that when there are adjustments and reconfigurations needed to be performed on
a particular part of the network, the entire network has to be temporarily brought down as well.
86) What are the different technologies involved in establishing WAN links?
Analog connections - using conventional telephone lines; Digital connections - using digitalgrade
telephone lines; switched connections - using multiple sets of links between sender and receiver to
move data.
90) How does dynamic host configuration protocol aid in network administration?
Instead of having to visit each client computer to configure a static IP address, the network
administrator can apply dynamic host configuration protocol to create a pool of IP addresses known as
scopes that can be dynamically assigned to clients.
ADDITIONAL PROGRAMS
Below example first encrypt the file using DES algorithm and save encrypted data to new
file. Then it decrypts the same file to create the plain text file.
package com.journaldev.des;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
private static final byte[] iv = { 11, 22, 33, 44, 99, 88, 77, 66 };
try {
encryptCipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
decryptCipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
System.out.println("DONE");
| InvalidAlgorithmParameterException | IOException e) {
e.printStackTrace();
writeData(is, os);
writeData(is, os);
// utility method to read data from input stream and write to output stream
int numRead = 0;
os.write(buf, 0, numRead);
os.close();
is.close();
REFERENCES
1. https://www.isi.edu/nsnam/ns/
2. http://aknetworks.webs.com/e-books
3. Communication Networks: Fundamental Concepts and Key Architectures - Alberto Leon,
Garcia and Indra Widjaja, 4th Edition, Tata McGraw- Hill,reprint-2012.
4. Data and Computer Communication, William Stallings, 8th tEdition, Pearson
Education,2009.
5. ComputerNetworks:ASystemsApproach-LarryL.PetersonandBruceS.David,4th Edition,
Elsevier,2009.
6. Introduction to Data Communications and Networking – Wayne Tomasi, Pearson
Education,2009.
7. CommunicationNetworks–FundamentalConceptsandKeyarchitectures–Alberto Leon-
Garcia and Indra Widjaja:, 2rd Edition, Tata McGraw-Hill,2009
8. Computer and Communication Networks – Nader F. Mir:, Pearson Education,2012