You are on page 1of 40

NAME- ATISH SHARMA

CLASS - B.VOC 5TH SEMESTER

ROLL NO- 02650118119

SUBJECT- ACN LAB FILE

SUBMITTED TO – MS. BUSHRA JAMAL

PRACTICAL 1

AIM-Write a program in java to demonstrate one-way communication between one client and one
server.

ONE WAY COMMUNICATION BETWEEN CLIENT AND SERVER VSCODE:


CLIENT:

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.

// Server2 class that

// receives data and sends data

import java.io.*;

import java.net.*;

class Server2 {
public static void main(String args[])

throws Exception

// Create server Socket

ServerSocket ss = new ServerSocket(888);

// connect it to client socket

Socket s = ss.accept();

System.out.println("Connection established");

// to send data to the client

PrintStream ps

= new PrintStream(s.getOutputStream());

// to read data coming from the client

BufferedReader br

= new BufferedReader(

new InputStreamReader(

s.getInputStream()));

// to read data from the keyboard

BufferedReader kb

= new BufferedReader(

new InputStreamReader(System.in));

// server executes continuously

while (true) {

String str, str1;


// repeat as long as the client

// does not send a null string

// read from client

while ((str = br.readLine()) != null) {

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

// Client2 class that

// sends data and receives also


import java.io.*;

import java.net.*;

class Client2 {

public static void main(String args[])

throws Exception

// Create client socket

Socket s = new Socket("localhost", 888);

// to send data to the server

DataOutputStream dos

= new DataOutputStream(

s.getOutputStream());

// to read data coming from the server

BufferedReader br

= new BufferedReader(

new InputStreamReader(

s.getInputStream()));

// to read data from the keyboard

BufferedReader kb

= new BufferedReader(

new InputStreamReader(System.in));

String str, str1;

// repeat as long as exit

// is not typed at client


while (!(str = kb.readLine()).equals("exit")) {

// send to the server

dos.writeBytes(str + "\n");

// receive from the server

str1 = br.readLine();

System.out.println(str1);

// close connection.

dos.close();

br.close();

kb.close();

s.close();

OUTPUT:
PRACTICAL-3

AIM- Installation and introduction to packet tracer.

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.

Make your choice and click the Next button to continue the installation.


The next screen allows us to customize the shortcut-link name and the location of Packet
Tracer in the Start menu.

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.

Keep default selections and click the Next button.

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.

The wizard displays the real-time progress of the installation.


The last screen of the wizard displays the result of the installation. If any error occurred
during the installation, this screen displays that error. If the installation process is completed
without any error and notice, this screen shows the confirmation message.

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.

Click the Finish button to close the wizard.

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.

To use a guest account, click the Guest login button on startup.

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

AIM- Introduction and installation of ns-2(any of Windows(via Cygwin)/Linux )

Installing NS2 on windows 7

NS2 builds and runs under windows using Cygwin. Cygwin provides Linux like
environment under windows.

System Requirements: A computer with C++ compiler. Building full NS2


package requires large memory space approximately 250MB

I. Steps to install NS 2 on windows 7 are given below

1. Download Cygwin from following link https://www.cygwin.com/setup.exe

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

4. Keep the default installation directory as "C:\cygwin" and click next


5. Keep default local package directory as your download folder 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"

To install NS2 you need to select and install following packages:


1. gcc

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.

II. Steps is to install NS2

1. Download NS2 from following link: https://www.isi.edu/nsnam/dist/ns-


allinone-2.28.tar.gz

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

NOTE: please change sys27 to name of your system

4. To start installation type following command:"./install"(WITHOUT qoutes)


This will began the installation process if any Cygwin package is missing it will be
reported to you if so the run Cygwin setu.exe and install the missing package
and start again from step 2.

Installation is a long process and take quite some time once it is finished you will
get a screen as shown below:

5. Add following lines to the .bashrc

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

NOTE: replace sys27 with your system name

6. To check if NS2 is installed correctly you can run one sample example given in
ns-tutorials folder

To run the example change the directory to examples folder: cd


./home/sys27/ns-allinone-2.28/ns-tutorial/examples

Then type following command:

ns example2.tcl
 
PRACTICAL-5

AIM- Introduction to OPNET Simulator.

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)

2) Experiment router configuration in cisco packet tracer.


PRACTICAL-7

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:-

2) Star topology using:


1) Switch
2)Hub

3)Ring topology:
PRACTICAL-8

AIM- Design and implement client-server connection (via DHCP)

Dynamic Host Configuration Protocol (DHCP) is a network management protocol used to


dynamically assign an IP address to nay device, or node, on a network so they can
communicate using IP (Internet Protocol). DHCP automates and centrally manages these
configurations. There is no need to manually assign IP addresses to new devices. Therefore,
there is no requirement for any user configuration to connect to a DHCP based network.

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

AIM- Implement static routing and dynamic routing in packet tracer

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

AIM-Configure IP static routing using 2 routers, 2 Switches, 4 Pc


Step 1: Draw the topology Diagram using cisco Packet Tracer as shown below.

static routing lab

Step 2: Assign IP Address and gateway IP on Both PC as Shown below.


Advertisements

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)#ip add 192.168.1.1 255.255.255.0

R1(config-if)#no shut

R1(config-if)#exit

Assign IP Address on Interface Fa0/1


R1(config)#int fa0/1

R1(config-if)#ip add 192.168.2.1 255.255.255.0

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)#ip add 192.168.2.2 255.255.255.0

R2(config-if)#no shut

Assign IP Address on Interface Fa0/1


R2(config-if)#exit

R2(config)#int fa0/1

R2(config-if)#ip add 192.168.3.1 255.255.255.0

R2(config-if)#no shut

Step 5: Static Routing Configuration on Router R1:


R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2

Step 6: Static Routing Configuration on Router R2:


R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1

Step 7: Check and troubleshoot IP Route


R1#show ip route
PRACTICAL-11

AIM- Configure Static Routing using 3 routers, 3 Switches, 6 Pc (5 networks)

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)#ip add 192.168.0.1 255.255.255.252

Router0(config-if)#description connection-to-Router1

Router0(config-if)#no shut

Router0(config-if)#int f0/0

Router0(config-if)#ip add 192.168.1.1 255.255.255.0

Router0(config-if)#desc connection-to-LAN

Router0(config-if)#no shut

Router0(config-if)#exit

Router0(config)#ip route 192.168.0.4 255.255.255.252 192.168.0.2

Router0(config)#ip route 192.168.2.0 255.255.255.0 192.168.0.2

Router0(config)#ip route 192.168.3.0 255.255.255.0 192.168.0.2

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)#ip add 192.168.0.2 255.255.255.252

Router1(config-if)#description connection-to-Router0

Router1(config-if)#clock rate 64000

Router1(config-if)#no shut

Router1(config)#int s0/1/0

Router1(config-if)#ip add 192.168.0.5 255.255.255.252

Router1(config-if)#description connection-to-Router2

Router1(config-if)#clock rate 64000

Router1(config-if)#no shut
Router1(config-if)#int f0/0

Router1(config-if)#ip add 192.168.2.1 255.255.255.0

Router1(config-if)#desc connection-to-LAN

Router1(config-if)#no shut

Router1(config-if)#exit

Router1(config)#ip route 192.168.2.0 255.255.255.0 192.168.0.1


Router1(config)#ip route 192.168.3.0 255.255.255.0 192.168.0.6

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)#ip add 192.168.0.6 255.255.255.252

Router2(config-if)#description connection-to-Router1

Router2(config-if)#no shut

Router2(config-if)#int f0/0

Router2(config-if)#ip add 192.168.3.1 255.255.255.0

Router2(config-if)#desc connection-to-LAN

Router2(config-if)#no shut

Router2(config-if)#exit

Router2(config)#ip route 192.168.0.0 255.255.255.252 192.168.0.5


Router2(config)#ip route 192.168.1.0 255.255.255.0 192.168.0.5
Router2(config)#ip route 192.168.2.0 255.255.255.0 192.168.0.5

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.

You might also like