Sie sind auf Seite 1von 58

GOVERNMENT ENGINEERING COLLEGE,

DAHOD
(018)

COMPUTER ENGINEERING (07)

COMPUTER NETWORKS
(2140709)
LAB MANUAL

1
LIST OF PRACTICALS

Sr. No. Practical Name Pg. No. Date


1 To study various Networking Components. 3

2 To study various networking Commands. 8

Perform Installation of the following software: 13


3 a. Wireshark
b. Cisco Packet Tracer
4 To study of Wireshark. 14

5 To Implement LAN using Packet tracer simulator. 16

6 To Implement WAN using Packet tracer simulator. 19


Create a star topology with 5 nodes and a switch and perform 23
7
data transmission between nodes.(Cisco Packet Tracer)
8 To Implement DNS using Packet tracer simulator. 26
9 Implement Concept Of Bit Stuffing. 29

10 Implement Concept of Byte/Char Stuffing. 31

11 Implement Parity Checking mechanism CRC. 33

Write a Program Distance Vector Routing Algorithm. (Try to 36


12
Configure a Network using distant vector routing strategy.

13 To Study the Network Simulator (NS2). 40

To Study Network IP Address. 50


14 a. IPV6 Address with their header format
b. IPV4 Address with their header format
Study about various addresses and addressing schemes. 54
a. Classfull addressing.
15
b. Classless addressing.
c. Logical address, Physical Address, Port Address,URL
16 To study and prepare RJ45 Cable 56

2
Practical: - 1

AIM: To study various Networking Components.

Major computer network components


Computer network requires the following devices (some of them are optional): -

• Network Interface Card (NIC)

• Hub

• Switches

• Cables and connectors

• Router

• Modem

1. Network Interface Card

Network adapter is a device that enables a computer to talk with other computer/network. Using
unique hardware addresses (MAC address) encoded on the card chip, the data-link protocol
employs these addresses to discover other systems on the network so that it can transfer data to
the right destination.

3
There are two types of network cards: wired and wireless. The wired NIC uses cables and
connectors as a medium to transfer data, whereas in the wireless card, the connection is made
using antenna that employs radio wave technology. All modern laptop computers incorporated
wireless NIC in addition to the wired adapter.

Network Card Speed

Network Interface card, one of the main computer network components, comes with different
speeds, 10Mbps, 100Mbps, and 1000Mbps, so on. Recent standard network cards built with
Gigabit (1000Mbps) connection speed. It also supports to connect slower speeds such as
10Mbps and 100Mbps. However, the speed of the card depends on your LAN speed.

For example, if you have a switch that supports up to 100Mbps, your NIC will also transfer a
data with this same speed even though your computer NIC has still the capability to transfer
data at 1000Mbps (1Gbps). In modern computers, network adapter is integrated with a
computer motherboard. However if you want advanced and fast Ethernet card, you may buy and
install on your computer using the PCI slot found on the motherboard (desktop) and Express
Card slots on laptop.

2. Hub

Hub is a device that splits a network connection into multiple computers. It is like a distribution
center. When a computer request information from a network or a specific computer, it sends
the request to the hub through a cable. The hub will receive the request and transmit it to the
entire network. Each computer in the network should then figure out whether the broadcast data
is for them or not.

4
Currently Hubs are becoming obsolete and replaced by more advanced communication devices
such as Switches and Routers.

3. Switch

Switch is a telecommunication device grouped as one of computer network components. Switch


is like a Hub but built in with advanced features. It uses physical device addresses in each
incoming messages so that it can deliver the message to the right destination or port.

Like Hub, switch don’t broadcast the received message to entire network, rather before sending
it checks to which system or port should the message be sent. In other words, switch connects
the source and destination directly which increases the speed of the network. Both switch and
hub have common features: Multiple RJ-45 ports, power supply and connection lights.

4. Cables and connectors

Cable is one way of transmission media which can transmit communication signals. The wired
network typology uses special type of cable to connect computers on a network.

5
There are a number of solid transmission Media types, which are listed below. - Twisted pair
wire

It is classified as Category 1, 2, 3, 4, 5, 5E, 6 and 7. Category 5E, 6 and 7 are high-speed cables
that can transmit 1Gbps or more. -

Coaxial cable

Coaxial cable more resembles like TV installation cable. It is more expensive than twisted-pair
cable but provide high data transmission speed.

Fiber-optic cable

It is a high-speed cable which transmits data using light beams through a glass bound fibers.
Fiber-optic cable is high data transmission cable comparing to the other cable types. But the
cost of fiber optics is very expensive which can only be purchased and installed on
governmental level.

5. Router

When we talk about computer network components, the other device that used to connect a
LAN with an internet connection is called Router. When you have two distinct
networks (LANs) or want to share a single internet connection to multiple computers, we use a
Router.

In most cases, recent routers also include a switch which in other words can be used as a switch.
You don’t need to buy both switch and router, particularly if you are installing small business
and home networks.

There are two types of Router: wired and wireless. The choice depends on your physical
office/home setting, speed and cost.

6
6. Modems

A modem enables you to connect your computer to the available internet connection over the
existing telephone line. Like NIC, Modem is not integrated with a computer motherboard. It
comes as separate part which can be installed on the PCI slots found on motherboard.

A modem is not necessary for LAN, but required for internet connection such as dial-up and
DSL.

There are some types of modems, which differs in speed and transmission rate. Standard PC
modem or Dial-up modems (56Kb data transmission speed), Cellular modem (used in a laptop
that enables to connect while on the go), cable modem (500 times faster than standard
modem) and DSL Modems are the most popular.

7
Practical: - 2

AIM: To study various Networking Commands.


PING:

Ping command for windows:

The ping command to check the destination IP address you want to reach and record the results. The
ping command displays whether the destination responded and how long it took to receive a reply. If
there is an error in the delivery to the destination, the ping command displays an error message.

Output:

IPConfig:

Displays all current TCP/IP network configuration values and refreshes Dynamic Host
Configuration Protocol (DHCP) and Domain Name System (DNS) settings. Used without
parameters, ipconfig displays the IP address, subnet mask, and default gateway for all adapters

Output:

8
TELNET:

The telnet command is used to communicate with another host using the TELNET protocol.
If telnet is invoked without the host argument, it enters command mode, indicated by its prompt
(telnet> ) In this mode, it accepts and executes the commands listed below. If it is invoked with
arguments, it performs an open command with those arguments.

Output:

NETSTAT:

Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP
routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the

9
IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). Used without parameters, netstat
displays active TCP connections.

Output:

TRACEROUTE:

The Internet is a large and complex aggregation of network hardware, connected together by
gateways. Tracking the route one's packets follow (or finding the miscreant gateway that's discarding
your packets) can be difficult. Trace route utilizes the IP protocol `time to live' field and attempts to
elicit an ICMP TIME_EXCEEDED response from each gateway along the path to some host.
Output:

RLOGIN:

Rlogin starts a terminal session on the remote host specified as host. The remote host must be
running an rlogind service (or daemon) for rlogin to connect to. When no user name is specified
either with the -l option or as part of username@hostname, rlogin connects as the user you are
currently logged in as (including either your domain name if you are a domain user or your machine
name if you are not a domain user).

10
Output:

ARP:
Arp manipulates the kernel's ARP cache in various ways. The primary options are clearing
an address mapping entry and manually setting up one. For debugging purposes, the arp program
also allows a complete dump of the ARP cache.

Output:

NSLOOKUP

MS-DOS utility that enables a user to look up an IP address of a domain or host on network.
This command is often used to perform a reverse lookup on an IP address as shown in the below
example. The first section specifies the server and address of that server that provided you with the
domain name and IP address displayed in the second section.

11
Output:

ROUTE:

Route is a command used to view and manipulate the TCP/IP routing table in both Unix-like and
Windows operating. Manual manipulation of the routing table is characteristic of static routing.

Output:

12
Practical: - 3

AIM: Perform Installation of the following software:


A: Wireshark
B: Cisco Packet Tracer
TOOLS AND TECHNOLOGY: CISCO PACKET TRACER & Wireshark.

IMPLEMENTATION:

Installation Steps for Wireshark:

First download Wireshark from following link https://www.wireshark.org/download.html then follow next
steps.

Step 1: Double Click on Setup select next.

Step 2: Accept license and agreement.

Step 3: Select path where setup install.

Step 4: Complete all step till Install Button, setup will Install.

Step 5: Then Select Finish the setup was installed.

Installation Steps for Cisco Packet Tracer:

First download Cisco Packet Tracer from following link https://www.netacad.com/courses/packet-tracer-


download then follow next steps.

Step 1: Double Click on Setup select next.

Step 2: Accept license and agreement.

Step 3: Select path where setup install.

Step 4: Complete all step till Install Button, setup will Install.

Step 5: Then Select Finish the setup was installed.

13
Practical: - 4

AIM: To Study Wireshark.


TOOLS AND TECHNOLOGY: Wireshark.

IMPLEMENTATION: First start Wirehark then, follow next steps.

Step 1: After starting of wireshark it display following screen.

Figure 1

Step 2: Write in filter and select network interface if network interface is Wi-Fi then click on Wi-Fi.

Figure 2

14
Step 3: Click on any packet and click on Hypertext Transfer Protocol (HTTP) for analyze.

Step 4: Also Click on Transport Control Protocol (TCP) for Analyze.

Wireshark is free and open source packet analyzer. It is use for network troubleshooting, analysis, software and
communication protocol development and education. Originally named Ethereal, the project was renamed
wireshark in May-2006.

15
Practical: - 5

AIM: To Implement LAN using Packet tracer simulator.


TOOLS AND TECHNOLOGY: CISCO PACKET TRACER.

IMPLEMENTATION:

First start Cisco Packet Tracer then, Select Guest Login Wait for 15 Seconds and then select left side corner
end devices & other options option then follow next steps.

Step1: Take 5 PCs ,2 Hubs and 1 Switch for LAN configuration.

Figure 1

Step2: Connect all device with appropriate connection:

Figure 2

16
Step3:Click on pc0 than go to Desktop and select IP configuration

Figure 3

Step-4: click on static and give appropriate IP Address for pc0 and close it.

Figure 4

17
Step5: Repeat 3 and 4 steps to Give Appropriate IP Address to all 5 pcs

CONCLUSION:

Thus we have studied and Implement the LAN using Packet tracer simulator.

18
Practical: - 6

AIM: To Implement WAN using Packet tracer simulator.


TOOLS AND TECHNOLOGY:CISCO PACKET TRACER.

IMPLEMENTATION:

First start Cisco Packet Tracer then, Select Guest Login Wait for 15 Seconds and then select left side corner
end devices & other options option then follow next steps.

Step1: Take 5 Router and 2 host PCs for WAN configuration.

Figure 1

Step2: Connect all device with appropriate connection:

Figure 2

19
Step3: Click on pc0 than go to Desktop and select IP configuration

Figure 3

Step-4: Click on static and give appropriate IP Address and default Gateway for pc0 and close it.

Figure 4

Repeat 3 and 4 steps to Give Appropriate IP Address to 2 pcs

20
Step5:.Now ,Click on Router0 than go to config And Select FastEthernet0/0.

Figure 5

Step6: Select port Status on and give Appropriate IP Address to router Same way give Appropriate IP Address to
FastEthernet0/1.

Figure 6

21
Figure 7

Step7: Repeat 5 and 6 steps to Give Appropriate IP Address to FastEthernet0/0 and FastEthernet0/1 for all 5
routers.

WAN Configuration

CONCLUSION:
Thus we have studied and Implement the WAN using Packet tracer simulator.

22
Practical: - 7

AIM: Create a star topology with 5 nodes and a switch and perform data
transmission between nodes. (Cisco Packet Tracer)

TOOLS AND TECHNOLOGY: CISCO PACKET TRACER.

IMPLEMENTATION: First start Cisco Packet Tracer then, Select Guest Login Wait for 15 Seconds and then
select left side corner end devices & other options option then follow next steps.

Step1: Take 5 PCs and 1 switch for Star Topology configuration.

Figure 1

Step2: Connect all device with appropriate connection using connections:

Figure 2

23
Step3: Click on pcA than go to Desktop and select IP configuration

Figure 3

Step-4: Click on static and give appropriate IP Address and default Gateway for pcA and close it.

Figure 4

Repeat 3 and 4 steps to Give Appropriate IP Address to 4 pcs

24
Step5: Now, click on PC’A than go to Desktop and Select Command Prompt.

write following command:

Ping 192.168.1.2. if get reply then connection is successful. Check with all other pc’s IP star topology is
complete.

CONCLUSION:
Thus we have studied and Implement the Star Topology using Packet tracer simulator.

25
Practical: - 8

AIM: To Implement DNS using Packet tracer simulator.


TOOLS AND TECHNOLOGY: CISCO PACKET TRACER.

IMPLEMENTATION: First start Cisco Packet Tracer then, Select Guest Login Wait for 15
Seconds and then select left side corner end devices & other options option then follow next steps.

Step 1: First take 2 PC’s from end devices and take 1 generic switch and also take 1 generic server.
Connect all device as shown in figure through Copper Straight Cable.

Figure 1

Step 2: Assign IP to pc and server as shown in figure 2.

Figure 2

26
Step 3: Double click on server and go to Services then go DNS Service. Turn on service and then write
name of host you want. (ex. gecdahod.tk) then write address of server (192.168.1.1).

Figure 3

Step 4: After 3rd step go to HTTP service and then double click on index.html and design website as shown
in figure 4.

Figure 4

27
Step 5: Double click on PC 0 and assign IP and also assign DNS server IP shown in figure.

Step 6: Repeat step 5 for PC 1 and assign IP and DNS.

Step 7: Finally, Double go to PC 0 Desktop Services and Select Browser. Type Domain Name shown in
figure.

28
Practical: - 9

AIM: Implement Concept Of Bit Stuffing.


#include <stdio.h>
void main(){
inti=0,count=0;
char a[100];
clrscr();
printf("enter the bits : \n");
scanf("%s",a);
printf("\nAfter bit stuffing :\n");
for(i=0;a[i]; i++){
if(a[i]=='1')
count++;
else
count=0;
printf("%c",a[i]);
if(count==5){
printf("0");
count=0;
}
}
getch();
}

OUTPUT:

29
Bit stuffing
Bit stuffing is the insertion of one or more bits into transmission ling information to a
receiver. The Knows how to detect and remove or disregard the stuffed bits.
Inserting bits in data in order to break up a bit pattern that may cause the transmission to go out of
synchronization.
For example, in T1 lines, timing is maintained by detecting a change from 0 to 1. If too many
zero bits are transmitted consecutively, the receiving end may lose synchronization because too
much time has passed without sensing voltage. Therefore, in long strings of zeros, a set of bits that
begins with a 1 and functions as a timing signal is "stuffed" into the stream of zeros at certain
intervals. The insertion of extra bits in a transmitted message in order to fill a frame to a fixed size or
to break up a pattern of bits that could be mistaken for control codes.
In bit oriented protocol the data to send is a series of bits. In order to distinguish frames most
protocols use a bit pattern of 8-bit (01111110) as flag at the beginning and end of each frame here
also cause the problem of appearance of flag in the data part to deal with this an extra bit added.

30
Practical: - 10

AIM: Implement Concept of Byte/Char Stuffing.


#include<stdio.h>
#include<conio.h>
void main(){
inti=0,count=0;
char a[100];
clrscr();
printf("Enter the characters: \n");
scanf("%s",a);
printf("\n After character stuffing:\n");
printf("DLESTX");
for(i=0;a[i];i++){
if(a[i]==a[i]){
count++;
}
else{
count=0;
}
printf("%c",a[i]);
if(a[i]==a[i+1]){
printf("DLE");
count=0;
}
}
printf("DLEEXT");
getch();
}

OUTPUT:

31
CHARACTER STUFFING

 Same idea as bit-stuffing, but operates on bytes instead of bits.

 Use reserved characters to indicate the start and end of a frame. For instance, use the two-character
sequence DLE STX (Data-Link Escape, Start of TeXt) to signal the beginning of a frame, and the
sequence DLE ETX (End of TeXt) to flag the frame's end.

 Problem occurs when the two-character sequence DLE ETX happens to appear in the frame itself.

 Hence the solution is to Use character stuffing; within the frame, replace every occurrence of DLE
with the two-character sequence DLE DLE. The receiver reverses the processes, replacing every
occurrence of DLE DLE with a single DLE.

 Example: If the frame contained ``A B DLE D E DLE'', the characters transmitted over the channel
would be ``DLE STX A B DLE DLE D E DLE DLEDLE ETX''.

 But the disadvantage is character is the smallest unit that can be operated on; not all architectures are
byte oriented.

32
Practical: - 11

AIM: Implement Parity Checking mechanism CRC.


#include <stdio.h>

#include <conio.h>

#include <string.h>

void main()

inti,j,keylen,msglen;

char input[100], key[30],temp[30],quot[100],rem[30],key1[30];

clrscr();

printf("Enter Data: ");

gets(input);

printf("Enter Key: ");

gets(key);

keylen=strlen(key);

msglen=strlen(input);

strcpy(key1,key);

for(i=0;i<keylen-1;i++)

input[msglen+i]='0';

for(i=0;i<keylen;i++)

temp[i]=input[i];

for(i=0;i<msglen;i++)

33
quot[i]=temp[0];

if(quot[i]=='0')

for(j=0;j<keylen;j++)

key[j]='0';

else

for(j=0;j<keylen;j++)

key[j]=key1[j];

for(j=keylen-1;j>0;j--)

if(temp[j]==key[j])

rem[j-1]='0';

else

rem[j-1]='1';

rem[keylen-1]=input[i+keylen];

strcpy(temp,rem);

strcpy(rem,temp);

printf("\nQuotient is ");

for(i=0;i<msglen;i++)

printf("%c",quot[i]);

printf("\nRemainder is ");

for(i=0;i<keylen-1;i++)

printf("%c",rem[i]);

printf("\nFinal data is: ");

for(i=0;i<msglen;i++)

printf("%c",input[i]);

34
for(i=0;i<keylen-1;i++)

printf("%c",rem[i]);

getch();

OUTPUT:-

35
Practical: - 12

AIM: Write a Program Distance Vector Routing Algorithm.


Distance Vector means that Routers are advertised as vector of distance and Direction.
Direction is simply next hop address and exit interface and Distance means hop count.

Routers using distance vector protocol do not have knowledge of the entire path to a
destination. Instead DV uses two methods: Direction in which router or exit interface a packet should
be forwarded. Distance from its destination.

In distance vector routing, the least cost route between any two nodes is the route
with minimumdistance. In this protocol, as the name implies, each node maintains a vector (table) of
minimum distance to every node. As the name suggests the DV protocol is based on calculating the
direction and distance to any link in a network. The cost of reaching a destination is calculated using
various route metrics. RIP uses the hop count of the destination whereas IGRP takes into account
other information such as node delay and available bandwidth.

Updates are performed periodically in a distance-vector protocol where all or part of a router
routingtable is sent to all its neighbors that are configured to use the same distance-vector routing
protocol. RIP supports cross-platform distance vector routing whereas IGRP is a CiscoSystems
proprietary distance vector routing protocol. Once a router has this information it is able to amend its
own routing table to reflect the changes and then inform its neighbors of the changes. This process
has been described as ‘routing by rumor’ because routers are relying on the information they receive
from other routers and cannot determine if the information is actually valid and true. There are a
number of features which can be used to help with instability and inaccurate routing information.

36
#include<stdio.h>

#include<conio.h>

struct node

unsigned dist[20];

unsigned from[20];

}rt[10];

int main()

intdmat[20][20];

intn,i,j,k,count=0;

printf("\nEnter the number of nodes : ");

scanf("%d",&n);

printf("\nEnter the cost matrix :\n");

for(i=0;i<n;i++)

for(j=0;j<n;j++)

scanf("%d",&dmat[i][j]);

dmat[i][i]=0;

rt[i].dist[j]=dmat[i][j];

rt[i].from[j]=j;

do

count=0;

for(i=0;i<n;i++)

for(j=0;j<n;j++)

37
for(k=0;k<n;k++)

if(rt[i].dist[j]>dmat[i][k]+rt[k].dist[j])

rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];

rt[i].from[j]=k;

count++;

}while(count!=0);

for(i=0;i<n;i++)

printf("\n\nState value for router %d is \n",i+1);

for(j=0;j<n;j++)

printf("\t\nnode %d via %d Distance%d",j+1,rt[i].from[j]+1,rt[i].dist[j]);

printf("\n\n");

Output:
Enter the number of nodes : 4
Enter the cost matrix :
0 3 5 99
3 0 99 1
5402
99 1 2 0
State value for router 1 is

node 1 via 1 Distance0


node 2 via 2 Distance3
node 3 via 3 Distance5

38
node 4 via 2 Distance4

State value for router 2 is

node 1 via 1 Distance3


node 2 via 2 Distance0
node 3 via 4 Distance3
node 4 via 4 Distance1

State value for router 3 is

node 1 via 1 Distance5


node 2 via 4 Distance3
node 3 via 3 Distance0
node 4 via 4 Distance2

State value for router 4 is

node 1 via 2 Distance4


node 2 via 2 Distance1
node 3 via 3 Distance2
node 4 via 4 Distance0

39
Practical: - 13

AIM: To Study about Network Simulator (NS2).

TOOLS AND TECHNOLOGY: NS2 (Network simulator version 2).

IMPLEMENTATION:

1 Introduction:

The Network Simulator (ns2) [1] network simulation package will be the supported tool for this
class. You may run ns2 using the ECE Graduate Workstation Laboratory or you can install it on your
own Linux or Microsoft Windows computer. This document provides instructions for installing and
running ns2 on Windows, based on [3] and [4]. Installing and running ns2 in Linux is not covered in
this document; further information is provided by [2]. You will need to install the following
packages.Tcl

 Tk
 Otcl
 Tclcl
 Ns2
 Nam
 Tracegraph (for Windows), or Xgraph (for Unix)

Tcl, Tk, Otcl, and Tclcl are support programs that are used by ns2, which is the simulation program.
Nam is the network simulator which provides visual views of the network simulation. Tracegraph is
used to obtain statistics and produce graphical results under the Windows platform. Alternatively, if
you are installing under UNIX, Xgraph is used for the same purpose. This installation tutorial covers
only the installation steps required for Windows. For instructions on Unix installation, see [1]. The
zip file available in the course website contains only the precompiled version of ns2 and nam for
Windows.

40
2 References

Additional information about installing ns2 is available on the web. Here are some helpful sites.

[1] The Network Simulator - ns-2, http://www.isi.edu/nsnam/ns/

[2] The Network Simulator: Building Ns, http://www.isi.edu/nsnam/ns/ns-build.html

[3] How to Compile Ns2 on Windows Platform, http://www.isi.edu/nsnam/ns/ns-win32-

build.html

[4]Installing ns on Windows ME/2000,

http://www.public.iastate.edu/~magico/nsFiles/InstallNS1.html

[5] Ns Manual, http://www.isi.edu/nsnam/ns/ns-documentation.html

[6] Tutorial for the Network Simulator “ns”, http://www.isi.edu/nsnam/ns/tutorial/index.html

[7] Tracegraph Program Download Page, http://www.geocities.com/tracegraph/

3 Preliminaries

3.1 System Requirements

To successfully install ns2, you system must meet the following requirements.

 Windows 2000
 Microsoft Visual C++ 6.0 or above
 Approximately 70 MB of space for precompiled ns2 binary, or 145+50 (name) MB of space
for full ns2 and name source

3.2 Making a Network Simulator Directory

First, you have to decide on a directory to place the ns2 code and its associated components. This
installation tutorial will assume the C:\NetSim directory.

Throughout the installation, a MS-DOS command prompt is needed to compile and install the
different components. In Windows 2000, make sure you use the full functional command prompt by
going to Start Menu, Run, and then type cmd (i.e. do not type command). cmd.exe has full
functionalities while command.com does not. For Windows 95/98, there is not cmd, so command is
fine. To create the ns2 directory in MS-DOS prompt, type the following:

41
D:\>C:

C:\>mkdir NetSim

C:\>cd NetSim

3.3 Setting up Microsoft Visual C++ Environment Variables

Microsoft Visual C++ needs to be set up to use the command line compiler and linker in a MS-DOS
prompt. Type the following in MS-DOS prompt:

C:\>cd C:\NetSim

C:\>vcvars32.bat

3.4 Downloading the Sources

To make the download process easier, a single zipped file containing all necessary files is available.
You can download this file, ns2.zip, from the class web site. Otherwise, you can download the
following components separately from [2].

 tcl-8.3.2
 tk-8.3.2
 otcl-1.0a7
 tclcl-1.0b11
 ns-2.1b8a-win – use either the precompiled binary or the full source, see section 4.5
 nam-1.0a10 – use either the precompiled binary or the full source, see section 4.6
 trgraph120beng and mglinstaller (for Windows, covered here), or xgraph-12.1 (for Unix, not
covered here) – for obtaining statistics and plotting graphs

No matter whichever download method you choose, the compressed files are in .zip or .tar.gz format
and WinZip can be used to unzip the files.

3.5 Decompressing the Source Files

Use WinZip to unzip the downloaded files into their respective directories. The simple and easy way
to do this is to place the download files in the directory C:\NetSim, and double click the files in the
order given above. This action will create the directories for each necessary component. Make sure

42
you do not change the directory names after decompression because the makefiles decompressed are
dynamically generated and are based on this directory structures.

Decompress the files tcl-8.3.2.tar.gz, tk-8.3.2.tar.gz, otcl- 1.0a7.tar.gz,and tclcl-1.0b11.tar.gz.


Decompress also ns-2.1b8awin. tar.gz and nam-1.0a10.tar.gz if installing the full sources. You
should see a directory structure similar to the following:

C:

NetSim

tcl8.3.2

tk8.3.2

otcl-1.0a7

tclcl-1.0b11

ns-2.1b8a-win

nam-1.0a10

Tracegraph is installed after ns2 installation is completed, and thus its files are notuncompressed yet.

4 Installation

The ns2 installation consists of several installs of the necessary components. These components must
be installed in the following order:

 tcl-8.3.2
 tk-8.3.2
 otcl-1.0a7
 tclcl-1.0b11
 ns-2.1b8a-win
 nam-1.0a10
 trgraph120beng

Each of the following subsection contains instructions for installing each of these components in the
above order. Many of these installations require changes to the makefiles. If you use Notepad to
modify these files, make sure the extension is still .vc when you save. This can be done by putting

43
double quotes around the filename in Save As (i.e. “makefile.vc” will save as makefile.vc, but
makefile.vc will save as makefile.vc.txt).

4.1 Installing Tcl

4.1.1 Modifying the Makefiles

In the file C:\NetSim\tcl8.3.2\win\makefile.vc, change the following lines:

Before: INSTALLDIR = c:\Progra~1\Tcl

After: INSTALLDIR = c:\NetSim\tcl8.3.2

Make sure the paths to MSVC are correct. Depending on the version of MSVC you have, one of the
following should apply. Due to the limitation of DOS filenames, your system may have micro~2, or
micro~3, etc. Microsoft Visual C++ is assumed for the rest of the tutorial. IMPORTANT: If you
have Microsoft Visual Studio, you need to make the necessary changes in the batch files.

Visual Studio: TOOLS32 = c:\Progra~1\devstudio\vc

Visual C++: TOOLS32 = c:\Progra~1\micros~4\vc98

Visual Studio: TOOLS32_rc = c:\Progra~1\devstudio\sharedide

Visual C++: TOOLS32_rc = c:\Progra~1\micros~4\common\msdev98

4.1.2 Compiling and Installing the Sources

Nmake is the Microsoft Visual C++ command line compiler and is used to compile the sources for
ns2. Open up a MS-DOS prompt and change to the appropriate directory. Then use nmake to
compile the source. The option /f means using the following argument as the file to be compiled. I
would recommend putting the following lines in a batch file (.bat) and just run the batch file. A set of
batch files are pre-written for this purpose and is available at in the ns2.zip file. The batch file to use
for installing Tcl is named install_tcl.bat.

cd C:\NetSim\tcl8.3.2\win

c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc

c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc install

44
4.2 Installing Tk

4.2.1 Modifying the Makefiles

In the file C:\NetSim\tk8.3.2\win\makefile.vc, change the following lines:

Before: TCLDIR = ..\..\tcl8.3

After: TCLDIR = ..\..\tcl8.3.2

Before: INSTALLDIR = c:\progra~1\tcl

After: INSTALLDIR = c:\NetSim\tcl8.3.2

Visual Studio: TOOLS32 = c:\Progra~1\devstudio\vc

Visual C++: TOOLS32 = c:\Progra~1\micros~4\vc98

Visual Studio: TOOLS32_rc = c:\Progra~1\devstudio\sharedide

Visual C++: TOOLS32_rc = c:\Progra~1\micros~4\common\msdev98

4.2.2 Compiling and Installing the Sources

Run the following commands in MS-DOS prompt, or use the batch file named install_tk.bat.

cd C:\NetSim\tk8.3.2\win

c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc

c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc install

4.2.3 Setting up the Tcl/Tk Path

Several paths need to be added to the search path of the current MS-DOS prompt in order for ns2 to
find Tcl. These paths can be added to the autoexec.bat or autoexec.nt so that the paths are properly
added every time you start a MS-DOS prompt. However, you don’t always start a MS-DOS prompt
to run ns2. If the paths of all programs you use are added to the autoexec.bat, it only delays the time
to find the right executable to run. Therefore, it is recommended that when you want to run ns2, you
start a MS-DOS prompt and run the batch file before using ns2. Run the following commands in MS-
DOS prompt, or use the batch file named set_path.bat to set up the paths for running ns2.

45
PATH %PATH%;C:\NetSim\tcl8.3.2\bin;C:\NetSim\ns-2.1b8awin;

C:\NetSim\nam-1.0a10-win32;C:\NetSim

4.3 Installing Otcl

4.3.1 Modifying the Makefiles

In the file C:\NetSim\otcl-1.0a7\makefile.vc, change the following lines:

Visual Studio: TOOLS32 = c:\Progra~1\devstudio\vc

Visual C++: TOOLS32 = c:\progra~1\micros~4\VC98

Before: OTCL_DIR = ..\otcl

After: OTCL_DIR = ..\otcl-1.0a7

Before: STATIC_TCLTK = 1

After: # STATIC_TCLTK = 1

4.3.2 Compiling the Sources

Run the following commands in MS-DOS prompt, or use the batch file named install_otcl.bat.

cd C:\NetSim\otcl-1.0a7

c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc

4.4 Installing Tclcl

4.4.1 Modifying the Makefiles

In the file C:\NetSim\tclcl-1.0b11\conf\makefile.win, change the following lines:

Visual Studio: TOOLS32 = c:\Progra~1\devstudio\vc

Visual C++: MSVCDIR = c:\progra~1\micros~4\VC98

Before: LOCAL_SRC = c:\research\vint\ns-allinone-2.1b7

46
After: LOCAL_SRC = c:\NetSim

Make sure the version numbers for tcl and tk are correct.

TCL_SUFFIX = 8.3.2

TK_SUFFIX = 8.3.2

Before: OTCL_DIR = $(LOCAL_SRC)\otcl-1.0a6

After: OTCL_DIR = $(LOCAL_SRC)\otcl-1.0a7

Before: TCLCL_DIR = $(LOCAL_SRC)\tclcl-1.0b10

After: TCLCL_DIR = $(LOCAL_SRC)\tclcl-1.0b11

4.4.2 Compiling the Sources

The /I option is used to suppress the error that an existing executable c:\NetSim\tclcl-
1.0b11\tcl2c++.exe cannot be found. Of course it cannot be found since it hasn’t been previously
installed. This error comes up when I ran the installation. Note that the /I option is not recommended
for usual compilation. Run the following commands in MS-DOS prompt, or use the batch file named
install_tclcl.bat.

cd C:\NetSim\tclcl-1.0b11

c:\progra~1\micros~4\vc98\bin\nmake /I /f makefile.vc

4.5 Installing Ns-2

You can download a precompiled version of ns2 (ns-2.1b8a-win32.exe) from [1], also available from
the zip file we provide. This is a quick and easy way to install ns2. In this class, you will be given
code for the model or you will write your own model. Therefore, you do not need to modify the
existing ns2 code. For the purpose of this class, this type of installation will suffice. However, if you
already have experience with ns2 or plan to use ns2 for further research, a more complicated
installation is recommended. This method requires installing the full source of ns2 (~75 MB) and
takes a longer time. The steps involved are very similar to those for installing Tclcl. If you choose to
install the precompiled version, copy the file ns-2.1b8a.exe to the C:\NetSim directory and rename it
as ns. You can type ns in MS-DOS prompt to invoke ns2. If you choose to install the full source,

47
download and decompress the file ns-src- 2.1b8a-win.tar.gz from [1] and read the Appendix. Now
ns2 has been installed in your computer. To invoke ns2, open an MS-DOS prompt, run the batch file
set_path.bat, and type ns.

4.6 Installing nam

Nam is the network simulation animator that animates the network simulation done by ns2. It
provides a visual view of the network simulation. Although nam is optional but it is recommended
that you install it so that you can see what is going on during the simulation. Similarly, you can
choose to install nam as a precompiled binary. Or you can choose to install the full nam source. If
you choose to install the precompiled version, copy the file nam-1.0a10-win32.exe to the C:\NetSim
directory and rename it as nam. You can type nam in MS-DOS prompt to invoke nam. Skip sections
4.6.1 and 4.6.2. If you choose to install the full source, download and decompress the file nam-src-
1.0a10.tar.gz from [1] and read sections 4.6.1 and 4.6.2. However, instructions are not available.
You can try asking in the ns mailing list for some help.

4.7 Installing Tracegraph

X graph is the program to plot graphs for name. However, it can only work in Unix. In order to
obtain graphical results from ns2 simulation in Windows, trace graph must be installed. In addition,
the Mat Lab Graphics Run Time Libraries must also be installed. You can download both
Mglinstaller.zip and trgraph120beng.zip from JaroslawMalek’s website [7]. To install these two
programs, follow the steps below:

 Unzip the file Mglinstaller.zip to extract the file mglinstaller.exe.


 Double click the file mglinstaller.exe.
 When prompted, enter C:\NetSim\mgl as the install path, and press Enter.
 Now the Mat Lab Graphics Run Time Libraries has been installed.
 Unzip the file trgraph120beng.zip into C:\NetSim\mgl\bin\win32.
 Add C:\NetSim\mgl\bin\win32 to the system path. The file set_path.bat should take care of this.

Conclusion:

Thus we have studied and implement NS2 Installation.

with the expired TTL field will be dropped.

48
Protocol:

This 8-bit binary value indicates the data payload type that the packet is carrying. The Protocol field
enables the Network layer to pass the data to the appropriate upper-layer protocol.

Example values are:

01 ICMP

06 TCP

17 UDP

Header checksum (16 bits): An error-detecting code applied to the header only. Because some header
fields may change during transit (e.g., time to live, segmentation-related fields), this is reverified and
recomputed at each router. The checksum field is the 16-bit one's complement addition of all 16-bit words
in the header. For purposes of computation, the checksum field is itself initialized to a value of zero .

Options (variable). Encodes the options requested by the sending user.

Padding (variable). Used to ensure that the datagram header is a multiple of 32 bits.

Data (variable). The data field must be an integer multiple of 8 bits. The max- imum length of the
datagram (data field plus header) is 65,535 octets.

49
Practical: - 14
AIM: To Study Network IP Address.
a. IPV6 Address with their header format
b. IPV4 Address with their header format

IP Address:
Each computer in a TCP/IP network must be given a unique identifier, or IP address. This address, which operates
at Layer 3, allows one computer to locate another computer on a network. All computers also have a
unique physical address, which is known as a MAC address. These are assigned by the manufacturer of the NIC.
MAC addresses operate at Layer 2 of the OSI model. An IP address (IPv4) is a 32-bit sequence of ones and zeros.To
make the IP address easier to work with, it is usually written as four decimal numbers separated by periods. For
example, an IP address of one computer is 192.168.1.2. Another computer might have the address 128.10.2.1.
This is called the dotted decimal format. Each part of the address is called an octet because it is made up of eight
binary digits. For example, the IP address 192.168.1.8 would be 11000000.10101000.00000001.00001000 in
binary notation. The dotted decimal notation is an easier method to understand than the binary ones and zeros
method. This dotted decimal notation also prevents a large number of transposition errors that would result if
only the binary numbers were used.

Ipv4 Header:

Version:(4 bits): Indicates the version number, to allow evolution of the protocol.

Internet Header Lenght(IHL 4 bits): Length of header in 32 bit words. The minimum value is five for a minimum
header length of 20 octets.

Type-of-Service:

The Type-of-Service field contains an 8-bit binary value that is used to determine the priority of each packet. This
value enables a Quality-of-Service (QoS) mechanism to be applied to high priority packets, such as those
carrying telephony voice data. The router processing the packets can be configured to decide which packet it is to
forward first based on the Type-of-Service value.

50
Total length: total datagram length ,in octets.

Identifier (16 bits): A sequence number that, together with the source address, destination address, and user
protocol, is intended to uniquely identify a datagram. Thus, the identifier should be unique for the datagram's
source address, destination address, and user protocol for the time during which the datagram will remain
in the internet.

Fragment Offset : A router may have to fragment a packet when forwarding it from one medium to another
medium that has a smaller MTU. When fragmentation occurs, the IPv4 packet uses the Fragment Offset
field and the MF flag in the IP header to reconstruct the packet when it arrives at the destination host. The
fragment offset field identifies the order in which to place the packet fragment in the reconstruction.

Flags(3 bits): Only two of the bits are currently defined: MF(More Fragments) and DF(Don't

Fragment):

More Fragments flag (MF):The More Fragments (MF) flag is a single bit in the Flag field used with the Fragment
Offset for the fragmentation and reconstruction of packets. The More Fragments flag bit is set, it means that it is
not the last fragment of a packet. When a receiving host sees a packet arrive with the MF = 1, it examines the
Fragment Offset to see where this fragment is to be placed in the reconstructed packet. When a receiving host
receives a frame with the MF = 0 and a non-zero value in the Fragment offset, it places that fragment as the
last part of the reconstructed packet. An unfragmented packet has all zero fragmentation information (MF =
0, fragment offset =0)

Don't Fragment flag (DF):The Don't Fragment (DF) flag is a single bit in the Flag field that indicates that
fragmentation of the packet is not allowed. If the Don't Fragment flag bit is set, then fragmentation of this packet
is NOT permitted. If a router needs to fragment a packet to allow it to be passed downward to the Data Link layer
but the DF bit is set to 1, then the router will discard this packet.

IP Destination Address

The IP Destination Address field contains a 32-bit binary value that represents the packet destination

Network layer host address.

IP Source Address

The IP Source Address field contains a 32-bit binary value that represents the packet source Network layer host
address.

Time-to-Live

The Time-to-Live (TTL) is an 8-bit binary value that indicates the remaining "life" of the packet. The TTL value is
decreased by at least one each time the packet is processed by a router (that is, each hop). When the value
becomes zero, the router discards or drops the packet and it is removed from the network data flow. This
mechanism prevents packets that cannot reach their destination from being forwarded indefinitely between
routers in a routing loop. If routing loops were permitted to continue, the network would become congested with
data packets that will never reach their destination. Decrementing the TTL value at each hop ensures that it
eventually becomes zero and that the packet with the expired TTL field will be dropped.

51
Protocol:

This 8-bit binary value indicates the data payload type that the packet is carrying. The Protocol field enables
the Network layer to pass the data to the appropriate upper-layer protocol.

Example values are:

01 ICMP

06 TCP

17 UDP

Header checksum (16 bits): An error-detecting code applied to the header only. Because some header fields may
change during transit (e.g., time to live, segmentation-related fields), this is reverified and recomputed at each
router. The checksum field is the 16-bit one's complement addition of all 16-bit words in the header. For purposes
of computation, the checksum field is itself initialized to a value of zero.

Options (variable). Encodes the options requested by the sending user.

Padding (variable). Used to ensure that the datagram header is a multiple of 32 bits.

Data (variable). The data field must be an integer multiple of 8 bits. The max- imum length of the datagram
(data field plus header) is 65,535 octets.

IPv6 Packet Header Format

The IPv6 protocol defines a set of headers, including the basic IPv6 header and the IPv6 extension
headers. The following figure shows the fields that appear in the IPv6 header and the order in which the
fields appear.

Figure IPv6 Basic Header Format

52
The following list describes the function of each header field.

 Version – 4-bit version number of Internet Protocol = 6.


 Traffic class – 8-bit traffic class field.
 Flow label – 20-bit field.
 Payload length – 16-bit unsigned integer, which is the rest of the packet that follows the IPv6 header, in octets.
 Next header – 8-bit selector. Identifies the type of header that immediately follows the IPv6 header. Uses the
same values as the IPv4 protocol field.
 Hop limit – 8-bit unsigned integer. Decremented by one by each node that forwards the packet. The packet is
discarded if the hop limit is decremented to zero.
 Source address – 128 bits. The address of the initial sender of the packet.
 Destination address – 128 bits. The address of the intended recipient of the packet. The intended recipient is not
necessarily the recipient if an optional routing header is present.

IPv6 Extension Headers

IPv6 options are placed in separate extension headers that are located between the IPv6 header and the transport-
layer header in a packet. Most IPv6 extension headers are not examined or processed by any router along a
packet's delivery path until the packet arrives at its final destination. This feature provides a major improvement in
router performance for packets that contain options. In IPv4, the presence of any options requires the router to
examine all options.

Unlike IPv4 options, IPv6 extension headers can be of arbitrary length. Also, the number of options that a packet
carries is not limited to 40 bytes. This feature, in addition to the manner in which IPv6 options are processed,
permits IPv6 options to be used for functions that are not practical in IPv4.

To improve performance when handling subsequent option headers, and the transport protocol that follows, IPv6
options are always an integer multiple of 8 octets long. The integer multiple of 8 octets retains the alignment of
subsequent headers.

The following IPv6 extension headers are currently defined:

 Routing – Extended routing, such as IPv4 loose source route


 Fragmentation – Fragmentation and reassembly
 Authentication – Integrity and authentication, and security
 Encapsulating Security Payload – Confidentiality
 Hop-by-Hop options – Special options that require hop-by-hop processing
 Destination options – Optional information to be examined by the destination node

53
Practical: - 15

AIM: Study about various addresses and addressing schemes.


a. Classfull addressing.
b. Classless addressing.
c. Logical address, Physical Address, Port Address, URL.

Classfull addressing: As show in figure we teach how the IP addresses are classified and when they
are used. Class Address Range Supports.

Classless Addressing

To reduce the wastage of IP addresses in a block, we use sub-netting. What we do is that we use
host id bits as net id bits of a classful IP address. We give the IP address and define the number of bits
for mask along with it (usually followed by a ‘/’ symbol), like, 192.168.1.1/28. Here, subnet mask is
found by putting the given number of bits out of 32 as 1, like, in the given address, we need to put 28
out of 32 bits as 1 and the rest as 0, and so, the subnet mask would be 255.255.255.240.

Logical Address

Logical address is our IP internet protocol) address. IP is logical and it is 32bit long.

Physical Address

Physical address is our MAC (media access control) address. MAC is logical and it is 48bit long.

54
Port Address

A port number is a way to identify a specific process to which an Internet or other network message is to
be forwarded when it arrives at a server. For the Transmission Control Protocol and the User Datagram
Protocol, a port number is a 16-bit integer that is put in the header appended to a message unit.

URL

A URL (Uniform Resource Locator), as the name suggests, provides a way to locate a resource on the web,
the hypertext system that operates over the internet. The URL contains the name of the protocol to be used
to access the resource and a resource name. The first part of a URL identifies what protocol to use. The second
part identifies the IP address or domain name where the resource is located.

55
Practical: - 16
AIM: To study and prepare RJ45 Cable.

Requirements:

 Unshielded twisted pair (UTP) patch cable


 Modular connector (8P8C plug, aka RJ45)
 Crimping tool
 Cable tester (optional, but recommended)

Step 1: Strip the cable jacket about 1.5 inch down from the end.

Figure 1
Step 2: Spread the four pairs of twisted wire apart. For Cat 5e, you can use the pull string to strip the jacket
farther down if you need to, then cut the pull string. Cat 6 cables have a spine that will also need to be cut.

Figure 2

56
Step 3: Untwist the wire pairs and neatly align them in the T568B orientation. Be sure not to untwist them
any farther down the cable than where the jacket begins; we want to leave as much of the cable twisted as
possible.

Figure 3

Step 4: Cut the wires as straight as possible, about 0.5 inch above the end of the jacket.

Step 5: Carefully insert the wires all the way into the modular connector, making sure that each wire passes
through the appropriate guides inside the connector.

Figure 4

57
Step 6: Push the connector inside the crimping tool and squeeze the crimper all the way down.

Figure 5

Step 7: Repeat steps 1-6 for the other end of the cable.

Step 8: To make sure you've successfully terminated each end of the cable, use cable tester to test each pin.

Figure 6

When you're all done, the connectors should look like this:

Figure 7

58