12 CNS Lab Manual 2023-24
12 CNS Lab Manual 2023-24
12 CNS Lab Manual 2023-24
LAB MANUAL
ACADEMIC YEAR (2022-23) SEMESTER-V
VISION
MISSION
VISION
MISSION
• The department of Computer Engineering will be the widely recognized
centers of excellence for promoting value added engineering education. We
will contribute by evolving innovative technology solution to solve a wide
range of complex scientific, technological and social problems.
CERTIFICATE
Div. __ Roll No.__ Exam Seat No.___________ has completed all the
Group B
Group C
Installing and configure DHCP server and write a program to install the
11 software on remote machine
To capture packets using Wireshark, write the exact packet capture filter
12 expressions to accomplish the following and save the output in file
Experiment No-01
OBJECTIVES:
• To study wired LAN using switch.
• To understand setup of LAN using switch.
• To implement use of switch.
PROBLEM STATMENT:
Setup a wired LAN using Layer 2 Switch and then IP switch of minimum four computers. It
includes preparation of cable, testing of cable using line tester, configuration machine using IP
addresses, testing using PING utility and demonstrate the PING packets captured traces using
Wireshark Packet Analyzer Tool.
OUTCOMES:
CO1: Demonstrate LAN and WAN protocol behavior using Modern Tools.
THEORY:
Computer Networks, the widespread sharing of information among groups of computers and
their users, a central part of the information age. The popular adoption of the personal computer
(PC) and the local area network (LAN) during the 1980s has led to the capacity to access
information on a distant database; download an application from overseas; send a message to a
friend in a different country; and share files with a colleague—all from a personal computer.
The networks that allow all this to be done so easily are sophisticated and complex entities. They rely
for their effectiveness on many cooperating components. The design and deployment of the
worldwide computer network can be viewed as one of the great technological wonders of recent
decades.
Networks are connections between groups of computers and associated devices that allow users to
transfer information electronically. The local area network shown on the left is representative of
the setup used in many offices and companies. Individual computers, called work stations (WS),
communicate to each other via cable or telephone line linking to servers. Servers are computers
exactly like the WS, except that they have an administrative function and are devoted entirely to
monitoring and controlling WS access to part or all of the network and to any shared resources
(such as printers). The red line represents the larger network connection between servers, called
the backbone; the blue line shows local connections. A modem (modulator/demodulator) allows
computers to transfer information across standard telephone lines. Modems convert digital signals
into analogue signals and back again, making it possible for computers to communicate, or
network, across thousands of miles.
Each computer includes the File server or a Network will have a card plugged in the PCI
Expunction slot or will have on-board NIC (Network Interface Card), which will provide
connectivity among the workstation in the network through cables.
Types of Card:-
Hub/Switch:-
These devices are used for Re-directing traffic, i.e. in a
Star Topology the central device is used to
ECHO/Re-Direct the packets coming from one
workstation/node to the Destination workstation/node.
Type of Hub:-
1. Passive Hub:-
It is a device which do not require any type of power supply and does not boost incoming
signal, it just echo the incoming signal to all nodes.
2. Active Hub :-
It is a device which requires power supply and boosts the incoming signal and echoes the
signal to all nodes. Hub where absolute due to use of an intelligent device called Switch
which reads the destination adders and sends the incoming packet to it.
The CAT 5 Cable consist of 8 wires which comes pares of White/Blue, Blue, White/Orange,
Orange, White/Green, Green, White/Brown, Brown and they are coded for Straight and Cross
combinations respectively.
The CAT 5 Cable consist of 8 wires which comes pares of White/Blue, Blue, White/Orange,
Orange, White/Green, Green, White/Brown, Brown and they are coded for Straight and Cross
combinations respectively.
1-White/Blue White/Blue 5
Blue 4
2-Wht./Orange White/Orange 1
Orange 2
Green 6
4-White/Brown White/Brown 7
Brown 8
1-White/Blue White/Blue 5
Cross:
Blue 4
2-White/Green White/Green 1
Green 2
3-White/Orange White/Orange 3
Orange 6
4-White/Brown White/Brown 7
Brown 8
2. Un-twist each pair, and straighten each wire between the fingers.
3. Place the wires in the order of one of the two diagrams shown above .Bring all of the wires
together, until they touch.
5. Optional: Make a mark on the wires at 1/2" from the end of the cable jacket.
6. Hold the grouped (and sorted) wires together tightly, between the thumb, and the
forefinger.
7. Cut all of the wires at a perfect 90 degree angle from the cable at 1/2" from the end of the
cable jacket. This is a very critical step. If the wires are not cut straight, they may not all
make contact. We suggest using a pair of scissors for this purpose.
8. Conductors should be at a straight 90 degree angle, and be 1/2" long, prior to insertion into
the connector.
10. Push moderately hard to assure that all of the wires have reached the end of the connector.
Be sure that the cable jacket goes into the back of the connector by about 3/16".
11. Place the connector into a crimp tool, and squeeze hard so that the handle reaches its full
swing.
12. Repeat the process on the other end. For a straight through cable, use the same wiring.
It is a tool used for testing weather there is no cut in between two terminals and to identify the type
of pair crimp with.
Just as routers direct traffic on the Internet, sending information to its proper destination,
and routers on an intranet perform the same function. Routers-equipment that is a combination of
hardware and software-can send the data to a computer on the same sub network inside the intranet,
to another network on the intranet, or outside to the Internet. They do this by examining header
information in IP packets, and then sending the data on its way. Typically, a router will send the
packet to the next router closest to the final destination, which in turn sends it to an even closer
router, and so on, until the data reaches its intended recipient.
A router has input ports for receiving IP packets, and output ports for sending those packets
toward their destination. When a packet comes to the input port, the router examines the packet
header, and checks the destination in it against a routing table-a database that tells the router how
to send packets to various destinations. Based on the information in the routing table, the packet
is sent to a particular output port, which sends the packet to the next closest router to the packet's
destination.
If packets come to the input port more quickly than the router can process them, they are sent to a
holding area called an input queue. The router then processes packets from the queue in the order
they were received. If the number of packets received exceeds the capacity of the queue (called
the length of the queue), packets may be lost.
In a simple intranet that is a single, completely self-contained network, and in which there
are no connections to any other network or the intranet, only minimal routing need be done, and
so the routing table in the router is exceedingly simple with very few entries, and is constructed
automatically by a program called ifconfig
Experiment No-02
AIM: Demonstrate the different types of topologies and types of transmission media by using a
packet tracer tool
OBJECTIVES:
• To study wired LAN using switch.
• To understand setup of LAN using switch.
• To implement use of switch.
PROBLEM STATMENT:
Demonstrate the different types of topologies and types of transmission media by using a packet
tracer tool
OUTCOMES:
CO1: Demonstrate LAN and WAN protocol behavior using Modern Tools.
THEORY:
1. Bus Topologies:-
In a bus network configuration, each node is
connected to one main communications line. With this
arrangement, even if one of the nodes goes down, the rest
of the network can continue to function normally.
2. Star Topologies:-
3. Ring Topology:-
destination, and eventually returned to the sender. The sender removes the attached message and
then passes the freed token to the next station in line. Token ring networks are defined in the IEEE
802.5 standards.
4. Mesh Topology:-
5. Hybrid/Tree Topology:-
A tree topology combines characteristics of linear bus
and star topologies. It consists of groups of starconfigured
workstations connected to a linear bus backbone cable.
Routers are the traffic cops of intranets. They make sure that all data gets sent to where it's
supposed to go and that it gets sent via the most efficient route. Routers are also useful tools to
make the most efficient use of the intranet. Routers are used to segment traffic and provide
redundancy of routes. Routers use encapsulation to permit different protocols to be sent across
otherwise incompatible networks.
Experiment No -03
OBJECTIVES:
• To study error detection and correction.
• To understand CRC and Hamming code techniques.
• To implement CRC and Hamming code techniques.
PROBLEM STATMENT:
Write a program for error detection and correction for 7/8 bits ASCII codes using Hamming
Codes or CRC. Demonstrate the packets captured traces using Wireshark Packet Analyzer Tool
for peer to peer mode
OUTCOMES:
CO2: Analyze data flow between peer to peer in an IP network using Application, Transport and
Network Layer Protocols
THEORY:
Example:
Hamming code:
• Hamming codes are a family of linear error-correcting codes that generalize the
Hamming(7,4)-code
Hamming codes can detect up to two-bit errors or correct one-bit errors without detection of
uncorrected errors
General algorithm:
• The following general algorithm generates a single-error correcting (SEC) code for any
number of bits.
• Write the bit numbers in binary: 1, 10, 11, 100, 101, etc.
• All bit positions that are powers of two (have only one 1 bit in the binary form of their
position) are parity bits: 1, 2, 4, 8, etc. (1, 10, 100, 1000)
• All other bit positions, with two or more 1 bits in the binary form of their position, are data
bits.
• Each data bit is included in a unique set of 2 or more parity bits, as determined by the binary
form of its bit position.
• Each data bit is included in a unique set of 2 or more parity bits, as determined by the binary
form of its bit position.
• Parity bit 1 covers all bit positions which have the least significant bit set: bit 1 (the parity
bit itself), 3, 5, 7, 9, etc.
• Parity bit 2 covers all bit positions which have the second least significant bit set: bit 2 (the
parity bit itself), 3, 6, 7, 10, 11, etc.
• Parity bit 4 covers all bit positions which have the third least significant bit set: bits 4–7,
12–15, 20–23, etc.
• Parity bit 8 covers all bit positions which have the fourth least significant bit set: bits 8–15,
24–31, 40–47, etc.
• In general each parity bit covers all bits where the bitwise AND of the parity position and
the bit position is non-zero.
Example
Suppose a binary data 1001101 is to be transmitted. To implement hamming code for this,
following steps are used:
1. Calculating the number of redundancy bits required. Since number of data bits is
2r > m + r + 1
24 > 7 + 4 + 1
3. Determining the positions of various data bits and redundancy bits. The various r
bits are placed at the position that corresponds to the power of 2 i.e. 1, 2, 4, 8
Considering a case of above discussed example, if bit number 7 has been changed from 1 to
0.The data will be erroneous.
Write a program for error detection and correction for 7/8 bits ASCII codes using
Hamming Codes
#include<stdio.h>
//#include<conio.h>
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);
/* output
proglab@proglab:~$ ./a.out Enter 4 bits of data one by
one
1
SIT, Lonavala. Page 19
Computer Network & Security Lab [CNSL] Computer Engineering Department
0
1
1
Encoded data is
1010101
Error on position 2
Data sent : 1010101
Data received : 0110110
Correct message is
0110100
Experiment No -04
AIM: To demonstrate Go back N and Selective Repeat Modes of Sliding Window Protocol in peer
to peer mode.
OBJECTIVES:
PROBLEM STATMENT:
Write a program to simulate Go back N and Selective Repeat Modes of Sliding Window Protocol
in peer to peer mode and demonstrate the packets captured traces using Wireshark Packet Analyzer
Tool for peer to peer mode.
OUTCOMES:
CO2: Analyze data flow between peer to peer in an IP network using Application, Transport and
Network Layer Protocols
THEORY:
The basic idea of sliding window protocol is that both sender and receiver keep a ‘window’
of acknowledgment. The sender keeps the value of expected acknowledgment; while the
receiver keeps the value of expected receiving frame. When it receives an acknowledgment
from the receiver, the sender advances the window. When it receives the expected frame, the
receiver advances the window.
In transmit flow control, sliding window is a variable-duration window that allows a sender to
transmit a specified number of data units before an acknowledgement is received or before a
specified event occurs.
Flow Control is a set of procedures that tells the sender how much data it can transmit before it
must wait for an acknowledgment from the receiver. The flow of data should not be allowed to
SIT, Lonavala. Page 21
Computer Network & Security Lab [CNSL] Computer Engineering Department
overwhelm the receiver. Receiver should also be able to inform the transmitter before its limits
(this limit may be amount of memory used to store the incoming data or the processing power at
the receiver end) are reached and the sender must send fewer frames. Hence, Flow control refers
to the set of procedures used to restrict the amount of data the transmitter can send before waiting
for acknowledgment.
There are two methods developed for flow control namely Stop-and-wait and Sliding-window
Sliding window algorithms, used by TCP, permit multiple data packets to be in simultaneous
transit, making more efficient use of network bandwidth.
With the use of multiple frames for a single message, the stop-and-wait protocol does not perform
well. Only one frame at a time can be in transit. Efficiency can be greatly improved by allowing
multiple frames to be in transit at the same time. Efficiency can also be improved by making use
of the full-duplex line. To keep track of the frames, sender station sends sequentially numbered
frames. Since the sequence number to be used occupies a field in the frame, it should be of limited
size. If the header of the frame allows k bits, the sequence numbers range from 0 to
2k – 1. Sender maintains a list of sequence numbers that it is allowed to send (sender window).
The size of the sender’s window is at most 2k – 1. The sender is provided with a buffer equal to
the window size. Receiver also maintains a window of size 2k – 1. The receiver acknowledges a
frame by sending an ACK frame that includes the sequence number of the next frame expected.
This also explicitly announces that it is prepared to receive the next N frames, beginning with the
number specified. This scheme can be used to acknowledge multiple frames. It could receive
frames 2, 3, 4 but withhold ACK until frame 4 has arrived. By returning an ACK with sequence
number 5, it acknowledges frames 2, 3, 4 in one go. The receiver needs a buffer of size 1.
Sliding window algorithm is a method of flow control for network data transfers. TCP, the
Internet's stream transfer protocol, uses a sliding window algorithm.
A sliding window algorithm places a buffer between the application program and the network data
flow. For TCP, the buffer is typically in the operating system kernel, but this is more of an
implementation detail than a hard-and-fast requirement.
Data received from the network is stored in the buffer, from where the application can read at its
own pace. As the application reads data, buffer space is freed up to accept more input from the
network. The window is the amount of data that can be "read ahead" - the size of the buffer, less
the amount of valid data stored in it. Window announcements are used to inform the remote host
of the current window size.
An example of a sliding window in packet transmission is one in which, after the sender fails
to receive an acknowledgement for the first transmitted packet, the sender "slides" the window,
i.e. resets the window, and sends a second packet. This process is repeated for the specified
number of times before the sender interrupts transmission. Sliding window is sometimes
(loosely) called acknowledgement delay period.
Go-Back-N Protocol and “Selective Repeat Protocol” are the sliding window protocols. The
sliding window protocol is primarily an error control protocol, i.e. it is a method of error
detection and error correction. The basic difference between go-back-n protocol and selective
repeat protocol is that the “go-back-n protocol” retransmits all the frames that lie after the
frame which is damaged or lost. The “selective repeat protocol” retransmits only that frame
which is damaged or lost.
Go back N ARQ
In the Go-Back-N Protocol, the sequence numbers are modulo 1!", Where
m is the size of the sequence number field in bits.
Go-Back-N ARQ simplifies the process at the receiver site. The receiver keeps track of only one
variable, and there is no need to buffer out-of-order frames; they are simply discarded. However,
this protocol is very inefficient for a noisy link. In a noisy link a frame has a higher probability of
damage, which means the resending of multiple frames. This resending uses up the bandwidth and
slows down the transmission. For noisy links, there is another mechanism that does not resend N
frames when just one frame is damaged; only the damaged frame is resent. This mechanism is
called Selective Repeat ARQ.
1. Go-Back-N protocol is design to retransmit all the frames that are arrived after the
damaged or a lost frame. On the other hand, Selective Repeat protocol retransmits only
that frame that is damaged or lost.
2. If the error rate is high i.e. more frames are being damaged and then retransmitting all the
frames that arrived after a damaged frame waste the lots of bandwidth. On the other hand,
selective repeat protocol re-transmits only damaged frame hence, minimum bandwidth is
wasted.
3. All the frames after the damaged frame are discarded and the retransmitted frames arrive
in a sequence from a damaged frame onwards, so, there is less headache of sorting the
frames hence it is less complex. On the other hand only damaged or suspected frame is
retransmitted so, extra logic has to be applied for sorting hence, it is more complicated.
4. Go-Back-N has a window size of N-1 and selective repeat have a window size
<=(N+1)/2.
5. Neither sender nor receiver need the sorting algorithm in Go-Back-N whereas, receiver
must be able to sort the as it has to maintain the sequence.
6. In Go-Back-N receiver discards all the frames after the damaged frame hence, it don’t
need to store any frames. Selective repeat protocol does not discard the frames arrived
after the damaged frame instead it stores those frames till the damaged frame arrives
successfully and is sorted in a proper sequence.
7. In selective repeat NAK frame refers to the damaged frame number and in Go-Back-N,
NAK frame refers to the next frame expected.
8. Generally the Go-Back-N is more is use due to its less complex nature instead of
Selective Repeat protocol.
Write a program to simulate Go back N and Selective Repeat Modes of Sliding Window Protocol in Peer-to-Peer mode
#include <stdio.h>
#include <conio.h>
#include <math.h>
int n, r;
struct frame
{
char ack;
int data;
void goback()
{
sender(); recvack();
sender();
printf("\n all frames sent succesfully \n");
}
void selective()
{
sender(); recvack();
resend_sr();
printf("\n all frames sent succesfully \n");
}
int sender()
{
int i,data;
printf("\nEnter the no.of frames to be sent:"); scanf("%d", &n);
for (i = 1; i <= n; i++)
{
printf("\nEnter the data for frames [%d]", i);
scanf("%d", &frm[i], data);
frm[i].ack = 'y';
}
return 0;
}
void recvack()
{
int i; rand();
r = rand() % n;
frm[r].ack = 'n';
for (i =1;i <= n; i++)
{
if (frm[i].ack == 'n')
printf("\nThe frame number %d is not recieved\n", r);
}
}
void resend_sr()
{
printf("\nresending frame %d", r); sleep(2);
frm[r].ack = 'y';
printf("\nThe received frame is %d", frm[r].data);
}
/*int resend_gb()
{
int i,data;
printf("\nEnter the no.of frames to be sent:"); scanf("%d", &n);
for (i = 1; i <= n; i++)
{
printf("\nEnter the data for frames [%d]", i); scanf("%d", &frm[i], data);
frm[i].ack = 'y';
}
return 0;
}
/*void resend_gb()
{
int i;
printf("\nAgain send frame %d", r); for (i = r;i <= n; i++)
{
sleep(2);
frm[i].ack = 'y';
printf("\n received data of frame %d is %d", i, frm[r].data);
}
}*/ int main()
{
int c;
do
{
printf("\n\n1.Selective repeat ARQ\n2.GOback ARQ\n3.exit");
CONCLUSION: - Hence we have implemented of sliding window protocol (Go back N and
Selective Repeat).
Experiment No -05
AIM: To understand subnetting concepts and also find subnet mask of network.
OBJECTIVES:
PROBLEM STATMENT:
OUTCOMES:
CO2: Analyze data flow between peer to peer in an IP network using Application, Transport and
Network Layer Protocols
THEORY:
What is IP address?
An Internet Protocol address (IP address) is a numerical label assigned to each device (e.g.,
computer, printer) participating in a computer network that uses the Internet Protocol for
communication. An IP address serves two principal functions: host or network interface
identification and location addressing. IP address is a 32 bit number. It is universally unique
What is subnet?
A sub network, or subnet, is a logical, visible subdivision of an IP network. The practice of dividing
a network into two or more networks is called sub netting. Computers that belong to a subnet are
addressed with a common identical, most-significant bit-group in their IP. This results in the
logical division of an IP address into two fields, a network or routing prefix and the rest field or
host identifier. The rest field is an identifier for a specific host or network interface.
For the purpose of network management, an IP address is divided into two logical parts, the
network prefix and the host identifier or rest field. All hosts on a sub network have the same
network prefix. This routing prefix occupies the most-significant bits of the address. The number
of bits allocated within a network to the internal routing prefix may vary between subnets,
depending on the network architecture. While in IPv6 the prefix must consist of a set of contiguous
1-bits, in IPv4 this is not enforced, though there is no advantage to using noncontiguous 1-bits.
The host part is a unique local identification and is either a host number on the local network or
an interface identifier.
An IP address has two components, the network address and the host address. A subnet mask
separates the IP address into the network and host addresses (<network><host>). Subnetting
further divides the host part of an IP address into a subnet and host address
A Subnet mask is a 32-bit number that masks an IP address, and divides the IP address into network
address and host address. Subnet Mask is made by setting network bits to all "1"s and setting host
bits to all "0"s. Within a given network, two host addresses are reserved for special purpose, and
cannot be assigned to hosts. The "0" address is assigned a network address and "255" is assigned
to a broadcast address, and they cannot be assigned to hosts.
A mask used to determine what subnet an IP address belongs to. An IP address has two
components, the network address and the host address.
For example:
Consider the IP address 150.215.017.009. Assuming this is part of a Class B network, the first
two numbers (150.215) represent the Class B network address, and the second two numbers
(017.009) identify a particular host on this network.
Subnetting an IP network is to separate a big network into smaller multiple networks for
reorganization and security purposes. All nodes (hosts) in a sub network see all packets transmitted
by any node in a network. Performance of a network is adversely affected under heavy traffic load
due to collisions and retransmissions.
Applying a subnet mask to an IP address separates network address from host address. The network
bits are represented by the 1's in the mask, and the host bits are represented by 0's. Performing a
bitwise logical AND operation on the IP address with the subnet mask produces the network
address.
Write a program to demonstrate Sub-netting and find subnet masks import java.io.*; import
java.net.InetAddress; class subnet1 {
System.out.println("ENTER IP:");
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
String ip = br.readLine();
String checkclass = ip.substring(0, 3);
int cc = Integer.parseInt(checkclass);
String mask = null;
if(cc>0)
{
if(cc<=127)
{
mask = "255.0.0.0";
System.out.println("Class A IP Address");
System.out.println("SUBNET MASK:\n"+mask);
}
if(cc>=128 && cc<=191)
{
mask = "255.255.0.0";
System.out.println("Class B IP Address");
System.out.println("SUBNET MASK:\n"+mask);
}
if(cc>=192 && cc<=223)
{
mask = "255.255.255.0";
System.out.println("Class C IP Address");
System.out.println("SUBNET MASK:\n"+mask);
}
if(cc>=224 && cc<=239)
{
mask = "255.0.0.0";
System.out.println("Class D IP Address Used for multicasting");
}
if(cc>=240 && cc<=254)
{
mask = "255.0.0.0";
System.out.println("Class E IP Address Experimental Use");
}
}
String networkAddr="";
String lastAddr="";
String[] ipAddrParts=ip.split("\\.");
String[] maskParts=mask.split("\\.");
C:\Users\Hitesh>d:
D:\>cd program
Experiment No-06
AIM: Write a program to implement link state /Distance vector routing protocol to find suitable
path for transmission.
OBJECTIVES:
PROBLEM STATMENT:
Write a program to implement link state /Distance vector routing protocol to find suitable path for
transmission.
OUTCOMES:
CO2: Analyze data flow between peer to peer in an IP network using Application, Transport and
Network Layer Protocols
THEORY:
A distance-vector routing (DVR) protocol requires that a router inform its neighbors of topology
changes periodically. Historically known as the old ARPANET routing algorithm (or known as
Bellman-Ford algorithm).
Bellman Ford Basics – Each router maintains a Distance Vector table containing the distance
between itself and ALL possible destination nodes. Distances, based on a chosen metric, are
computed using information from the neighbors’ distance vectors.
1. A router transmits its distance vector to each of its neighbors in a routing packet.
2. Each router receives and saves the most recently received distance vector from each of its
neighbors.
3. A router recalculates its distance vector when:
• It receives a distance vector from a neighbor containing different information than
before.
• It discovers that a link to a neighbor has gone down.
• From time-to-time, each node sends its own distance vector estimate to neighbors.
When a node x receives new DV estimate from any neighbor v, it saves v’s
distance vector and it updates its own DV using B-F equation:
• Dx(y) = min { C(x,v) + Dv(y), Dx(y) } for each node y N
Example – Consider 3-routers X, Y and Z as shown in figure. Each router have their routing
table. Every routing table will contain distance to the destination nodes.
Consider router X , X will share it routing table to neighbors and neighbors will share it routing
table to it to X and distance from node X to destination will be calculated using bellmen- ford
equation.
Dx(y) = min { C(x,v) + Dv(y)} for each node y N
As we can see that distance will be less going from X to Z when Y is intermediate node(hop) so
it will be update in routing table X.
Write a program to implement link state /Distance vector routing protocol to find suitable path
for transmission.
#include<stdlib.h>
#include<stdio.h>
#define NUL 1000 #define NODES 10
struct node
{
int t[NODES][3];
};
struct node n[NODES]; typedef struct node NOD;
int main()
{
void init(int,int); void inp(int,int); void
caller(int,int); void op1(int,int,int); void
find(int,int);
int i,j,x,y,no; do{
printf("\n Enter the no of nodes required:");
scanf("%d",&no); }while(no>10||no<0); for(i=0;i<no;i++)
{ init(no,i); inp(no,i);
}
printf("\nThe configuration of the nodes after initalization is as follows:"); for(i=0;i<no;i++) op1(no,i,0);
for(j=0;j<no;j++)
{
for(i=0;i<no;i++)
caller(no,i);
}
printf("\nThe config of the nodes after the comp of the paths is as follows:"); for(i=0;i<no;i++) op1(no,i,1); while(1)
{ printf("\n Enter 0 to exit or any other key to find the shortest path:"); scanf("%d",&j); if(!j) break; Do{
printf("\n Enter the nodes btn which path is to be found:"); scanf("%d%d",&x,&y);
}while((x<0||x>no) && (y<0||y>no));
printf("\nThe most suitable route from node %d to %d is as follows\n",x,y); find(x,y); printf("%d",y);
printf("\nThe length of the shortest path between node %d & %d is %d",x,y,n[x1].t[y-
1][2]); }
}
void init(int no,int x)
{
int i; for(i=0;i999); if(n[x].t[i][2]!=999) n[x].t[i][3]=i; }
}}
void caller(int no,int x) { void compar(int,int,int); int i; for(i=0;iz) { n[x].t[i][2]=z; n[x].t[i][3]=y; }
}
}
void op1(int no,int x,int z)
{ int i,j;
printf("\n The routing table for node no %d is as follows",x+1);
printf("\n\n\t\t\tDESTINATION\tDISTANCE\tNEXT_HOP"); for(i=0;i=999) ||(n[x].t[i][2]>=(999*no)))
printf("\n\t\t\t %d \tNO LINK \t NO HOP",n[x].t[i][1]+1); else if(n[x].t[i][3]==NUL)
printf("\n\t\t\t %d \t\t %d \t\t NO HOP",n[x].t[i][1]+1,n[x].t[i][2]); else
printf("\n\t\t\t %d \t\t %d \t\t%d",n[x].t[i][1]+1,n[x].t[i][2],n[x].t[i][3]+1); } }
void find(int x,int y) COMPUTER NETWORKS LABORATORY { int i,j; i=x-1; j=y-1; printf("%d->",x);
if(n[i].t[j][3]!=j) { find(n[i].t[j][3]+1,y); return; } }
Experiment No-07
OBJECTIVES:
• To study TCP protocol.
• To implement socket programming.
• To use TCP socket for wired network.
PROBLEM STATMENT:
Write a program using TCP socket for wired network for following a.
Say Hello to Each other
b. File transfer
c. Calculator
OUTCOMES:
THEORY:
TCP:
The Transmission Control Protocol provides a communication service at an intermediate level
between an application program and the Internet Protocol. It provides host-to-host connectivity at
the Transport Layer of the Internet model.
Most intercrosses communication uses the client server model. These terms refer to the two
processes which will be communicating with each other. One of the two processes, the client,
connects to the other process, the server, typically to make a request for information. A socket is
one end of an intercrosses communication channel. The two processes each establish their own
socket.
The steps involved in establishing a socket on the client side are as follows:
2. Connect the socket to the address of the server using the connect( ) system call
3. Send and receive data. There are a number of ways to do this, but the simplest is to use the
read ( ) and write ( ) system calls.
4. Accept a connection with the accept ( ) system call. This call typically blocks until a client
connects with the server.
FTP:
The File Transfer Protocol (FTP) is a standard network protocol used to transfer computer files
from one host to another host over a TCP-based network, such as the Internet. FTP is built on
client-server architecture and uses separate control and data connections between the client and
the server. FTP users may authenticate themselves using a clear-text sign-in protocol, normally in
the form of a username and password, but can connect anonymously if the server is configured to
allow it. For secure transmission that protects the username and password, and encrypts the
content, FTP is often secured with SSL/TLS (FTPS).
FTP may run in active or passive mode, which determines how the data connection is established.
In both cases, the client creates a TCP control connection from a random unprivileged port N to
the FTP server command port 21. In active modes, the client starts listening for incoming data
connections on port N+1 from the server (the client sends the FTP command PORT N+1 to inform
the server on which port it is listening). In situations where the client is behind a firewall and
unable to accept incoming TCP connections, passive mode may be used. In this mode, the client
SIT, Lonavala. Page 43
Computer Network & Security Lab [CNSL] Computer Engineering Department
uses the control connection to send a PASV command to the server and then receives a server IP
address and server port number from the server, which the client then uses to open a data
connection from an arbitrary client port to the server IP address and server port number received.
Both modes were updated in September 1998 to support IPV6. Further changes were introduced
to the passive mode at that time, updating it to extended passive mode.
The server responds over the control connection with three-digit status codes in ASCII with an
optional text message. The numbers represent the code for the response and the optional text
represents a human-readable explanation or request. An ongoing transfer of file data over the data
connection can be aborted using an interrupt message sent over the control connection.
Login
FTP login utilizes a normal username and password scheme for granting access. The username is
sent to the server using the USER command, and the password is sent using the PASS command.
If the information provided by the client is accepted by the server, the server will send a greeting
to the client and the session will commence.
Anonymous FTP
A host that provides an FTP service may provide anonymous FTP access. Users typically log into
the service with an 'anonymous' (lower-case and case-sensitive in some FTP servers) account when
prompted for user name. Although users are commonly asked to send their email address instead
of a password, no verification is actually performed on the supplied data.
Write a program using TCP socket for wired network for following a.
Say Hello to Each other b. File transfer c. Calculator
// Hello Client Side
#include<sys/types.h>
#include<sys/socket.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>
#define buffsize 150
int main(void)
{
struct sockaddr_in clientaddr;
if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0)
Hello server:
// Hello Server-Side Program
#include<sys/types.h>
#include<sys/socket.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<netinet/in.h>
#include<stdlib.h>
int main(void)
{
struct sockaddr_in servaddr,clientaddr; char
buff[buffsize],crcbuff[buffsize]; int listenfd,connfd;
int sin_size;
if((listenfd=socket(AF_INET,SOCK_STREAM,0))==-1) perror("Socket
Creation Error.\n"); else
printf("Socket Created Successfully\n"); bzero((char *) &servaddr,
sizeof(servaddr)); servaddr.sin_family=AF_INET;
servaddr.sin_addr.s_addr=inet_addr("192.168.0.1"); servaddr.sin_port=htons(54321);
if(bind(listenfd, (struct sockaddr *)&servaddr,sizeof(servaddr)) == -1)
perror("Bind Error\n");
listen(listenfd,4);
sin_size = sizeof(struct sockaddr_in);
for(;;)
{
if((connfd=accept(listenfd,(struct sockaddr *)&clientaddr,
&sin_size))==-1)
Echo.client:
#include<stdio.h>
#include<stdlib.h>
#include<error.h>
#include<string.h>
#include<netdb.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<sys/socket.h>
#include<sys/wait.h>
#define PORT 54321 /*well know port */ /* 55*/
#define MAXLINE 100 /* how many pending connection queue will hold */ void str_cli(FILE *fp, int sockfd)
{
char sendline[MAXLINE], recvline[MAXLINE]; int i;
while(fgets(sendline,MAXLINE,fp) != NULL)
{
for(i=0;i<100;i++)
recvline[i]='\0';
write(sockfd,sendline, strlen(sendline)); if
(read(sockfd,recvline,MAXLINE)==0)
perror("server terminated prematurely");
fputs(recvline,stdout);
}
}
perror("connect"); exit(1);
printf("Enter the data \n");
}
str_cli(stdin, sockfd);
exit(0);
}
Echo server.c
#include <stdio.h>
#include <stdlib.h>
#include <error.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/wait.h>
exit(1); } for( ; ; )
{
clilen = sizeof(their_addr);
if ((new_fd =accept(sockfd, (struct sockaddr*)&their_addr,&clilen)) == -1)
{
perror("accept");
continue;
}
if ( ( childpid = fork() ) == 0)
{
close(sockfd); str_echo(new_fd);
exit(0);
}
close(new_fd);
}
}
*OUTPUT CLIENT
iotlab@iotlab-Veriton-M200-B360:~$ cd TCP\ Socket/ iotlab@iotlab-Veriton-M200-B360:~/TCP Socket$ cd Simple\ Hello/
iotlab@iotlab-Veriton-M200-B360:~/TCP Socket/Simple Hello$ gcc client_simple_hello.c -o client client_simple_hello.c: In
function ‘main’: client_simple_hello.c:23:30: warning: implicit declaration of function ‘inet_addr’; did you mean
‘s6_addr’? [-Wimplicit-function-declaration] serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
^~~~~~~~~ s6_addr
iotlab@iotlab-Veriton-M200-B360:~/TCP Socket/Simple Hello$ ./client
Data received: Hello World
OUTPUT SERVER
iotlab@iotlab-Veriton-M200-B360:~/TCP Socket/Simple Hello$ gcc server_simple_hello.c -o server server_simple_hello.c: In function ‘main’:
server_simple_hello.c:24:30: warning: implicit declaration of function ‘inet_addr’; did you mean ‘s6_addr’?
[-Wimplicit-function-declaration]
serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
^~~~~~~~~ s6_addr
iotlab@iotlab-Veriton-M200-B360:~/TCP Socket/Simple Hello$ ./server Listening
*/ /*OUTPUT
SERVER
iotlab@iotlab-Veriton-M200-B360:~$ cd TCP\ Socket/ iotlab@iotlab-Veriton-M200-B360:~/TCP Socket$ cd File\ Transfer/
iotlab@iotlab-Veriton-M200-B360:~/TCP Socket/File Transfer$ gcc Server_file.c -o server
iotlab@iotlab-Veriton-M200-B360:~/TCP Socket/File Transfer$ ./server
Socket retrieve success
Bytes read 0
End of file
OUTPUT CLIENT
iotlab@iotlab-Veriton-M200-B360:~/TCP Socket/File Transfer$ gcc Client_file.c -o client iotlab@iotlab-Veriton-M200-B360:~/TCP Socket/File
Transfer$ ./clientiotlab@iotlab-Veriton-M200-
B360:~/TCP Socket/File Transfer$
CONCLUSION: - Thus we have successfully implemented the socket programming for TCP using C.
Experiment No 08
OBJECTIVES:
• To study UDP protocol.
• To implement socket programming.
• To transfer files using UDP socket.
PROBLEM STATMENT:
Write a program using UDP Sockets to enable file transfer (Script, Text, Audio and Video one
file each) between two machines. Demonstrate the packets captured traces using Wireshark
Packet Analyzer Tool for peer to peer mode.
OUTCOMES:
THEORY:
UDP:
UDP (User Datagram Protocol) is a communication protocol that offers a limited amount of service
when messages are exchanged between computers in a network that uses the Internet Protocol (IP).
UDP is an alternative to the Transmission Control Protocol (TCP) and, together with IP, is
sometimes referred to as UDP/IP. Like the Transmission Control Protocol, UDP uses the Internet
Protocol to actually get a data unit (called a datagram) from one computer to another. Unlike TCP,
however, UDP does not provide the service of dividing a message into packets (datagrams) and
reassembling it at the other end. Specifically, UDP doesn't provide sequencing of the packets that
the data arrives in. This means that the application program that uses UDP must be able to make
sure that the entire message has arrived and is in the right order. Network applications that want
to save processing time because they have very small data units to exchange (and therefore very
little message reassembling to do) may prefer UDP to TCP. The Trivial File Transfer Protocol
(TFTP) uses UDP instead of TCP.
With a UDP socket a connection is NOT made, instead the sender just issues a message to its
destination and hopes it gets there! The message uses a datagram of fixed length, often termed a
record. Since there is no connection between client and server the client can send a datagram to
one server and then immediately send a datagram to another server using the same socket UDP is
a connectionless protocol.
Trivial File Transfer Protocol (TFTP) is a simple, lock-step, file transfer protocol which allows a
client to get from or put a file onto a remote host.
TFTP is a simple protocol for transferring files, implemented on top of the UDP/IP protocols
using IANA registered port number 69. TFTP was designed to be small and easy to implement,
And therefore it lacks most of the advanced features offered by more robust file transfer
protocols.
Write a program using UDP Sockets to enable file transfer (Script, Text, Audio and
Video one file each) between two machines.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<arpa/inet.h>
#include<sys/socket.h>
int main(void)
{
struct sockaddr_in si_other; int s, i,
slen=sizeof(si_other); char buf[BUFLEN];
char message[BUFLEN];
if (inet_aton(SERVER , &si_other.sin_addr) == 0)
{
fprintf(stderr, "inet_aton() failed\n");
exit(1);
}
//memset(message,0,503);
char fname[20];
printf("Enter Filename with extension: ");
scanf("%s",&fname);
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<arpa/inet.h>
#include<sys/socket.h>
exit(1);
}
int main(void)
{
struct sockaddr_in si_me, si_other;
//printf("%s",fname);
memset(buf,0,503);
recv_len = recvfrom(s, buf, 20, 0, (struct sockaddr *) &si_other, &slen);
/*if ((recv_len = recvfrom(s, buf, 20, 0, (struct sockaddr *) &si_other, &slen)) == -1)
{
die("recvfrom()");
}*/
//printf("%s",buf);
strcpy(fna,buf); int len= strlen(fna);
printf("%d",len);
for(j=len-1;j>=0;j--)
{
if(fna[j]=='.')
{
fna[j-1]='1';
}
}
unsigned long mm = atoi(buf); //fp=fopen("ve1.mp4","wb");
//fp=fopen("mysiren1.mp3","wb");
OUTPUT : ad SIT,Lonavala
CONCLUSION: - Thus we have successfully implemented the socket programming for UDP to
enable file transfer (Script, Text, Audio and Video one file each) between two machines
Experiment No-09
AIM: To capture packets using Wireshark, write the exact packet capture filter expressions to
accomplish the following and save the output in file:
OBJECTIVES:
PROBLEM STATMENT:
Write a program to analyze following packet formats captured through Wireshark for wired
network. 1. Ethernet 2. IP 3.TCP 4. UDP
OUTCOMES:
• Hardware:
THEORY:
A packet analyzer (also known as a network analyzer, protocol analyzer or packet sniffer or for
particular types of networks, an Ethernet sniffer or wireless sniffer) is a computer program or a
piece of computer hardware that can intercept and log traffic passing over a digital network or part
of a network. As data streams own across the network, the sniffer captures each packet and, if
needed, decodes the packet's raw data, showing the values of various fields in the packet, and
analyzes its content according to the appropriate RFC or other specifications.
1. TCP:
The Transmission Control Protocol (TCP) is one of the core protocols of the Internet protocol suite
(IP), and is so common that the entire suite is often called TCP/IP. TCP provides reliable, ordered
and error-checked delivery (or notification of failure to deliver) of a stream of octets between
programs running on computers connected to a local area network, intranet or the public Internet.
It resides at the transport layer. Web browsers use TCP when they connect to servers on the World
Wide Web, and it is used to deliver email and transfer files from one location to another. The
protocol corresponds to the transport layer of TCP/IP suite. TCP provides a communication service
at an intermediate level between an application program and the Internet Protocol (IP). That is,
when an application program desires to send a large chunk of data across the Internet using IP,
instead of breaking the data into IP-sized pieces and issuing a series of IP requests, the software
can issue a single request to TCP and let TCP handle the IP works by exchanging pieces of
information called packets. A packet is a sequence of octets (bytes) and consists of a header
followed by a body.
The header describes the packet's source, destination and control information. The body contains
the data IP is transmitting. Due to network congestion, traffic load balancing, or other
unpredictable network behavior, IP packets can be lost, duplicated, or delivered out of order. TCP
detects these problems, requests retransmission of lost data, rearranges out-of-order data, and even
helps minimize network congestion to reduce the occurrence of the other problems. If the data still
remains undelivered, its source is notified of this failure. Once the TCP receiver has reassembled
the sequence of octets originally transmitted, it passes them to the receiving application. Thus,
TCP abstracts the application's communication from the underlying networking details. TCP is a
reliable stream delivery service that guarantees that all bytes received will be identical with bytes
sent and in the correct order. Since packet transfer over many networks is not reliable, a technique
known as positive acknowledgment with retransmission is used to guarantee reliability of packet
transfers. This fundamental technique requires the receiver to respond with an acknowledgment
message as it receives the data. The sender keeps a record of each packet it sends. The sender also
maintains a timer from when the packet was sent, and retransmits a packet if the timer expires
before the message has been acknowledged. The timer is needed in case a packet gets lost or
corrupted.
2. UDP:
The User Datagram Protocol (UDP) is one of the core members of the Internet protocol Suite. UDP
uses a simple connectionless transmission model with a minimum of protocol mechanism. It has
no handshaking dialogues, and thus exposes any unreliability of the underlying network protocol
to the user's program. There is no guarantee of delivery, ordering, or duplicate protection. UDP
provides checksums for data integrity, and port numbers for addressing different functions at the
source and destination of the datagram. With UDP, computer applications can send messages, in
this case referred to as datagrams, to other hosts on an Internet Protocol (IP) network without prior
communications to set up special transmission channels or data paths. UDP is suitable for purposes
where error checking and correction is either not necessary or is performed in the application,
avoiding the overhead of such processing at the network interface level. Time-sensitive
applications often use UDP because dropping packets is preferable to waiting for delayed packets,
which may not be an option in a real-time system.
3. ICMP:
The Internet Control Message Protocol (ICMP) is one of the main protocols of the Internet Protocol
Suite. It is used by network devices, like routers, to send error messages indicating, for example,
that a requested service is not available or that a host or router could not be reached.
ICMP can also be used to relay query messages. It is assigned protocol number 1.ICMP differs
from transport protocols such as TCP and UDP in that it is not typically used to exchange data
between systems, nor is it regularly employed by end-user network applications (with the
Exception of some diagnostic tools like ping and trace route). ICMP for Internet Protocol version
4 (IPv4) is also known as ICMPv4. IPv6 has a similar protocol, ICMPv6. The Internet Control
Message Protocol is part of the Internet Protocol Suite, as defined in RFC 792. ICMP messages
are typically used for diagnostic or control purposes or generated in response to errors in IP
operations. ICMP errors are directed to the source IP address of the originating packet.
4. IGMP:
The Internet Group Management Protocol (IGMP) is a communications protocol used by hosts
and adjacent routers on IP networks to establish multicast group memberships. IGMP is an integral
part of IP multicast. IGMP can be used for one-to-many networking applications such as online
streaming video and gaming, and allows more efficient use of resources when supporting these
types of applications. IGMP messages are carried in bare IP packets with IP protocol. There is no
transport layer used with IGMP messaging, similar to the Internet Control Message Protocol.
Membership Queries are sent by multicast routers to determine which multicast addresses are of
interest to systems attached to its network. Routers periodically send General Queries to refresh
the group membership state for all systems on its network. Group-Specific Queries are used for
determining the reception state for a particular multicast address.
Write a program to analyze following packet formats captured through Wireshark for wired
network. 1. Ethernet 2. IP 3.TCP 4. UDP
#include <iostream>
#include<fstream>
#include <iomanip>
#include<string>
using namespace std;
int main()
{
cout << "***** PACKET ANALYZER *****" << endl;
string value, sr_no,time,source,destination,info,protocol,len;
int count=-1,i=0;
int choice;
do
{
ifstream file("data.csv");
//Reinitialize Counters
count=-1;
i=0;
cout<<"\nEnter which protocol packets you want to see"<<endl;
cout<<"1.IP\n2.UDP\n3.TCP\n4.Ethernet\n0Exit!!!\nChoice:"<<endl;
cin>>choice;
string protocolChoice; //sting to hold user packet choice
switch(choice){
case 1: protocolChoice="ICMPv6";
break;
case 2: protocolChoice="UDP";
break;
case 3: protocolChoice="TCP";
break;
case 4: protocolChoice="ARP";
break;
default: protocolChoice="ARP";
break;
}
while(file.good()) //LOOP UNTIL FILE HAS CONTENT
{
getline(file,sr_no,','); //GET STRING TILL ,
getline(file,time,',');
getline(file,source,',');
getline(file,destination,',');
getline(file,protocol,',');
getline(file,len,',');
getline(file,info,'\n');
protocol=string(protocol,1,protocol.length()-2);
if(protocol=="Protocol"||protocol==protocolChoice)
{
cout <<setw(4)<<left<<i++;
cout <<setw(12)<<left<< string( time, 1, time.length()-2 );
cout << setw(30)<<left<<string( source, 1, source.length()-2 );
cout << setw(30)<<left<<string( destination, 1, destination.length()-2 );
cout <<setw(8)<<left<<protocol;
cout <<setw(8)<<left<< string( len, 1, len.length()-2 );
cout << string( info, 1, info.length()-2 )<<"\n";
count++;
}
}
file.close();
cout<<"\nTotal Packet Count: "<<count;
}while(choice!=0);
return 0;
}
/* output:
* ***** PACKET ANALYZER *****
CONCLUSION:
Hence we have implemented packet formats captured through Wireshark for wired network. 1.
Ethernet 2. IP 3.TCP 4. UDP.
Experiment No 10
OBJECTIVES:
PROBLEM STATMENT:
Write a program for DNS lookup. Given an IP address input, it should return URL and viceversa
OUTCOMES:
CO2: Analyze data flow between peer to peer in an IP network using Application, Transport and
Network Layer Protocols
THEORY:
How does a DNS query work? When a DNS client needs to look up a name used in a program, it
queries DNS servers to resolve the name. Each query message the client sends contains three
pieces of information, specifying a question for the server to answer: ... A specified class for the
DNS domain name
Querying DNS. Click the Windows Start button, then "All Programs" and "Accessories."
Rightclick on "Command Prompt" and choose "Run as Administrator." Type "nslookup
%ipaddress%" in the black box that appears on the screen, substituting %ipaddress% with the IP
address for which you want to find the hostname
Instead, you just connect through a domain name server, also called a DNS server or name server,
which manages a massive database that maps domain names toIP addresses. ... The proper term
for this process is DNS name resolution, and you would say that the DNS server resolves the
domain name to the IP address.
Domain Names and IP Addresses. An Internet Protocol, or IP, address is different than a domain
name. The IP address is an actual set of numerical instructions. ... A typical IP address looks like
a string of numbers. It could be 232.17.43.22, for example.
URLs (Uniform Resource Locators) and IP addresses are just identifiers used for this purpose.
The main difference between URL and IP address is what they point to. An IP address basically
points to a computer, whether it is the physical hardware or a virtual one as in the case of shared
hosting
}
else
{
Scanner input = new Scanner(System.in);
System.out.print("\n Enter IP address: "); host =
input.nextLine();
try {
InetAddress address = InetAddress.getByName(host);
System.out.println("Host name : " + address.getHostName());
System.out.println("IP address: " + address.getHostAddress());
System.out.println("Host name and IP address: " + address.toString());
}
catch (UnknownHostException ex) {
System.out.println("Could not find " + host);
} }
}
}
CONCLUSION:
Hence we have implemented DNS lookup.
Experiment NO-11
OBJECTIVES:
• To study RIP/OSPF/BGP protocol.
• To implement packet tracer.
• To Configure RIP/OSPF/BGP.
PROBLEM STATMENT:
OUTCOMES:
THEORY:
Step 1: Enable the RIP routing process, which places you in router configuration mode via the
Router#router rip command.
Step 2: Specify those networks that should be advertised using RIP via the Router (config-router)
#network [network-number] command.
Step 1: Use the router ospf command in global configuration mode to enable OSPF on the R1
router. Enter a process ID of 1 for the process-ID parameter.
R1 (config) #router ospf 1
R1 (config-router) #
Step 3: Configure the router to advertise the 192.168.10.0/30 network attached to the Serial0/0/0
interface.
R1 (config-router) # network 192.168.10.0 0.0.0.3 area 0
R1 (config-router) #
Step 4: Configure the router to advertise the 192.168.10.4/30 network attached to the Serial0/0/1
interface.
R1 (config-router) # network 192.168.10.4 0.0.0.3 area 0
R1 (config-router) #
Step 5: When you are finished with the OSPF configuration for R1, return to privileged
EXEC mode.
R1 (config-router) #end
%SYS-5-CONFIG_I: Configured from console by console R1#
Router 1
R1(config)#
R1(config)#int fa0/0
R1(config-if)#ip address 10.0.0.1 255.0.0.0
R1(config-if)#no shut
R1(config-if)#
R1(config-if)#int serial 0/0/0
R1(config-if)#ip add 20.0.0.1 255.0.0.0
R1(config-if)#no shut
Router 2
R2(config)#
R2(config)#int fa0/0
R2(config-if)#ip add 30.0.0.1 255.0.0.0
R2(config-if)#no shut
R2(config-if)#
R2(config-if)#int serial 0/0/0
R2(config-if)#ip add 20.0.0.2 255.0.0.0
R2(config-if)#no shut
IP configuration on PCs
Click PC->Desktop->IP Configuration. On each PC assign these addresses:
PC1: IP address: 10.0.0.2 Subnet mask 255.0.0.0 Default Gateway 10.0.0.1 PC2: IP address:
And now:
Router 1
R1(config)#
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#network 10.0.0.0
R1(config-router)#network 20.0.0.0
Router 2
R2(config)#
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#network 20.0.0.0
R2(config-router)#network 30.0.0.0
CONCLUSION:
Hence we have implemented configuration of RIP/OSPF/BGP using packet tracer.
Experiment No 12
AIM: Study and analyse the performance of HTTP, HTTPS and FTP protocol using Packet tracer
tool.
OBJECTIVES:
PROBLEM STATMENT:
OUTCOMES:
CO4: Develop Client-Server architectures and prototypes by the means of correct standards and
technology.
THEORY:
The File Transfer Protocol (FTP) is a standard network protocol used for the transfer of
computer files between a client and server on a computer network.
FTP employs a client-server architecture whereby the client machine has an FTP client
installed and establishes a connection to an FTP server running on a remote machine. After
the connection has been established and the user is successfully authenticated, the data
transfer phase can begin.
Worth noting: Although FTP does support user authentication, all data is sent in clear text,
including usernames and passwords. For secure transmission that protects the username
and password, and encrypts the content, FTP is often secured with SSL/TLS (FTPS) or
replaced with SSH File Transfer Protocol (SFTP).
FTP topology.PNG
3. Now try using an FTP client built in the Laptop to send files to an FTP server configured in
the Server.
From the Laptop’s command prompt, FTP the server using the server IP address by typing:
ftp 192.168.1.2
Provide the username(cisco) and password(cisco) [which are the defaults] for ftp login.
PC0 has an FTP client which can be used to read, write, delete and rename files present in
the FTP server.
The FTP server can be used to read and write configuration files as well as IOS images.
Additionally, the FTP server also supports file operations such rename, delete and listing
directory.
4. Create a file in the Laptop then upload it to the server using FTP.
To do this, open the Text Editor in the Laptop, create a file and give it your name of choice.
Type any text in the editor then save your file. e.g. myFile.txt.
5. Now upload the file from the Laptop to the server using FTP. (An FTP connection has to
be started first. But this is what we’ve done in step 3)
put MyFile.txt
6. Once file upload is successful, go to the Server FTP directory to verify if the file sent has
been received . To do this, go to Server-> Services->FTP. Here look for MyFile.txt sent from
the laptop.
Something extra: To check other FTP commands supported by the FTP client running on the
Laptop(or PC), you can use a question mark (?) on the Laptop’s command prompt as shown
below:
You can see the put command that we used to upload our file to the FTP server. Other
commands listed include: get-used to get(download) a file from the server. For example: get
MyFile.txt delete– to delete a file in the FTP directory with the server
For example, we can open an HTTP directory in the server by typing: cd /http. This will
change the current directory from FTP directory to HTTP directory
Once the http directory is open, you can upload a file to the HTTP server. You’re now
uploading a file to an HTTP folder(directory) using FTP.
To see this working, let’s open an HTTP directory and upload(put) a file to it using FTP:
You can now check up in the HTTP directory in the server and verify that the file uploaded
from the Laptop(MyFile.txt) is well received:
Notice that we are uploading files to an HTTP Server directory using File Transfer
Protocol.(FTP). This is what actually happens when you use an FTP client such as FileZilla
client to upload files to a website. In our case here, we are using an FTP client built-in the
Laptop.
This may interest you: The first FTP client applications were command-line programs
developed before operating systems had graphical user interfaces, and are still shipped with
most Windows and Linux operating systems. (Actually this is what we have been using this
far). Many FTP clients(e.g. FileZilla) and automation utilities have since been developed for
desktops, servers, mobile devices, and hardware. FTP has also been incorporated into
productivity applications, such as HTML editors.
We’ll create an html file in our Laptop, upload it to HTTP server directory using FTP, then
try to access the file from the Laptop’s browser.
On the Laptop, open the text editor, then type some markup(html) and save the file with the
extension .html. See all this below:
File2 html.PNG
Now upload the file( File2.html) to the HTTP server using FTP. This is easy. We’ve already
done it previously!
If you’re already in the HTTP directory, you just need to type: put File2.html. If no, first ftp
the server(ftp 192.168.1.2), provide the login username(cisco) and password(cisco); change
the current directory to HTTP(cd /http) , and finally upload the html file onto the HTTP
directory(put File2.html)
Check whether the html file uploaded has been received in the HTTP directory:
Go to Server->Services-> HTTP. Then look up for the file in the File Manager.
Now edit index.html file in the HTTP directory so as to include a link to File2 that we’ve just
uploaded. This will make File2 accessible from the Laptop’s browser. To do this, locate
index.html then click edit. Proceed to edit it as shown below. Then save and accept
overwrite.Index.html editing to include File2 html.PNG
Finally, try to access the newly uploaded file from the Laptop’s browser.
So go to the Laptop’s browser and access the server using the server’s IP address. By doing
this, the browser is making an http request to the server. The server will respond to the
Laptop with the index.html file containing a link to File2 which we’ve uploaded from the
Laptop using FTP.
Click File2 link to view the contents of the file in the browser.
CONCLUSION:
Hence we have studied performance of HTTP, HTTPS and FTP protocol using Packet tracer tool.
Experiment No 13
AIM: Installing and configure DHCP server and write a program to install the software on remote
machine.
OBJECTIVES:
• To study UDP socket programming.
• To implement Peer to Peer chat & Multiuser chat
PROBLEM STATMENT: Installing and configure DHCP server and write a program to install
the software on remote machine.
OUTCOMES:
CO4: Develop Client-Server architectures and prototypes by the means of correct standards and
technology.
Theory:
The Dynamic Host Configuration Protocol (DHCP) is a standardized network protocol used on
Internet Protocol (IP) networks for dynamically distributing network configuration parameters,
such as IP addresses for interfaces and services. With DHCP, computers request IP addresses and
networking parameters automatically from a DHCP server, reducing the need for a network
administrator or a user to configure these settings manually. RFC 2131.
The Dynamic Host Configuration Protocol (DHCP) is a network service that enables host
computers to be automatically assigned settings from a server as opposed to manually configuring
each network host. Computers configured to be DHCP clients have no control over the settings
they receive from the DHCP server, and the configuration is transparent to the computer's user.
The most common settings provided by a DHCP server to DHCP clients include:
However, a DHCP server can also supply configuration properties such as:
1. Host Name
2. Domain Name
3. Time Server
4. Print Server
The advantage of using DHCP is that changes to the network, for example a change in the address
of the DNS server, need only be changed at the DHCP server, and all network hosts will be
reconfigured the next time their DHCP clients poll the DHCP server. As an added advantage, it is
also easier to integrate new computers into the network, as there is no need to check for the
availability of an IP address. Conflicts in IP address allocation are also reduced.
A DHCP server can provide configuration settings using the following methods:
Automatic allocation
Using this method, the DHCP automatically assigns an IP address permanently to a device,
selecting it from a pool of available addresses. Usually DHCP is used to assign a temporary address
to a client, but a DHCP server can allow an infinite lease time.
The last two methods can be considered "automatic" because in each case the DHCP server assigns
an address with no extra intervention needed. The only difference between them is in how long the
IP address is leased, in other words whether a client's address varies over time. Ubuntu is shipped
with both DHCP server and client. The server is dhcpd (dynamic host configuration protocol
daemon). The client provided with Ubuntu is dhclient and should be installed on all computers
required to be automatically configured. Both programs are easy to install and configure and will
be automatically started at system boot.
Installation
At a terminal prompt, enter the following command to install dhcpd:
We need to change the default configuration by editing /etc/dhcp/dhcpd.conf to suit our needs
and particular configuration.
We also may need to edit /etc/default/isc-dhcp-server to specify the interfaces dhcpd should listen
to.
Note: dhcpd's messages are being sent to syslog. Look there for diagnostics messages.
Configuration
The error message the installation ends with might be a little confusing, but the following steps
will help you configure the service:
Most commonly, what you want to do is assign an IP address randomly. This can be done with
settings as follows:
This will result in the DHCP server giving clients an IP address from the range
192.168.1.150192.168.1.200. It will lease an IP address for 600 seconds if the client doesn't ask
for a specific time frame. Otherwise the maximum (allowed) lease will be 7200 seconds. The server
will also "advise" the client to use 192.168.1.254 as the default-gateway and 192.168.1.1 and
192.168.1.2 as its DNS servers.
Experiment No.14
AIM: To Study IPsec (ESP and AH) protocol by capturing packets using
Wireshark tool.
OBJECTIVES:
To study IPsec protocol.
PROBLEM STATMENT:
To Study IPsec (ESP and AH) protocol by capturing packets using
Wireshark tool.
OUTCOMES:
CO1:Studied IPsec protocol by wireshark tool.
Theory:
What is IPSEC?
•
Confidentiality – prevents the theft of data, using encryption.
•
Integrity – ensures that data is not tampered or altered, using a
hashing algorithm.
SIT,Lonavala 86
Computer Network & Security Lab [CNSL] Computer Engineering Department
Authentication – confirms the identity of the host sending data, using pre-
shared keys or a Certificate Authority (CA).
•
Anti-replay – prevents duplication of encrypted packets, by assigning
a unique sequencing number.
Data sent in clear-text across the Internet can easily be intercepted and
stolen. Because of this, sensitive data should be encrypted when sent across
an untrusted network or domain.
Keys are generated values used to both encrypt and decrypt data. The longer
the key, the more secure that key is. The length of a key is measured in bits.
Two “types” of keys exist:
Symmetric keys can be used to both encrypt and decrypt data. More
specifically, the same key is used to both encrypt a packet (at the sending
device) and then decrypt that packet (at the receiving device). Symmetric
key encryption is efficient, but does not scale well in large environments.
Symmetric keys are not openly shared during data transmit, and must instead
be installed on each machine prior to the transfer of data. This can be
accomplished using a variety of (inefficient and insecure) methods: email,
sneaker-net, and even snail-mail. Each device on a network would require
every other device’s symmetric key, and thus the lack of scalability.
Asymmetric keys require a separate key for encryption (the public key) and
decryption (the private key). Public keys are openly exchanged between
devices to encrypt data during transfer. Private keys are never exchanged.
SIT,Lonavala 87
Computer Network & Security Lab [CNSL] Computer Engineering Department
Only the private keys can decrypt the data. Thus, even if the data and the
public key were intercepted, confidentiality is ensured.
Confidentiality and Encryption (continued)
The generated public keys encrypt data payload using one of several
available encryption algorithms:
•
DES (Data Encryption Standard) – 56-bit key
SIT,Lonavala 88
Computer Network & Security Lab [CNSL] Computer Engineering Department
•
3DES (Triple Data Encryption Standard) – 168-bit key
•
AES (Advanced Encryption Standard) - 128, 192, or 256-bit key
•
Blowfish – up to a 448-bit key
•
Group 1 – 768 bits
• •
Group 2 – 1024 bits Group 5 – 2048 bits Data Integrity and
Hashing
Data sent across the Internet can not only be stolen, but can also be
maliciously altered.
•
HMAC-MD5 (Message-Digest 5) – 128-bit hashed key
•
HMAC-SHA1 (Secure Hash Algorithm) – 160-bit hashed key
SIT,Lonavala 89
Computer Network & Security Lab [CNSL] Computer Engineering Department
Authentication
Another concern when sending data across the Internet is the source or
origin of that data. It is possible to masquerade or spoof one’s identity or
address.
For an IPSEC VPN tunnel to be established, both sides of the tunnel must be
authenticated. To accomplish this, either pre-shared keys or RSA digital
signatures are used.
When using pre-shared keys, a secret string of text is used on each device
to authenticate each other. This string must be pre-agreed upon and identical
on each device. This string is then hashed into a digital signature.
One of the above options must be correctly configured before the VPN
tunnel will become active.
SIT,Lonavala 90
Computer Network & Security Lab [CNSL] Computer Engineering Department
AH uses a hash algorithm to compute a hash value on both the payload and
header of a packet, ensuring integrity of the packet. However, this causes a
very specific problem. AH will not work through a NATed device.
NAT changes the IP header of a packet during translation, but the hash value
is not changed. Thus, the receiving device will believe the packet has been
altered in transit, and reject the packet.
ESP also uses a hash algorithm for data integrity. However, the hash does
not include the IP header of the packet, and thus ESP will (usually) work
through a NATed device.
ESP and AH can be used separately, or used in conjunction with each other.
Each IPSEC protocol (AH or ESP) can operate in one of two modes:
•
Transport mode – Original IP headers are left intact. Used when
securing communication from one device to another single device.
•
Tunnel mode – the entire original packet is hashed and/or encrypted,
including both the payload and any original headers. A temporary IP
header is applied to the packet during transit. Used to tunnel traffic from
one site to another.
SIT,Lonavala 91
Computer Network & Security Lab [CNSL] Computer Engineering Department
Hashed
New IP Header ESP Header IP Header TCP Header Data Payload ESP Trailer
ESP in Tunnel mode experiences NAT difficulties similar to AH. This can
be alleviated by implementing NAT Traversal (NAT-T).
SIT,Lonavala 92
Computer Network & Security Lab [CNSL] Computer Engineering Department
IKE policies are often referred to as Internet Security Association and Key
Management Protocol (ISAKMP) policies. Multiple IKE policies can be
created on a VPN peer. During the negotiation process, VPN peers share
their list of configured IKE policies. The SA will only be established if there
is an exact matching policy between the peers.
SIT,Lonavala 93
Computer Network & Security Lab [CNSL] Computer Engineering Department
•
Main Mode – slower, but more secure
•
Aggressive Mode – faster, but less secure
IKE Phase 2 establishes the IPSEC tunnel (IPSEC SA), which details the
AH or ESP parameters for securing data. These parameters are contained in
an IPSEC Transform Set.
IKE Phase 1 negotiates parameters for the tunnel (key exchange) itself,
while IKE Phase 2 negotiates parameters for the data traversing that tunnel.
1. Any traffic that should be secured and sent across the tunnel is
identified as interesting traffic, usually using an access-list.
SIT,Lonavala 94