You are on page 1of 35

COMPUTER NETWORKS

PRACTICAL FILE
K. MANISHA
2018UIT2523
IT SEC-1
1. To study the various Physical layer
components of networking.
A.CONNECTIONS
BNC : The BNC (Bayonet Neill–Concelman) connector is a miniature quick
connect / disconnect radio frequency connector used for coaxial cable. It
features two bayonet lugs on the female connector; mating is fully achieved
with a quarter turn of the coupling nut. BNC connectors are most commonly
made in 50 ohm and 75 ohm versions, matched for use with cables of the
same characteristic impedance. The 75 ohm connector is dimensionally slightly
different from the 50 ohm variant, but the two nevertheless can be made to
mate. The 75 ohm types can sometimes be recognized by the reduced or
absent dielectric in the mating ends but this is by no means reliable. There was
a proposal in the early 1970s for the dielectric material to be coloured red in
75 ohm connectors, and while this is occasionally implemented, it did not
become standard. The 75 ohm connectors are typically specified for use at
frequencies up to 2 GHz. 75 ohm BNC connectors are primarily used in Video
(particularly HD video signals) and DS3 Telco central office applications. Many
VHF receivers use 75 ohm antenna inputs, so they often used 75 ohm BNC
connectors. The 50 ohm connectors are typically specified for use at
frequencies up to 4 GHz. 50 ohm connectors are used for data and RF. A 95
ohm variant is used within the aerospace sector, but rarely elsewhere. It is
used with the 95 ohm video connections for glass cockpit displays on some
aircraft.

RJ-45 : RJ45 is a type of connector commonly used for Ethernet networking.


It looks

similar to a telephone jack, but is slightly wider. Since Ethernet cables have an
RJ45

connector on each end, Ethernet cables are sometimes also called RJ45 cables.
The "RJ" in RJ45 stands for "registered jack," since it is a standardized
networking interface.

The "45" simply refers to the number of the interface standard. Each RJ45
connector has

eight pins, which means an RJ45 cable contains eight separate wires. If you
look closely at

the end of an Ethernet cable, you can actually see the eight wires, which are
each a different

color. Four of them are solid colors, while the other four are striped.

B.CABLES
CO-AXIAL : Coaxial cable is a type of copper cable specially built with a
metal shield and other components engineered to block signal interference. It
is primarily used by cable TV companies to connect their satellite antenna
facilities to customer homes and businesses. It is also sometimes used by
telephone companies to connect central offices to telephone poles near
customers. Some homes and offices use coaxial cable, too, but its widespread
use as an Ethernet connectivity medium in enterprises and data centers has
been supplanted by the deployment of twisted pair cabling. Coaxial cable
received its name because it includes one physical channel that carries the
signal surrounded -- after a layer of insulation -- by another concentric physical
channel, both running along the same axis. The outer channel serves as a
ground. Many of these cables or pairs of coaxial tubes can be placed in a single
outer sheathing and, with repeaters, can carry information for a great
distance.

How coaxial cables work : Coaxial cables have concentric layers of electrical
conductors and insulating material. This construction ensures signals are
enclosed within the cable and prevents electrical noise from interfering with
the signal.
The center conductor layer is a thin conducting wire, either solid or braided
copper. A dielectric layer, made up of an insulating material with very well-
defined electrical characteristics, surrounds the wire. A shield layer then
surrounds the dielectric layer with metal foil or braided copper mesh. The whole
assembly is wrapped in an insulating jacket.The outer metal shield layer of the
coaxial cable is typically grounded in the connectors at both ends to shield the
signals and as a place for stray interference signals to dissipate.

TWISTED PAIR CABLE :


One of the earliest guided transmission media is twisted pair cables. A twisted
pair cable comprises two separate insulated copper wires, which are twisted
together and run in parallel. The copper wires are typically 1mm in diameter. One
of the wires is used to transmit data and the other is the ground reference.

Reason for Twisting : All transmissions are prone to noise, interferences, and
crosstalks. When the wires are twisted, some part of the noise signals is in the
direction of data signals while the other parts are in the opposite directions. Thus
the external waves cancel out due to the different twists. The receiver calculates
the difference in the voltages of the two wires for retrieving data.Thus a much
better immunity against noise is obtained.

Applications of Twisted-Pair Cables

1. In telephone lines

2. In DSL lines

3. In LANs

UTP: UTP Cable is a shorter way of saying unshielded twisted pair. This is one of
the least expensive wires and works for basic needs of phone systems so it is one
of the most commonly installed in residential industries. The twisted cable pairs
work to cancel out EMI (electromagnetic interference) from external sources. This
would be interference from electromagnetic radiation, ground water, pressure,
root systems and more. It also cuts down on crosstalk. Interestingly enough, UTP
wire is accredited with being discovered by Alexander Graham Bell. It is no
surprise that UTP Cable is the single most common type of copper telephone
wire.The two wires in each pair carry opposite signals. Each signal is detected as
the opposite end when the signal reaches the receiver. Twisting the pairs
together is how the effects of crosstalk are countered. Multiple pair cabling is a
necessity for handling all forms of communication needs. The purpose of the
cable really determines how many pairs are needed. Analog systems, digital
systems and ethernet systems all require a different number of pairs. Sometimes,
because it is less expensive than coaxial cable, UTP and STP (Shielded twisted
pair) are sometimes used in basic LAN installations. Most of the time though, UTP
cables are used in computer networking and in modern Ethernet solutions. It is
also used in data networks as networks which have short or medium length will
save money over optical fiber or coaxial cable.UTP cable is also finding a home in
video applications. Mostly it is security cameras, not the cinematic type. The
bandwidth of UTP has been improved so it now matches baseband needed to
connect.

2. To study about various networking devices


used at different layers of osi .
i) NETWORK ADAPTER : A network adapter is the component of a
computer’s internal hardware that is used for communicating over a
network with another computer. It enable a computer to connect with
another computer, server or any networking device over an LAN
connection. A network adapter can be used over a wired or wireless
network.
ii) HUBS : A hub, also called a network hub, is a common connection
point for devices in a network. Hubs are devices commonly used to connect
segments of a LAN. The hub contains multiple ports. When a packet arrives
at one port, it is copied to the other ports so that all segments of the LAN
can see all packets.
Hubs and switches serve as a central connection for all of your network
equipment and handles a data type known as frames. Frames carry your data.
When a frame is received, it is amplified and then transmitted on to the port of
the destination PC.

iii) SWITCH: A switch, in the context of networking is a high-speed device that


receives incoming data packets and redirects them to their destination on a local
area network (LAN). A LAN switch operates at the data link layer (Layer 2) or the
network layer of the OSI Model and, as such, it can support all types of packet
protocols. Essentially, switches are the traffic cops of a simple local area network.

iv) Router: Routers operate on the third layer of the OSI Model, the Network-
Control Layer. Rather than passing packets based on the Media Access Control
(MAC) Layer addresses (as bridges do), a router examines the packet's data
structure and determines whether or not to forward it. This determination is
made based on the network information within the packet. Once the router
determines where the packet should be sent, it finds the fastest route to send the
data to its destination. The router also has to send this data in the most
appropriate format for transferring information. That means it may repackage or
break the data into smaller pieces than the receiving destinations can handle.
Routers don't have a bridge's ability to learn addresses, so they have to do more
data processing than bridges do. Routers also have to be aware of the network
protocols they serve and often have more complex installation and configuration
requirements.

v) Gateways: A gateway, as the name suggests, is a passage to connect two


networks together that may work upon different networking models. They
basically work as the messenger agents that take data from one system, interpret
it, and transfer it to another system. Gateways are also called protocol converters
and can operate at any network layer. Gateways are generally more complex than
switch or router. The gateway operates at the network layer (Layer 3) of the OSI
Model. The gateway is used when transmitting packets. When packets are sent
over a network, the destination IP address is examined. If the destination IP is
outside of the network, then the packet goes to the gateway for transmission
outside of the network. The gateway is on the same network as end devices. The
gateway address must have the same subnet mask as host devices. Each host on
the network uses the same gateway. The gateway should have a static address, as
changing the address would cause packets not to be delivered. The gateway is
typically assigned either the highest or lowest network address. This is not a
requirement, but many organizations use a consistent addressing scheme to
facilitate network planning.

3. Explain Installation of LAN card and LAN cabling.


A LAN card connects a computer to a network. LAN cards are typically built into
your computer. You can connect to the network via an Ethernet cable, usb, or
wirelessly. If your computer is equipped with wireless capabilities, your computer
will have what is called a WLAN module. With today’s advancing technologies,
most desktops, laptops, tablets, and cell phones are equipped with a WLAN
module.For example, a computer in one room needs to connect with a printer in
the next room over. As long as the printer is connected either by a direct
connection with an Ethernet cable or wirelessly via a WLAN module connected to
the LAN via a router the computer will be able to connect to the printer through
the LAN. LAN cards also make it possible to connect many different computers
together through the LAN. As long as each of the computers has the proper IP
package addresses.

Before getting started

1. Difficulty of installing a PC network card should be a 4 out of 5.

2. Write down important information from the top or bottom of the card such

as the Model Number, Serial Number, and specifications.

3. Ensure you are familiar with ESD and its potential dangers.

4. When physically installing the network card, ensure the computer is

powered down and unplugged.


Set jumpers

Before installing the network card, verify that the jumpers are properly set.

Today, most computers do not have jumpers for a network card installation and

allow for the network card to be set up and configured through software or plug

and play. If available, it is recommended that this be used.

Install into expansion slot

Today, network cards connect to the PCI slot. Locate an available slot in the

computer and gently push the card into the slot until it snaps into place. Once

the card is in the expansion slot, place a screw into the top of the card to hold

the card into position.

If your computer has a network card already installed and you are replacing or

upgrading that network card, you need to remove the existing network card

before installing the new card.

Attach internal cables

Most network cards will not include internal cables, but you may find Wake-on-
LAN cable, which wakes the computer when network activity is present. If cables
are included with the network card and your computer supports these cables,
install the cables now. The Wake-on-LAN cable must also be a supported feature
of the computer motherboard. The cable will connect to the Wake-on-LAN or
similar connection on the motherboard. Consult the motherboard documentation
or manufacturer for additional information if this is a supported feature or where
the cable should be connected.

Attach external cables


Once the network card is physically installed, replace the case panel and connect
the keyboard, mouse, and monitor as well as the power and network cables.
Then, connect the other end of the network cable to the network outlet on a hub,
switch, or router.

Software setup

Once connected, turn the computer on and install the drivers for the Network
card. If you do not have drivers for your network card or the network card drivers
included appear not to work, you can find links to network drivers on our network
card drivers page. Once the Network card is installed, set the configuration values
for the network card in the software. These values will depend on the
configuration of your network. If it is a corporate or business network, and you
aren't sure how to configure your network card, contact your network's
administrator for detailed instructions.

4. To Study OSI reference model.


OSI stands for Open Systems Interconnection. It has been developed by ISO
–‘International Organization of Standardization‘, in the year 1984. It is a 7 layer
architecture with each layer having specific functionality to perform. All these 7
layers work collaboratively to transmit the data from one person to another
across the globe.

1. Physical Layer (Layer 1) :

The lowest layer of the OSI reference model is the physical layer. It is responsible
for the actual physical connection between the devices. The physical layer
contains information in the form of bits. It is responsible for transmitting
individual bits from one node to the next. When receiving data, this layer will get
the signal received and convert it into 0s and 1s and send them to the Data Link
layer, which will put the frame back together.

The functions of the physical layer are :


1. Bit synchronization: The physical layer provides the synchronization of the bits
by providing a clock. This clock controls both sender and receiver thus providing
synchronization at bit level.

2. Bit rate control: The Physical layer also defines the transmission rate i.e. the
number of bits sent per second.

3. Physical topologies: Physical layer specifies the way in which the


different,devices/nodes are arranged in a network i.e. bus, star or mesh topolgy.

4. Transmission mode: Physical layer also defines the way in which the data flows
between the two connected devices. The various transmission modes possible
are: Simplex, half-duplex and full-duplex.

Hub, Repeater, Modem, Cables are Physical Layer devices. Network Layer, Data
Link Layer and Physical Layer are also known as Lower Layers or Hardware Layers.

2.Data Link Layer (DLL) (Layer 2) :

The data link layer is responsible for the node to node delivery of the
message.
The main function of this layer is to make sure data transfer is error-free
from one node to another, over the physical layer. When a packet arrives in
a network, it is the responsibility of DLL to transmit it to the Host using its
MAC address.
Data Link Layer is divided into two sub layers :
1. Logical Link Control (LLC)
2. Media Access Control (MAC)
The packet received from Network layer is further divided into frames
depending on the frame size of NIC(Network Interface Card). DLL also
encapsulates Sender and Receiver’s MAC address in the header.
The Receiver’s MAC address is obtained by placing an ARP(Address
Resolution Protocol) request onto the wire asking “Who has that IP
address?” and the destination host will reply with its MAC address.
The functions of the data Link layer are :
1. Framing: Framing is a function of the data link layer. It provides a way for
a sender to transmit a set of bits that are meaningful to the receiver. This
can be accomplished by attaching special bit patterns to the beginning and
end of the frame.
2. Physical addressing: After creating frames, Data link layer adds physical
addresses (MAC address) of sender and/or receiver in the header of each
frame.
3. Error control: Data link layer provides the mechanism of error control in
which it detects and retransmits damaged or lost frames.
4. Flow Control: The data rate must be constant on both sides else the data
may get corrupted thus , flow control coordinates that amount of data that
can be sent before receiving acknowledgement.
5. Access control: When a single communication channel is shared by
multiple devices, MAC sub-layer of data link layer helps to determine which
device has control over the channel at a given time. The Packet in Data Link
layer is referred as Frame.

3. Network Layer (Layer 3) :


Network layer works for the transmission of data from one host to the
other located in different networks. It also takes care of packet routing i.e.
selection of the shortest path to transmit the packet, from the number of
routes available. The sender & receiver’s IP address are placed in the
header by the network layer.
The functions of the Network layer are :
1. Routing: The network layer protocols determine which route is suitable
from source to destination. This function of network layer is known as
routing.
2. Logical Addressing: In order to identify each device on internetwork
uniquely, network layer defines an addressing scheme. The sender &
receiver’s IP address are placed in the header by network layer. Such an
address distinguishes each device uniquely and universally.

4. Transport Layer (Layer 4) :


Transport layer provides services to application layer and takes services
from network layer. The data in the transport layer is referred to as
Segments. It is responsible for the End to End Delivery of the complete
message. The transport layer also provides the acknowledgement of the
successful data transmission and re-transmits the data if an error is found.
• At sender’s side:
Transport layer receives the formatted data from the upper layers,
performs Segmentation and also implements Flow & Error control to
ensure proper data transmission. It also adds Source and Destination port
number in its header and forwards the segmented data to the Network
Layer.
Generally, this destination port number is configured, either by default or
manually. For example, when a web application makes a request to a web
server, it typically uses port number 80, because this is the default port
assigned to web applications. Many applications have default port assigned.
• At receiver’s side:
Transport Layer reads the port number from its header and forwards the
Data which it has received to the respective application. It also performs
sequencing and reassembling of the segmented data.
The functions of the transport layer are :
1. Segmentation and Reassembly: This layer accepts the message from the
(session) layer , breaks the message into smaller units . Each of the
segment produced has a header associated with it. The transport layer at
the destination station reassembles the message.
2. Service Point Addressing: In order to deliver the message to correct
process, transport layer header includes a type of address called service
point address or port address. Thus by specifying this address, transport
layer makes sure that the message is delivered to the correct process.

The services provided by the transport layer :


1. Connection Oriented Service: It is a three-phase process which include
– Connection Establishment
– Data Transfer
– Termination / disconnection
In this type of transmission, the receiving device sends an
acknowledgement, back to the source after a packet or group of packet is
received. This type of transmission is reliable and secure.
2. Connection less service: It is a one-phase process and includes Data
Transfer. In this type of transmission, the receiver does not acknowledge
receipt of a packet. This approach allows for much faster communication
between devices. Connection-oriented service is more reliable than
connectionless Service.
Data in the Transport Layer is called as Segments.
Transport layer is operated by the Operating System. It is a part of the OS
and communicates with the Application Layer by making system calls.
Transport Layer is called as Heart of OSI model.

5. Session Layer (Layer 5) :


This layer is responsible for establishment of connection, maintenance of
sessions, authentication and also ensures security.
The functions of the session layer are :
1. Session establishment, maintenance and termination: The layer allows
the two processes to establish, use and terminate a connection.
2. Synchronization : This layer allows a process to add checkpoints which
are considered as synchronization points into the data. These
synchronization point help to identify the error so that the data is re-
synchronized properly,and ends of the messages are not cut prematurely
and data loss is avoided.
3. Dialog Controller : The session layer allows two systems to start
communication with each other in half-duplex or full-duplex.

6. Presentation Layer (Layer 6) :


Presentation layer is also called the Translation layer.The data from the
application layer is extracted here and manipulated as per the required
format to transmit over the network.
The functions of the presentation layer are :
1. Translation : For example, ASCII to EBCDIC.
2. Encryption/ Decryption : Data encryption translates the data into
another form or code. The encrypted data is known as the cipher text and
the decrypted data is known as plain text. A key value is used for encrypting
as well as decrypting data.
3. Compression: Reduces the number of bits that need to be transmitted on
the network.

7. Application Layer (Layer 7) :


At the very top of the OSI Reference Model stack of layers, we find the
Application layer which is implemented by the network applications. These
applications produce the data, which has to be transferred over the
network. This layer also serves as a window for the application services to
access the network and for displaying the received information to the user.
Ex: Application – Browsers, Skype Messenger etc.
The functions of the Application layer are :
1. Network Virtual Terminal
2. FTAM-File transfer access and management
3. Mail Services
4. Directory Services
The OSI model acts as a reference model and is not implemented on the
Internet because of its late invention. Current model being used is the
TCP/IP model.

5.Bit Stuffing

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int a[20],b[30],i,j,k,count,n;
printf("Enter frame size (Example: 8):");
scanf("%d",&n);
printf("Enter the frame in the form of 0 and 1 :");
for(i=0; i<n; i++)
scanf("%d",&a[i]);
i=0;
count=1;
j=0;
while(i<n)
{
if(a[i]==1)
{
b[j]=a[i];
for(k=i+1; a[k]==1 && k<n && count<5; k++)
{
j++;
b[j]=a[k];
count++;
if(count==5)
{
j++;
b[j]=0;
}
i=k;
}
}
else
{
b[j]=a[i];
}
i++;
j++;
}
printf("After Bit Stuffing :");
for(i=0; i<j; i++)
printf("%d",b[i]);
getch();
}

Byte Stuffing
#include<stdio.h>
#include<string.h>
main()
{
char a[30], fs[50] = " ", t[3], sd, ed, x[3], s[3], d[3], y[3];
int i, j, p = 0, q = 0;

printf("Enter characters to be stuffed");


scanf("%s", a);
printf("\nEnter a character that represents starting delimiter:");
scanf(" %c", &sd);
printf("\nEnter a character that represents ending delimiter:");
scanf(" %c", &ed);
x[0] = s[0] = s[1] = sd;
x[1] = s[2] = '\0';
y[0] = d[0] = d[1] = ed;
d[2] = y[1] = '\0';
strcat(fs, x);
for(i = 0; i < strlen(a); i++)
{
t[0] = a[i];
t[1] = '\0';
if(t[0] == sd)
strcat(fs, s);
else if(t[0] == ed)
strcat(fs, d);
else
strcat(fs, t);
}
strcat(fs, y);
printf("\n After stuffing:%s", fs);

6. Implement various error detection technique like


parity check, checksum and CRC.

Parity Check
#include <iostream>
using namespace std;
bool findParity(int n)
{
int count = 0;
int temp = n;
while (temp>=2)
{
if(temp & 1)
count++;
temp = temp >> 1;
}
return (count % 2)?true:false;
}
int main()
{
int n;
cout << "Enter a number: "; cin >>n;
cout << "Parity of " << n << " is "<<(findParity(n)?"Odd":"Even");
}
CRC
#include<stdio.h>
main()
{
int da[20],di[20],te[20],tem[20],l;
int i,j,m,n,data,div,t,k,e;
clrscr();
printf("\nEnter the total bit of data and divisor");
scanf("%d %d",&data,&div);
m=data+div-1;
printf("\nEnter the data:");
for(i=0;i<data;i++)
{
scanf("%d",&da[i]);te[i]=da[i];
}
for(i=data;i<m;i++)
{
te[i]=0;
}
printf("\nEnter the divisor");
for(i=0;i<div;i++)
{ scanf("%d",&di[i]); }
l=div;t=0;
k=0;
for(i=0;i<data;i++)
{
e=0;t=0;
for(j=1;j<div;j++)
{
if(((da[j]==1)&&(di[j]==1))||((da[j]==0)&&(di[j]==0)))
{
tem[j-1]=0;
if(e!=1)
{
k=k+1;
t=t+1;
i=i+1;
}
}
else
{
tem[j-1]=1;
e=1;
}
}
j=0;
for(e=t;e<div-1;e++)
{
da[j]=tem[e];
j++;
}
for(j=j;j<div;j++)
{
if(l>=data+1)
{
da[j]=0;
}
else
{
da[j]=te[l];
l=l+1;
}
}
}
printf("\n The CRC BITS are\t ");
for(i=0;i<div-1;i++)
{
printf(" %d",tem[i]);
}
}

Checksum
#include<stdio.h>

#include<string.h>
int main()
{
char a[20],b[20];
char sum[20],complement[20];
int i,length;
printf("Enter first binary string\n");
scanf("%s",&a);
printf("Enter second binary string\n");
scanf("%s",&b);
if(strlen(a)==strlen(b)){
length = strlen(a);
char carry='0';
for(i=length-1;i>=0;i--)

if(a[i]=='0' && b[i]=='0' && carry=='0')

{
sum[i]='0';
carry='0';
}
else if(a[i]=='0' && b[i]=='0' && carry=='1')
{
sum[i]='1';
carry='0';
}
else if(a[i]=='0' && b[i]=='1' && carry=='0')
{
sum[i]='1';
carry='0';
}
else if(a[i]=='0' && b[i]=='1' && carry=='1')
{
sum[i]='0';

carry='1';
}
else if(a[i]=='1' && b[i]=='0' && carry=='0')
{
sum[i]='1';
carry='0';
}
else if(a[i]=='1' && b[i]=='0' && carry=='1')
{
sum[i]='0';
carry='1';
}
else if(a[i]=='1' && b[i]=='1' && carry=='0')
{
sum[i]='0';
carry='1';
}
else if(a[i]=='1' && b[i]=='1' && carry=='1')
{
sum[i]='1';
carry='1';
}
else
break;
}

printf("\nSum=%c%s",carry,sum);
for(i=0;i<length;i++)

{
if(sum[i]=='0')
complement[i]='1';
else
complement[i]='0';

}
if(carry=='1')
carry='0';
else
carry='1';

printf("\nChecksum=%c%s",carry,complement);
}
else {
printf("\nWrong input strings");
}
}
7. Implement Error Correcting technique like hamming
code.
#include<stdio.h>
void main() {
int data[10];
int dataatrec[10],c,c1,c2,c3,i;
printf("Enter 4 bits of data one by one\n");
scanf("%d",&data[0]);
scanf("%d",&data[1]);
scanf("%d",&data[2]);
scanf("%d",&data[4]);
//Calculation of even parity
data[6]=data[0]^data[2]^data[4];
data[5]=data[0]^data[1]^data[4];
data[3]=data[0]^data[1]^data[2];
printf("\nEncoded data is\n");
for(i=0;i<7;i++)
printf("%d",data[i]);
printf("\n\nEnter received data bits one by one\n");
for(i=0;i<7;i++)
scanf("%d",&dataatrec[i]);
c1=dataatrec[6]^dataatrec[4]^dataatrec[2]^dataatrec[0];
c2=dataatrec[5]^dataatrec[4]^dataatrec[1]^dataatrec[0];
c3=dataatrec[3]^dataatrec[2]^dataatrec[1]^dataatrec[0];
c=c3*4+c2*2+c1 ;
if(c==0) {
printf("\nNo error while transmission of data\n");
}
else {
printf("\nError on position %d",c);
printf("\nData sent : ");
for(i=0;i<7;i++)
printf("%d",data[i]);
printf("\nData received : ");

for(i=0;i<7;i++)
printf("%d",dataatrec[i]);
printf("\nCorrect message is\n");

if(dataatrec[7-c]==0)
dataatrec[7-c]=1;

else

dataatrec[7-c]=0;
for (i=0;i<7;i++)
{

printf("%d",dataatrec[i]);

}
}
}
8.Implement Distant vector routing algorithm.

#include<stdio.h>
struct node
{
unsigned dist[20];
unsigned from[20];
}rt[10];
int main()
{
int costmat[20][20];
int nodes,i,j,k,count=0;
printf("\nEnter the number of nodes : ");
scanf("%d",&nodes);
printf("\nEnter the cost matrix :\n");
for(i=0;i<nodes;i++)
{
for(j=0;j<nodes;j++)
{
scanf("%d",&costmat[i][j]);
costmat[i][i]=0;
rt[i].dist[j]=costmat[i][j];
rt[i].from[j]=j;
}
}
do
{
count=0;
for(i=0;i<nodes;i++)
for(j=0;j<nodes;j++)
for(k=0;k<nodes;k++)
if(rt[i].dist[j]>costmat[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<nodes;i++)
{
printf("\n\n For router %d\n",i+1);
for(j=0;j<nodes;j++)
{
printf("\t\nnode %d via %d Distance %d ",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf("\n\n");
getch();
}

9. Implement Link State Routing Algorithm.


Initialization
N = {A} // A is a root node.
for all nodes v
if v adjacent to A
then D(v) = c(A,v)
else D(v) = infinity
loop
find w not in N such that D(w) is a minimum.
Add w to N
Update D(v) for all v adjacent to w and not in N:
D(v) = min(D(v) , D(w) + c(w,v))
Until all nodes in N

10. To study about IPV4, IPV6, default subnet mask, net


id, host id and classful addressing.
IPV4
Internet Protocol version 4 (IPv4) is the fourth version of the Internet
Protocol (IP). It is one of
the core protocols of standards-based internetworking methods in the
Internet and other packet-switched networks. IPv4 was the first version
deployed for production in the ARPANET in 1983. It still routes most
Internet traffic today, despite the ongoing deployment of a successor
protocol, IPv6. IPv4 is described in IETF publication RFC 791.
IPv4 uses a 32-bit address space which provides 4,294,967,296 (232) unique
addresses, but large blocks are reserved for special networking methods.
The Internet Protocol is the protocol that defines and enables
internetworking at the internet layer of the Internet Protocol Suite. In
essence it forms the Internet. It uses a logical addressing system and
performs routing, which is the forwarding of packets from a source
host to the next router that is one hop closer to the intended destination
host on another network.
IPv4 is a connectionless protocol, and operates on a best effort delivery
model, in that it does not guarantee delivery, nor does it assure proper
sequencing or avoidance of duplicate delivery. These aspects, including
data integrity, are addressed by an upper layer transport
protocol, such as the Transmission Control Protocol (TCP).

IPV6
An Internet Protocol Version 6 address (IPv6 address) is a numerical label
that is used to identify a network interface of a computer or a network
node participating in an IPv6 computer network and for locating it in the
network. IP addresses are transmitted in the fields of the packet header to
indicate the source and the destination of each network packet. The
IP address of the destination address is used to make decisions about
routing IP packets to other networks.
IPv6 is the successor to the first addressing infrastructure of the Internet,
Internet Protocol version 4 (IPv4). In contrast to IPv4, which defined an IP
address as a 32-bit value, IPv6 addresses have a size of 128 bits. Therefore,
IPv6 has a vastly enlarged address space
compared to IPv4.
IPv6 addresses are classified by the primary addressing and routing
methodologies common in networking: unicast addressing, anycast
addressing, and multicast addressing.
A unicast address identifies a single network interface. The Internet
Protocol delivers packets sent to a unicast address to that specific interface.
An anycast address is assigned to a group of interfaces, usually belonging to
different nodes.
A packet sent to an anycast address is delivered to just one of the member
interfaces, typically the nearest host, according to the routing protocol's
definition of distance. Any cast addresses cannot be identified easily, they
have the same format as unicast addresses, and differ only by their
presence in the network at multiple points. Almost any unicast address can
be employed as an anycast address.
A multicast address is also used by multiple hosts, which acquire the
multicast address destination by participating in the multicast distribution
protocol among the network routers. A packet that is sent to a multicast
address is delivered to all interfaces that have joined the
corresponding multicast group. IPv6 does not implement broadcast
addressing. Broadcast's traditional role is subsumed by multicast addressing
to the all-nodes link-local multicast group
ff02::1. However, the use of the all-nodes group is not recommended, and
most IPv6 protocols use a dedicated link-local multicast group to avoid
disturbing every interface in the network.
An IPv6 address consists of 128 bits. For each of the major addressing and
routing methodologies, various address formats are recognized by logically
dividing the 128 address bits into bit groups and establishing rules for
associating the values of these bit groups with special addressing features.

Default Subnet Mask

A subnet mask is a number that defines a range of IP addresses available


within a network.
A single subnet mask limits the number of valid IPs for a specific network.
Multiple subnet masks can organize a single network into smaller networks
(called subnetworks or subnets).
Systems within the same subnet can communicate directly with each other,
while systems on different subnets must communicate through a router.
A subnet mask hides (or masks) the network part of a system's IP address
and leaves only the host part as the machine identifier. It uses the same
format as an IPv4 address — four sections of one to three numbers,
separated by dots. Each section of the subnet mask can
contain a number from 0 to 255, just like an IP address. For example, a
typical subnet mask for a Class C IP address is:
255.255.255.0
In the example above, the first three sections are full (255 out of 255),
meaning the IP addresses of devices within the subnet mask must be
identical in the first three sections. The last section of each computer's IP
address can be anything from 0 to 255. If the subnet mask
is defined as 255.255.255.0, the IP addresses 10.0.1.99 and 10.0.1.100 are
in the same subnet, but 10.0.2.100 is not.

Net ID

A Network ID (or NetID) is a personal, unique identifier assigned to you. It


consists of your initials followed by one or more numbers. You use it, along
with a password, to obtain access to online services, such as email and
administrative systems.
A password is required with your NetID to ensure that no one but you can
access your confidential Cornell information. Your NetID and password also
give you access to services that are exclusive to the Cornell community.

Classful Addressing
A classful network is a network addressing architecture used in the Internet
from 1981 until the introduction of Classless Inter-Domain Routing in 1993.
The method divides the IP address space for Internet Protocol version 4
(IPv4) into five address classes based on the leading four address bits.
Classes A, B, and C provide unicast addresses for networks of three
different network sizes. Class D is for multicast networking and the class E
address range is reserved for future or experimental purposes.
Since its discontinuation, remnants of classful network concepts have
remained in practice only in limited scope in the default configuration
parameters of some network software and hardware components, most
notably in the default configuration of subnet masks.

Host ID
Host ID is a specific piece of information which uniquely identifies a
computer. Host IDs are used to generate MATLAB license files, which are
machine-specific. Most of the time, the host ID is the lowest-enumerated
MAC address of the computer. However, there are exceptions to this:

● With an individual license on a Windows machine, the Volume Serial


Number of the C:
drive can be used as the host ID.
● With network licenses, the IP address can be used as the host ID. This is
not recommended, as IP addresses can change due to external factors.

11. To study about installation and configuration of


printers.
Step 1 : Attach the device using a local or network port
and connect the power
The device is to be set up on a flat stable surface first after which it is to be
connected to host computer with its power off or to the network. Once this
is done, connect power to it using power adapter that comes with it or with
A/C power cord if the device has built-in power supply and finally the
device is to be turned on.
Step 2 : Install and Update the Device driver and calibrate the
device
Boot up the computer and wait for it to recognize the device and the
wizard that appears helps in the configuration process of the driver for the
printer/scanner or CD-ROM that comes
with the device can be inserted which guides through the device driver
installation procedure.The device functions once the driver is installed but
some devices such as inkjet printers or scanners require to calibrate the
device.Calibration is the process by which a device is brought within
functional specifications.
Step 3 : Configure options and default settings
Once the driver is installed, default settings and options for
printers and scanners can be
configured as required.

Step 4 : Print/scan a test page


Once all the steps above are completed, can test the output of the
printer/scanner by printing a test page. Windows has a built-in function for
doing this.

12. Explain Following network commands with all its


suffix and example:
a)Ping: The ping command is a Command Prompt command used to test
the ability of the source computer to reach a specified destination
computer. The ping command is usually used as a simple way to verify that
a computer can communicate over the network with another computer or
network device.
The ping command operates by sending Internet Control Message Protocol
(ICMP) Echo Request messages to the destination computer and waiting for
a response. How many of those responses are returned, and how long it
takes for them to return, are the two major pieces of information that the
ping command provides.
For example, you might find that there are no responses when pinging a
network printer,only to find out that the printer is offline and its cable
needs replaced. Or maybe you need to ping a router to verify that your
computer can connect to it, to eliminate it as a possible cause for a
networking issue.

b) Nslookup: Nslookup (stands for “Name Server Lookup”) is a useful


command for getting information from DNS server. It is a network
administration tool for querying the Domain Name System (DNS) to obtain
domain name or IP address mapping or any other specific DNS record. It is
also used to troubleshoot DNS related problems.
nslookup google.com : nslookup followed by the domain name will display
the “A Record” (IP Address) of the domain. Use this command to find the
address record for a domain. It queries domain name servers and gets the
details.
nslookup 192.168.0.10 : Reverse DNS lookup You can also do the reverse
DNS look-up by providing the IP Address as an argument to nslookup.

nslookup -type=ns google.com : Lookup for an ns record NS (Name Server)


record maps a domain name to a list of DNS servers authoritative for that
domain. It will output the name serves which are associated with the given
domain.
c) Ipconfig: In computing, ipconfig (internet protocol configuration) is a
console application of some operating systems that displays all current
TCP/IP network configuration values and refresh Dynamic Host
Configuration Protocol (DHCP) and Domain Name System
(DNS) settings.

Examples:
● ipconfig /all - Retrieves All TCP/IP Network Information (MAC address,
adapter description, DHCP details)
● ipconfig /release - Releases the IPv4 Address of All Network Adapters
● ipconfig /release6 - Releases the IPv6 Address of All Network Adapters
● ipconfig /release <adapter> - Releases the IP Address of a Specific
Network Adapter
● ipconfig /renew - Get a New IPv4 Address for All Network Adapter
● ipconfig /renew6 - Get a New IPv6 Address for All Network Adapters

d) Pathping: Provides information about network latency and network


loss at intermediate hops between a source and destination. pathping
sends multiple echo Request messages to each router between a source
and destination over a period of time and then computes results based on
the packets returned from each router. Because pathping displays the
degree of packet loss at any given router or link, you can determine which
routers or subnets might be having network problems.

Example:
pathping /n corp1
Tracing route to corp1 [10.54.1.196]
over a maximum of 30 hops:
0 172.16.87.35
1 172.16.87.218
2 192.168.52.1
3 192.168.80.1
4 10.54.247.14
5 10.54.1.196

e) Arp:
ARP Command is a TCP/IP utility and Microsoft Windows command for
viewing and modifying the local Address Resolution Protocol (ARP) cache,
which contains recently resolved MAC addresses of Internet Protocol (IP)
hosts on the network. When one host on a TCP/IP network wants to
communicate with a second host, the first host begins by using the
ARP to resolve the IP address of the second host into its associated MAC
address. The MAC address is needed for communication to take place over
the network.
ARP Command example
Typing arp -a displays the MAC addresses of recently resolved IP addresses.
A sample display could be
Interface: 172.16.8.50
Internet Address Physical Address Type
172.16.8.25 00-20-af-b4-a1-4e dynamic
172.16.8.200 00-40-95-d1-29-6c static

f) Netstat: Netstat command displays various network related


information such as network connections, routing tables, interface
statistics, masquerade connections, multicast memberships etc.

Examples of some practical netstat command :


1. netstat -a | more : To show both listening and non-listening sockets.
2. netstat -at : To list all tcp ports.
3. netstat -au : To list all udp ports.

g) Tracert: The tracert command is a Command Prompt command that's


used to show several details about the path that a packet takes from the
computer or device you're on to whatever destination you specify.
You might also sometimes see the tracert command referred to as the trace
route command or traceroute command.
Examples:
1. tracert 192.168.1.1: to show the path from the networked computer on
which the tracert command is being executed by a network device, in this
case, a router on a local network, that's assigned the 192.168.1.1 IP
address.
2. tracert www.google.com: show us the path from the local computer all
the way to the network device with the hostname www.google.com.
3. tracert -d www.yahoo.com: requesting the path to a website, this time
www.yahoo.com, but now we're preventing tracert from resolving
hostnames by using the -d option.
h) Net:
The net Command Prompt command manages almost any aspect of a
network and its settings, including network shares, network print jobs, and
network users.
Examples:
1. net view: This is one of the simplest net commands that lists all the
networked devices.
2. net accounts /MAXPWAGE:180: This example of the net accounts
command forces a user's password to expire after 180 days. This number
can be anywhere from 1 to 49,710, or UNLIMITED can be used so that the
password never expires. Default is 90 days.
3. net share Downloads=Z:\Downloads /GRANT:everyone,FULL: sharing
the Z:\Downloads folder with everyone on the network and giving all of
them full read/write access. You could modify this one by replacing FULL
with READ or CHANGE for those rights only, as well as replace everyone
with a specific username to give share access to just that
one user account.

You might also like