Professional Documents
Culture Documents
PRACTICAL 1
AIM-Write a program in java to demonstrate one-way communication between one client and one
server.
import java.net.*;
import java.io.*;
public class Client{
public static void main(String[] args) throws IOException {
Socket s = new Socket("localhost",4999);
PrintWriter pr = new PrintWriter(s.getOutputStream());pr.println("
is it working");
pr.flush();
InputStreamReader in = new InputStreamReader(s.getInputStream());
BufferedReader bf= new BufferedReader(in);
String str = bf.readLine();
System.out.println("server : " +str);
}
}
SERVER
import java.net.*;
import java.io.*;
public class Server{
public static void main(String[] args) throws IOException {
ServerSocket ss = new ServerSocket(4999);
Socket s = ss.accept();
System.out.println("Client Connected.");
InputStreamReader in = new InputStreamReader(s.getInputStream());
BufferedReader bf= new BufferedReader(in);
String str = bf.readLine();
System.out.println("client : " +str);
PrintWriter pr = new PrintWriter(s.getOutputStream());
pr.println("yes");
pr.flush();
}
}
PRACTICAL-2
AIM- Write a program in java to establish a two-way Communication between Server and Client
modules.
import java.io.*;
import java.net.*;
class Server2 {
public static void main(String args[])
throws Exception
Socket s = ss.accept();
System.out.println("Connection established");
PrintStream ps
= new PrintStream(s.getOutputStream());
BufferedReader br
= new BufferedReader(
new InputStreamReader(
s.getInputStream()));
BufferedReader kb
= new BufferedReader(
new InputStreamReader(System.in));
while (true) {
System.out.println(str);
str1 = kb.readLine();
// send to client
ps.println(str1);
// close connection
ps.close();
br.close();
kb.close();
ss.close();
s.close();
// terminate application
System.exit(0);
} // end of while
CLIENT2
import java.net.*;
class Client2 {
throws Exception
DataOutputStream dos
= new DataOutputStream(
s.getOutputStream());
BufferedReader br
= new BufferedReader(
new InputStreamReader(
s.getInputStream()));
BufferedReader kb
= new BufferedReader(
new InputStreamReader(System.in));
dos.writeBytes(str + "\n");
str1 = br.readLine();
System.out.println(str1);
// close connection.
dos.close();
br.close();
kb.close();
s.close();
OUTPUT:
PRACTICAL-3
Once the downloading is finished, open the folder that contains the downloaded file.
Double click the setup or installer file of Packet Tracer. Depending on UAC (User Access
Control) setting, Windows may prompt to confirm the installation. If it prompts, click
the Yes button to confirm the installation. After confirmation, the installation process starts
in a graphical wizard.
The first screen of the installation wizard presents the license agreement. Select the "I accept
the agreement" option and click the "Next" button.
The next screen provides an option to customize the installation directory. By default, Packet
Tracer is installed in the "Program File" folder of the Windows partition. If you want to
install Packet Tracer in another folder, click the Browse button and select the folder in which
you want to install Packet Tracer.
A shortcut-link name is used to launch an application from the Start menu. By default, the
wizard uses the name "Cisco Packet Tracer" for both the folder-name and the shortcut-link
name.
The next screen allows us to create two more shortcut links to launch the Packet Tracer.
Create a desktop icon: - This option creates a shortcut link on the Desktop.
Create a quick launch icon: - This option creates a shortcut link in the Quick-Launch bar.
Make your choice and click the Next button.
The next screen provides a summary of selections. If you want to change an option, use
the Back button to get that option. To start the installation with currently selected options,
click the Install button.
If the installation is successful, this screen shows an option to launch the Packet Tracer. If you
keep this option selected, the packet tracer starts when the wizard is closed.
When Packet Tracer starts the first time, it asks the user to select the mode in which it should
start. Multi-user mode allows multiple users to work simultaneously. If you don't want to
share or exchange your packet tracer instance, click the No button.
Activating Packet Tracer
Since version 7.0.0, Packet Tracer can only be used after login. When you start Packet Tracer,
it presents a login box. If the system is not connected to the Internet, you can use
the Guest account to access Packet Tracer.
The guest account offers limited features. This account allows you to save only 3 practice
labs.
To remove this restriction, you must log in to Packet Tracer from a Cisco Academy account.
To create a free Cisco Academy account, visit the following web page.
https://www.netacad.com/courses/packet-tracer/introduction-packet-tracer
Visit the above web-page and create a free user account and use that user account to login
to Packet Tracer.
Upon successful authentication, Packet Tracer will be activated and all restrictions will be
removed.
To provide a hassle-free access, Packet Tracer automatically saves login information and uses
that information to log in automatically when you start Packet Tracer again the next time.
The Packet Tracer does not ask you to login again until you log-out manually.
If you want to logout from Packet Tracer, click the File menu item and click the "Exit and
Logout" option from the sub-menu options.
Once you are logged out, all restrictions will apply again. You must log in again to use Packet
Tracer without restrictions.
If you use multiple copies of Packet Tracer to teach CCNA courses, there is no need to create
multiple user accounts. You can use a single user account to log in to as many copies of
Packet Tracer as you want. So instead of creating multiple user accounts, use only one user
account to login to all copies of the Packet Tracer.
PRACTICAL-4
NS2 builds and runs under windows using Cygwin. Cygwin provides Linux like
environment under windows.
2. Run the downloaded setup.exe and you will see screen shown below click
next.
3. Select option "Install From Internet". If you have already downloaded the
package select "Install from local directory" and click next
6. Next screen will ask for your Internet connection type keep it as "Direct
connection" and click next and in next screen choose one site to download the
packages and click next.
7. In next screen Cygwin will allow to select the packages you want to install
8. Uncheck the option "Hide obsolete packages" then click on "view" button till
the word "category" changes to "Full"
2. gcc-g++
3. gnuplot
4. make
5. patch
6. perl
7. tar
8. X-startup-scripts
9. xorg-x11-base
10. xorg-x11-bin
11. xorg-x11-devel
12. xorg-x11-bin-dlls
13. xorg-x11-bin-lndir
14. xorg-x11-etc
15. xorg-x11-fenc
16. xorg-x11-fnts
17. xorg-x11-libs-data
18. xorg-x11-xwin
19. libxt-devel
20. libXmu-devel
To select a package search the package name and click on word "skip" this will
change it to version number of the package. Do this for all above packages and
click next to start download and installation
9. Once installation is complete create desktop icons if you need.
NOTE: If you missed any package while installing Cygwin first time you can
install it by running the setup.exe again and selecting the package in step 8.
10. Cygwin installation is complete now you can run Cygwin from desktop and
see its interface.
2. Decompress the file use winrar. Copy the decompressed folder the Cygwin
installation directory under the subdirectory home. It will be C:\cygwin\home\
system_name : where system_name is name of your system in above Cygwin
installation this path will be C:\Cygwin\home\sys27
3. Run Cygwin from desktop and change the directory to folder you copied just
now in step 2 command to change directory:cd /home/sys27/ns-allinone-2.28
Installation is a long process and take quite some time once it is finished you will
get a screen as shown below:
export NS_HOME=/home/sys27/ns-allinone-2.28
export
PATH=$NS_HOME/nam-1.11:$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:
$NS_HOME/bin:$PATH
export LD_LIBRARY_PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:
$NS_HOME/otcl-1.9:$NS_HOME/lib:$LD_LIBRARY_PATH
export TCL_LIBRARY=$NS_HOME/tcl8.4.5/library
6. To check if NS2 is installed correctly you can run one sample example given in
ns-tutorials folder
ns example2.tcl
PRACTICAL-5
OPNET Network simulator is a tool to simulate the behavior and performance of any type of
network. The main difference Opnet Network Simulator comparing to other simulators lies in
its power and versatility. IT Guru provides pre-built models of protocols and devices. It allows
you to create and simulation different network topologies. The set of protocols/devices is
fixed – you cannot create new protocols nor modify the behavior of existing ones.
Advantages of Opnet Network Simulator:
Opnet Network Simulator is a open free software
Large number of project scenarios that are offered information on Opnet Network Simulator
Can be overlooked using Opnet Network Simulator.
Uses of opnet simulator:
Operational validation.
Application troubleshooting.
Network planning and design.
Validating hardware architecture.
Protocol modeling.
Traffic modeling of telecommunication networks.
Evaluating performance aspects of complex software systems.
Discrete event simulation workflow:
Create/import topology/configuration.
Create traffic.
Choose statistics
Run simulation.
View results.
Duplicate or create new scenario.
Publish results.
PRACTICAL-6
AIM- Design the connectivity between 2 PC's in cisco packet tracer when
a) they are on same network (via ping and/or message sending)
b) they are on different network (via ping and/or message sending)
: a).
B)
1. AIM-Design and Implement following topologies in packet tracer(show the simulation mode
along with proper labelling and use colour schemes to distinguish networks)
a. bus topology
b. star topology(using i) switch, ii) hub)
c. ring topology
d. mesh topology
e. Hybrid topology(using all above)
2. Bus Topology:-
3)Ring topology:
PRACTICAL-8
DHCP can be implemented on local networks as well as large enterprise networks. DHCP is
the default protocol used by the most routers and networking equipment. DHCP is also
called RFC (Request for comments) 2131.
PRACTICAL-9
Routers forward packets using either route information from route table entries that you
manually configure or the route information that is calculated using dynamic routing
algorithms.
Static routes, which define explicit paths between two routers, cannot be automatically
updated; you must manually reconfigure static routes when network changes occur. Static
routes use less bandwidth than dynamic routes. No CPU cycles are used to calculate and
analyze routing updates.
You can supplement dynamic routes with static routes where appropriate. You can
redistribute static routes into dynamic routing algorithms but you cannot redistribute routing
information calculated by dynamic routing algorithms into the static routing table.
You should use static routes in environments where network traffic is predictable and where
the network design is simple. You should not use static routes in large, constantly changing
networks because static routes cannot react to network changes. Most networks use
dynamic routes to communicate between routers but may have one or two static routes
configured for special cases. Static routes are also useful for specifying a gateway of last
resort (a default router to which all unroutable packets are sent).
PRACTICAL-10
REPORT THIS AD
Step 3:Assign IP Address and Hostname on Router R1:
ASSIGN IP ADDRESS ON INTERFACE FA0/0
Router>enable
Router#config terminal
Router(config)#host R1
R1(config)#int fa0/0
R1(config-if)#no shut
R1(config-if)#exit
R1(config-if)#no shut
Step 4: Assign IP Address on Router R2:
ASSIGN IP ADDRESS ON INTERFACE FA0/0
Router(config)#host R2
R2(config)#int fa0/0
R2(config-if)#no shut
R2(config)#int fa0/1
R2(config-if)#no shut
Using the Cisco Packet Tracer, select three Cisco 2811 routers, three 2960 Cisco Catalyst switches,
and six desktop computers. To get the serial connections, click on the router, click on physical, switch
off the router, click and drag the WIC-1T module to one of the expansion slots. For router1, I added
two modules of WIC-1T because router1 has two serial connections. The image below shows how it
is added.
Implementation
On Router0: I will configure both the serial and f0/0 interfaces, implement static routes to get to the
three networks that are unknown to Router0, namely: networks 192.168.0.4/30, 192.168.2.0/24 and
192.168.3.0/24. See commands below:
Router(config)#hostname Router0
Router0(config)#int s0/3/0
Router0(config-if)#description connection-to-Router1
Router0(config-if)#no shut
Router0(config-if)#int f0/0
Router0(config-if)#desc connection-to-LAN
Router0(config-if)#no shut
Router0(config-if)#exit
On Router1: when setting up the serial connections to both router0 and Router2, I made sure to click
on router1 first. This ensured that router1 became the DCE for both serial links. With this, the
clocking for both serial connections will be done on router1 while the two networks, namely, network
192.168.1.0/24 and network 192.168.3.0/24, unknown to router1, will be statically entered in
router1’s routing table using static route. Let’s see the codes below.
Router(config)#hostname Router1
Router1(config)#int s0/3/0
Router1(config-if)#description connection-to-Router0
Router1(config-if)#no shut
Router1(config)#int s0/1/0
Router1(config-if)#description connection-to-Router2
Router1(config-if)#no shut
Router1(config-if)#int f0/0
Router1(config-if)#desc connection-to-LAN
Router1(config-if)#no shut
Router1(config-if)#exit
On Router2: the configuration on Router2 will be similar to that of Router0, the difference will be in
the networks configured on interfaces and advertised using static routes. The three networks that are
unknown to Router2 and need to be statically entered in its routing table are networks 192.168.0.0/30,
192.168.1.0/24 and 192.168.2.0/24. Let’s see how to achieve this from the commands below.
Router(config)#hostname Router2
Router2(config)#int s0/3/0
Router2(config-if)#description connection-to-Router1
Router2(config-if)#no shut
Router2(config-if)#int f0/0
Router2(config-if)#desc connection-to-LAN
Router2(config-if)#no shut
Router2(config-if)#exit
Verification
To verify, we need to look at the routing tables of the routers using the sh ip route command. Below is
the output of the command on router0:
From the output above, we can see that router0 has route entries for networks 192.168.0.4/30,
192.168.2.0/24, and 192.168.3.0/24. These routes were learned from router1 (192.168.0.2) using static
routes, hence, the S symbol, and they all have the default administrative distance of 1. Let’s run a ping
from router0 to the LAN interface on router2 (192.168.3.1)
.
Conclusion
In configuring a static route, the command ip route is used, followed by the network you intend to
reach from the local router, then the subnetmask of the network, then, the gateway to reach the
network. The gateway must be reachable from the router on which the static route is being configured
and it must also have connectivity to the destination network being advertised.