Fast Network Recovery with MRC
Fast Network Recovery with MRC
INTRODUCTION
1
HARDWARE CONFIGURATION
Hard disk : 40 GB
RAM : 512 MB
SOFTWARE SPECIFICATION
The software requirement specification is produced at the culmination of the analysis task. The function
and performance allocated to software as part of system engineering are refined by establishing a
complete information description as functional representation, a representation of system behavior, an
indication of performance requirements and design constraints, appropriate validation criteria.
User Interface
* Swing - Swing is a set of classes that provides more powerful and flexible components that are possible
with AWT. In addition to the familiar components, such as button checkboxes and labels, swing supplies
several exciting additions, including tabbed panes, scroll panes, trees and tables.
* Applet - Applet is a dynamic and interactive program that can run inside a web page displayed by a java
capable browser such as hot java or Netscape.
Software Interface
JDK 1.5
2
SOFTWARE DESCRIPTION
Java:
Java was conceived by James Gosling, Patrick Naughton, Chris Wrath, Ed Frank, and
language that extends it’s features wide over the network.Java2 version introduces an
new component called “Swing” – is a set of classes that provides more power
- It’s a light weight package, as they are not implemented by platform-specific code.
-Related classes are contained in javax.swing and its sub packages, such as javax.swing.tree.
-Components explained in the Swing have more capabilities than those of AWT
What Is Java?
Simple
Object-oriented
Distributed
Interpreted
Robust
Secure
Architecture-neutral
Portable
High-performance
Multithreaded
Dynamic
3
Java is also unusual in that each Java program is both compiled and interpreted. With a compiler,
you translate a Java program into an intermediate language called Java byte codes--the platform-
independent codes interpreted by the Java interpreter. With an interpreter, each Java byte code instruction
is parsed and run on the computer. Compilation happens just once; interpretation occurs each time the
program is executed. This figure illustrates how this works.
Java byte codes can be considered as the machine code instructions for the Java Virtual Machine
(Java VM). Every Java interpreter, whether it's a Java development tool or a Web browser that can run
Java applets, is an implementation of the Java VM. The Java VM can also be implemented in hardware.
Java byte codes help make "write once, run anywhere" possible. The Java program can be
compiled into byte codes on any platform that has a Java compiler. The byte codes can then be run on any
implementation of the Java VM. For example, the same Java program can run on Windows NT, Solaris,
and Macintosh.
A platform is the hardware or software environment in which a program runs. The Java platform
differs from most other platforms in that it's a software-only platform that runs on top of other, hardware-
based platforms. Most other platforms are described as a combination of hardware and operating system.
The Java API is a large collection of ready-made software components that provide many useful
capabilities, such as graphical user interface (GUI) widgets. The Java API is grouped into libraries
(packages) of related components.
The following figure depicts a Java program, such as an application or applet, that's running on the Java
platform. As the figure shows, the Java API and Virtual Machine insulates the Java program from
hardware dependencies.
4
As a platform-independent environment, Java can be a bit slower than native code. However,
smart compilers, well-tuned interpreters, and just-in-time byte code compilers can bring Java's
performance close to that of native code without threatening portability.
Probably the most well-known Java programs are Java applets. An applet is a Java program that
adheres to certain conventions that allow it to run within a Java-enabled browser.
However, Java is not just for writing cute, entertaining applets for the World Wide Web ("Web").
Java is a general-purpose, high-level programming language and a powerful software platform. Using the
generous Java API, we can write many types of programs.
The most common types of programs are probably applets and applications, where a Java
application is a standalone program that runs directly on the Java platform.
How does the Java API support all of these kinds of programs?
With packages of software components that provide a wide range of functionality. The core API
is the API included in every full implementation of the Java platform. The core API gives you the
following features:
The Essentials: Objects, strings, threads, numbers, input and output, data structures, system properties,
date and time, and so on.
Internationalization: Help for writing programs that can be localized for users worldwide. Programs can
automatically adapt to specific locales and be displayed in the appropriate language.
Security: Both low-level and high-level, including electronic signatures, public/private key management,
access control, and certificates.
Software components: Known as JavaBeans, can plug into existing component architectures such as
Microsoft's OLE/COM/Active-X architecture, OpenDoc, and Netscape's Live Connect.
Object serialization: Allows lightweight persistence and communication via Remote Method Invocation
(RMI).
Java Database Connectivity (JDBC): Provides uniform access to a wide range of relational databases.
5
Java not only has a core API, but also standard extensions. The standard extensions define APIs for 3D,
servers, collaboration, telephony, speech, animation, and more.
Java is likely to make your programs better and requires less effort than other languages. We
believe that Java will help you do the following:
Get started quickly: Although Java is a powerful object-oriented language, it's easy to learn, especially for
programmers already familiar with C or C++.
Write less code: Comparisons of program metrics (class counts, method counts, and so on) suggest that a
program written in Java can be four times smaller than the same program in C++.
Write better code: The Java language encourages good coding practices, and its garbage collection helps
you avoid memory leaks. Java's object orientation, its JavaBeans component architecture, and its wide-
ranging, easily extendible API let you reuse other people's tested code and introduce fewer bugs.
Develop programs faster: Your development time may be as much as twice as fast versus writing the
same program in C++. Why? You write fewer lines of code with Java and Java is a simpler programming
language than C++.
Avoid platform dependencies with 100% Pure Java: You can keep your program portable by following
the purity tips mentioned throughout this book and avoiding the use of libraries written in other
languages.
Write once, run anywhere: Because 100% Pure Java programs are compiled into machine-independent
byte codes, they run consistently on any Java platform.
Distribute software more easily: You can upgrade applets easily from a central server. Applets
take advantage of the Java feature of allowing new classes to be loaded "on the fly," without recompiling
the entire program.
We explore the java.net package, which provides support for networking. Its creators
have called Java “programming for the Internet.” These networking classes encapsulate the “socket”
paradigm pioneered in the Berkeley Software Distribution (BSD) from the University of California at
Berkeley.
Networking Basics
Ken Thompson and Dennis Ritchie developed UNIX in concert with the C language at Bell
Telephone Laboratories, Murray Hill, New Jersey, in 1969. In 1978, Bill Joy was leading a project at Cal
Berkeley to add many new features to UNIX, such as virtual memory and full-screen display capabilities.
By early 1984, just as Bill was leaving to found Sun Microsystems, he shipped 4.2BSD, commonly
known as Berkeley UNIX.4.2BSD came with a fast file system, reliable signals, interprocess
communication, and, most important, networking. The networking support first found in 4.2 eventually
became the de facto standard for the Internet. Berkeley’s implementation of TCP/IP remains the primary
standard for communications with the Internet. The socket paradigm for inter process and network
communication has also been widely adopted outside of Berkeley.
6
Socket Overview
A network socket is a lot like an electrical socket. Various plugs around the network have
a standard way of delivering their payload. Anything that understands the standard protocol can “plug in”
to the socket and communicate.
Internet protocol (IP) is a low-level routing protocol that breaks data into small packets
and sends them to an address across a network, which does not guarantee to deliver said packets to the
destination.
Client/Server
A server is anything that has some resource that can be shared. There are compute
servers, which provide computing power; print servers, which manage a collection of printers; disk
servers, which provide networked disk space; and web servers, which store web pages. A client is simply
any other entity that wants to gain access to a particular server.
In Berkeley sockets, the notion of a socket allows as single computer to serve many
different clients at once, as well as serving many different types of information. This feat is managed by
the introduction of a port, which is a numbered socket on a particular machine. A server process is said to
“listen” to a port until a client connects to it. A server is allowed to accept multiple clients connected to
the same port number, although each session is unique. To mange multiple client connections, a server
process must be multithreaded or have some other means of multiplexing the simultaneous I/O.
Reserved Sockets
Once connected, a higher-level protocol ensues, which is dependent on which port you
are using. TCP/IP reserves the lower, 1,024 ports for specific protocols. Port number 21 is for FTP, 23 is
for Telnet, 25 is for e-mail, 79 is for finger, 80 is for HTTP, 119 is for Netnews-and the list goes on. It is
up to each protocol to determine how a client should interact with the port.
Java supports TCP/IP both by extending the already established stream I/O interface. Java
supports both the TCP and UDP protocol families. TCP is used for reliable stream-based I/O across the
network. UDP supports a simpler, hence faster, point-to-point datagram-oriented model.
InetAddress
The InetAddress class is used to encapsulate both the numerical IP address and the
domain name for that address. We interact with this class by using the name of an IP host, which is more
convenient and understandable than its IP address. The InetAddress class hides the number inside. As of
Java 2, version 1.4, InetAddress can handle both IPv4 and IPv6 addresses.
Factory Methods
7
methods in a class return an instance of that class. This is done in lieu of overloading a constructor with
various parameter lists when having unique method names makes the results much clearer.
throws UnknownHostException
The getLocalHost( ) method simply returns the InetAddress object that represents the
local host. The getByName( ) method returns an InetAddress for a host name passed to it. If these
methods are unable to resolve the host name, they throw an UnknownHostException.
On the internet, it is common for a single name to be used to represent several machines. In the
world of web servers, this is one way to provide some degree of scaling. The getAllByName ( ) factory
method returns an array of InetAddresses that represent all of the addresses that a particular name
resolves to. It will also throw an UnknownHostException if it can’t resolve the name to at least one
address. Java 2, version 1.4 also includes the factory method getByAddress( ), which takes an IP address
and returns an InetAddress object. Either an IPv4 or an IPv6 address can be used.
Instance Methods
The InetAddress class also has several other methods, which can be used on the objects
returned by the methods just discussed. Here are some of the most commonly used.
Boolean equals (Object other)- Returns true if this object has the same Internet address
as other.
byte[ ] getAddress( )- Returns a byte array that represents the object’s Internet address in
network byte order.
String getHostAddress( )- Returns a string that represents the host address associated with the
InetAddress object.
String get HostName( )- Returns a string that represents the host name associated with the
InetAddress object.
, it returns false.
String to String( )- Returns a string that lists the host name and the IP address for
conveneince. boolean isMulticastAddress( )- Returns true if this Internet address is a multicast address.
Otherwise
Internet addresses are looked up in a series of hierarchically cached servers. That means that your
local computer might know a particular name-to-IP-address mapping autocratically, such as for itself and
nearby servers. For other names, it may ask a local DNS server for IP address information. If that server
doesn’t have a particular address, it can go to a remote site and ask for it. This can continue all the way up
to the root server, called Inter NIC (internic.net).
8
TCP/IP Client Sockets
TCP/IP sockets are used to implement reliable, bidirectional, persistent, point-to-point, stream-
based connections between hosts on the Internet. A socket can be used to connect Java’s I/O system to
other programs that may reside either on the local machine or on any other machine on the Internet.
There are two kinds of TCP sockets in Java. One is for servers, and the other is for clients. The
Server Socket class is designed to be a “listener,” which waits for clients to connect before doing
anything. The Socket class is designed to connect to server sockets and initiate protocol exchanges.
The creation of a Socket object implicitly establishes a connection between the client and
server. There are no methods or constructors that explicitly expose the details of establishing that
connection. Here are two constructors used to create client sockets:
Socket(String hostName, int port) Creates a socket connecting the local host to the
named host and port; can throw an UnknownHostException or anIOException.
A socket can be examined at any time for the address and port information associated
with it, by use of the following methods:
int getPort( ) Returns the remote port to which this Socket object is connected.
int getLocalPort( ) Returns the local port to which this Socket object is connected.
Once the Socket object has been created, it can also be examined to gain access to the
input and output streams associated with it. Each of these methods can throw an IOException if the
sockets have been invalidated by a loss of connection on the Net.
OutputStream getOutputStream( ) Returns the OutputStream associated with the invoking socket.
Java has a different socket class that must be used for creating server applications. The
ServerSocket class is used to create servers that listen for either local or remote client programs to
connect to them on published ports. ServerSockets are quite different form normal Sockets.
When we create a ServerSocket, it will register itself with the system as having an
interest in client connections. The constructors for ServerSocket reflect the port number that we wish to
accept connection on and, optionally, how long we want the queue for said port to be. The queue length
tells the system how many client connection it can leave pending before it should simply refuse
connections. The default is 50. The constructors might throw an IOException under adverse conditions.
Here are the constructors:
ServerSocket(int port) Creates server socket on the specified port with a queue length of 50.
9
Serversocket(int port, int maxQueue)-Creates a server socket on the specified port with a
maximum queue length of maxQueue.
ServerSocket has a method called accept( ), which is a blocking call that will wait for a client to
initiate communications, and then return with a normal Socket that is then used for communication with
the client.
URL
The Web is a loose collection of higher-level protocols and file formats, all unified in a
web browser. One of the most important aspects of the Web is that Tim Berners-Lee devised a scaleable
way to locate all of the resources of the Net. The Uniform Resource Locator (URL) is used to name
anything and everything reliably.
Format
A URL specification is based on four components. The first is the protocol to use,
separated from the rest of the locator by a colon (:). Common protocols are http, ftp, gopher, and file,
although these days almost everything is being done via HTTP. The second component is the host name
or IP address of the host to use; this is delimited on the left by double slashes (/ /) and on the right by a
slash (/) or optionally a colon (:) and on the right by a slash (/). The fourth part is the actual file path.
Most HTTP servers will append a file named index.html or index.htm to URLs that refer directly to a
directory resource.
Java’s URL class has several constructors, and each can throw a
MalformedURLException. One commonly used form specifies the URL with a string that is identical to
what is displayed in a browser:
URL(String urlSpecifier)
The next two forms of the constructor breaks up the URL into its component parts:
Another frequently used constructor uses an existing URL as a reference context and then
create a new URL from that context.
10
The following method returns a URLConnection object associated with the invoking
URL object. it may throw an IOException.
JDBC
In an effort to set an independent database standard API for Java, Sun Microsystems developed Java
Database Connectivity, or JDBC. JDBC offers a generic SQL database access mechanism that provides a
consistent interface to a variety of RDBMS. This consistent interface is achieved through the use of
“plug-in” database connectivity modules, or drivers. If a database vendor wishes to have JDBC support,
he or she must provide the driver for each platform that the database and Java run on.
To gain a wider acceptance of JDBC, Sun based JDBC’s framework on ODBC. As you discovered earlier
in this chapter, ODBC has widespread support on a variety of platforms. Basing JDBC on ODBC will
allow vendors to bring JDBC drivers to market much faster than developing a completely new
connectivity solution.
JDBC Goals
Few software packages are designed without goals in mind. JDBC is one that, because of its many goals,
drove the development of the API. These goals, in conjunction with early reviewer feedback, have
finalized the JDBC class library into a solid framework for building database applications in Java.
The goals that were set for JDBC are important. They will give you some insight as to why certain classes
and functionalities behave the way they do. The eight design goals for JDBC are as follows:
SQLevelAPI
The designers felt that their main goal was to define a SQL interface for Java. Although not the lowest
database interface level possible, it is at a low enough level for higher-level tools and APIs to be created.
Conversely, it is at a high enough level for application programmers to use it confidently. Attaining this
goal allows for future tool vendors to “generate” JDBC code and to hide many of JDBC’s complexities
from the end user.
SQLConformance
SQL syntax varies as you move from database vendor to database vendor. In an effort to support a wide
variety of vendors, JDBC will allow any query statement to be passed through it to the underlying
database driver. This allows the connectivity module to handle non-standard functionality in a manner
that is suitable for its users.
11
Provide a Java interface that is consistent with the rest of the Java system
Because of Java’s acceptance in the user community thus far, the designers feel that they should not stray
from the current design of the core Java system.
Keep it simple
This goal probably appears in all software design goal listings. JDBC is no exception. Sun felt that the
design of JDBC should be very simple, allowing for only one method of completing a task per
mechanism. Allowing duplicate functionality only serves to confuse the users of the API.
12
SYSTEM ANALYSIS
1. Existing System
The slow convergence of routing protocols after a network failure becomes a growing problem.
Time consumed to send the data is increased due to resending of lost data.
DISADVATAGES:
We present a new scheme for handling link and node failures in IP networks.
Recovery in all single failure scenarios without knowing root cause of the failure.
Each and Every Node having Preconfigured Backup Path. That Backup path maintains
the routing table.
13
ADVANTAGES:
During message transfer the load is distributed which increases the speed of transmission.
Modules
Topology Construction
Data Transmission
14
Module 2 Restrict and Isolate Link
In the Data Transmission module, the Message transfer relates with that the sender node wants
to send a message to the destination node
Sender node first selects the Destination node.
Sender types the data or browses the .txt file and uploads the url from the textbox.
Checks the corresponding node and corresponding path is available .
After the path is selected also find out that node or link is failure and status of the destination
node through is true.
If anyone of the node or link is failed means sender use the preconfigured backup path.
The receiver node receives the message completely and then it send the acknowledgement to the
sender node also near by nodes through the router nodes where it is received the message.
15
DIAGRAMS
16
System Architecture
USER
SQL
17
CLASS DIAGRAM:
USECASE DIAGRAM:
18
Database Schema
nodename nvarchar
ipaddress nvarchar
portno nvarchar
sourcenode nvarchar
destinationnode nvarchar
weights nvarchar
Destination nvarchar
path nvarchar
weights nvarchar
19
System Testing
The purpose of testing is to discover errors. Testing is the process of trying to discover every conceivable
fault or weakness in a work product. It provides a way to check the functionality of components, sub
assemblies, assemblies and/or a finished product It is the process of exercising software with the intent of
ensuring that the Software system meets its requirements and user expectations and does not fail in an
unacceptable manner. There are various types of test. Each test type addresses a specific testing
requirement.
Types of Tests
Unit testing
Unit testing involves the design of test cases that validate that the internal program logic is
functioning properly, and that program input produce valid outputs. All decision branches and internal
code flow should be validated. It is the testing of individual software units of the application .it is done
after the completion of an individual unit before integration. This is a structural testing, that relies on
knowledge of its construction and is invasive. Unit tests perform basic tests at component level and test a
specific business process, application, and/or system configuration. Unit tests ensure that each unique
path of a business process performs accurately to the documented specifications and contains clearly
defined inputs and expected results.
Functional test
Functional tests provide systematic demonstrations that functions tested are available as specified
by the business and technical requirements, system documentation, and user manuals.
20
System Test
System testing ensures that the entire integrated software system meets requirements. It tests a
configuration to ensure known and predictable results. An example of system testing is the configuration
oriented system integration test. System testing is based on process descriptions and flows, emphasizing
pre-driven process links and integration points.
Performance Test
The Performance test ensures that the output be produced within the time limits, and the time
taken by the system for compiling, giving response to the users and request being send to the system for
to retrieve the results.
Integration Testing
Software integration testing is the incremental integration testing of two or more integrated
software components on a single platform to produce failures caused by interface defects.
The task of the integration test is to check that components or software applications, e.g.
components in a software system or – one step up – software applications at the company level – interact
without error.
Check the Route status in the Cache Table after the status information is received by the Node
Acceptance Testing
User Acceptance Testing is a critical phase of any project and requires significant participation by
the end user. It also ensures that the system meets the functional requirements.
The Acknowledgements will be received by the Sender Node after the Packets are received by the
Destination Node
The Route add operation is done only when there is a Route request in need
The Status of Nodes information is done automatically in the Cache Updation process
21
IMPLEMENTATION
Implementation is the stage in the project where the theoretical design is turned into a working
system and is giving confidence on the new system for the users, which it will work efficiently and
effectively. It involves careful planning, investigation of the current System and its constraints on
implementation, design of methods to achieve the change over, an evaluation, of change over methods.
Apart from planning major task of preparing the implementation are education and training of users.
The more complex system being implemented, the more involved will be the system analysis and the
design effort required just for implementation.
Implementation is the final and important phase, the most critical stage in achieving a successful
new system and in giving the users confidence. That the new system will work is effective .The system
can be implemented only after through testing is done and if it found to working according to the
specification. This method also offers the greatest security since the old system can take over if the
errors are found or inability to handle certain type of transactions while using the new system.
22
User Training
After the system is implemented successfully, training of the user is one of the most important
subtasks of the developer. For this purpose user manuals are prepared and handled over to the user to
operate the developed system. Thus the users are trained to operate the developed systems
successfully in future .In order to put new application system into use, the following activities were
taken care of:
Test run for some period to ensure smooth switching over the system.
The users are trained to use the newly developed functions. User manuals describing the procedures for
using the functions listed on menu and circulated to all the users .it is confirmed that the system is
implemented up to user need and expectations.
Security
The Administrator checks the path information and status information before the data transfer
Messages that are sent will receive the acknowledgements automatically if there is no link failure after
the message received by the Receiver Node
Failure of link’s will automatically make updation in the Cache table to other nodes in the Network
First, to reduce duplicate notifications to a node, we attach a reference list to each notification. The node
detecting a link failure is the root, initializing the list to be its notification list. Each child notifies only the
nodes not in the list and updates the list
By adding the nodes in its notification list. The graph will be close to a tree.
Second, we piggyback a notification on the data packet that encounters a broken link if that packet can
be salvaged. When using the algorithm, we also use a small list of broken links, which is similar to the
negative cache proposed in prior work, to prevent a node from being re-polluted by in-flight stale
routes.
23
Appendix B: Sample Source Code
AddNode.java:
/****************************************************************/
/* AddNode */
/* */
/****************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
/**
24
* Summary description for AddNode
*/
// Variables declaration
Statement st;
Connection con;
public AddNode()
25
initializeComponent();
//
//
this.setVisible(true);
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:MRC","sa","");
st=con.createStatement();
ex.printStackTrace();
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always regenerated
* by the Windows Form Designer. Otherwise, retrieving design might not work properly.
26
* Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
*/
contentPane = (JPanel)this.getContentPane();
//
// jLabel2
//
jLabel2.setText("Node Name");
//
// jLabel3
//
jLabel3.setText("TOPOLOGY CONSTRUCTION");
27
//
// jLabel4
//
jLabel4.setText("IP Address");
//
// jLabel5
//
jLabel5.setText("Port No");
jLabel6.setText("jLabel6");
//
// jTextField1
//
jTextField1.addActionListener(new ActionListener() {
jTextField1_actionPerformed(e);
});
//
// jTextField2
//
28
jTextField2.addActionListener(new ActionListener() {
jTextField2_actionPerformed(e);
});
//
// jTextField3
//
jTextField3.addActionListener(new ActionListener() {
jTextField3_actionPerformed(e);
});
//
// ADD
//
ADD.setText("ADD");
ADD.addActionListener(new ActionListener() {
ADD_actionPerformed(e);
29
}
});
FINISH.setText("FINISH");
FINISH.addActionListener(new ActionListener() {
FINISH_actionPerformed(e);
});
//
// contentPane
//
contentPane.setLayout(null);
30
//
// AddNode
//
c.setBounds(x,y,width,height);
container.add(c);
//
// TODO: Add any appropriate code in the following Event Handling Methods
//
System.out.println("\njTextField1_actionPerformed(ActionEvent e) called.");
31
private void jTextField2_actionPerformed(ActionEvent e)
System.out.println("\njTextField2_actionPerformed(ActionEvent e) called.");
System.out.println("\njTextField3_actionPerformed(ActionEvent e) called.");
try
System.out.println("\nADD_actionPerformed(ActionEvent e) called.");
String s1=jTextField1.getText();
String s2=jTextField2.getText();
String s3=jTextField3.getText();
32
String sql="insert into newnodedetails values('"+s1+"','"+s2+"','"+s3+"')";
st.executeUpdate(sql);
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
catch(Exception e1)
e1.printStackTrace ();
33
System.out.println("finish button clicked");
this.setVisible(false);
//
// TODO: Add any method code to meet your needs in the following area
//
NODEA.java
/****************************************************************/
/* NODEA */
/* */
/****************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
34
import java.net.*;
import java.util.*;
import java.sql.*;
import javax.swing.table.*;
/**
*/
// Variables declaration
//-----
35
private JTextField txt_path;//BROWSE FILE PATH
Pathtable pathtab;
Object header[]={"SOURCENODE","DESTINATIONNODE","BACKUPPATH"};
//-----
36
String findedpath1="";
String str="";
String nodename="A";
int portt;
String ipaddress="";
String fname="";
String sender="";
String nexthost="";
//-----
public NODEA()
super();
initializeComponent();
//
//
37
this.setVisible(true);
start();
getrelatednodes();
bckuppath();
try
out.writeUTF("getnodeport");
out.writeUTF(nodename);
//out.writeUTF(ipaddress);
String receive=in.readUTF();
String receive2=in.readUTF();
38
start();
portt=Integer.parseInt(receive);
serverlisten();
System.out.println("jwgd:"+ex);
ex.printStackTrace();
combo.removeAllItems();
39
try
outt.writeUTF("getaallnodes");
outt.writeUTF("");
System.out.println("gfghdfjkhsdfjk");
String ar=inn.readUTF();
System.out.println("is1 :"+ar);
String ar1=inn.readUTF();
System.out.println("2nd:"+ar1);
String[] arr=ar.split("@");
40
for (int i=0;i<arr.length ; i++)
combo.addItem(arr[i]);
System.out.println(ex);
ex.printStackTrace();
try
while (true)
41
Socket s=node.accept();
String p1=din.readUTF();
String p=din.readUTF();
if(p1.equals("message"))
String[] ss=p.split("&");
int lent=ss[1].length();
if (lent == 1)
jTextArea3.setText(ss[0]);
din1.writeUTF("ACK");
else
findedpath1=ss[1];
42
str=ss[0];
sendPackets();
System.out.println(ex);
ex.printStackTrace();
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always regenerated
43
* by the Windows Form Designer. Otherwise, retrieving design might not work properly.
* Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
*/
contentPane = (JPanel)this.getContentPane();
//-----
txt_path=new JTextField();
44
LINKFAILURE=new JButton("ISOLATE");
//-----
//-----
//
// jTabbedPane1
//
jTabbedPane1.addTab("NODE", NODE);
jTabbedPane1.addTab("ROUTER", ROUTER);
jTabbedPane1.addChangeListener(new ChangeListener() {
jTabbedPane1_stateChanged(e);
});
//
// contentPane
//
45
contentPane.setLayout(null);
//
// jLabel2
//
jLabel2.setText("DESTINATION NODE");
//
// jLabel3
//
jLabel3.setText("SELECT FILE");
//
// jTextField1
//
jScrollPane2.setViewportView(jTextArea2);
jTextField1.addActionListener(new ActionListener() {
jTextField1_actionPerformed(e);
});
//
// jTextField2
//
46
//
// jList1
//
jList1.addListSelectionListener(new ListSelectionListener() {
jList1_valueChanged(e);
});
//
// jScrollPane1
//
jScrollPane1.setViewportView(jList1);
jScrollPane3.setViewportView(jTextArea3);
//
// jButton1
//
jButton1.setText("SEND");
jButton1.addActionListener(new ActionListener() {
jButton1_actionPerformed(e);
47
});
//
// jButton2
//
jButton2.setText("BROWSE");
jButton2.addActionListener(new ActionListener() {
jButton2_actionPerformed(e);
});
//
// jButton3
//
//jButton3.setText("");
jButton3.addActionListener(new ActionListener() {
jButton3_actionPerformed(e);
});
48
//
// jButton4
//
// jButton4.setText();
jButton4.addActionListener(new ActionListener() {
jButton4_actionPerformed(e);
});
LINKFAILURE.addActionListener(new ActionListener() {
LINKFAILURE_actionPerformed(e);
});
con1.add(jsp);
tab=new JTable();
49
pathtab=new Pathtable();
pathtab.setColumnIdentifiers(header);
tab.setModel(pathtab);
jsp=new JScrollPane(tab);
//
// NODE
//
NODE.setLayout(null);
addComponent(NODE,jLabel2, 10,30,130,25);
addComponent(NODE,combo, 160,30,90,25);
addComponent(NODE,jLabel3, 10,80,100,25);
addComponent(NODE,txt_path, 90,80,160,25);
addComponent(NODE,lab1_list,359,20,80,20);
addComponent(NODE,lab_list,355,40,80,25);
addComponent(NODE,jScrollPane1,350,65,90,80);
addComponent(NODE,jButton4,350,165,90,25);
addComponent(NODE,LINKFAILURE,350,190,90,25);
50
addComponent(NODE,jButton2,255,80,80,25);
addComponent(NODE,messge_label, 20,130,100,25);
addComponent(NODE,jScrollPane2, 20,160,110,95);
addComponent(NODE,jButton1, 20,270,100,25);
addComponent(NODE,receive_label, 140,130,100,25);
addComponent(NODE,jScrollPane3, 140,160,110,95);
addComponent(NODE,jButton3, 140,270,100,25);
addComponent(ROUTER,jsp, 10,30,130,25);
//
// NODEA
//
this.setSize(new Dimension(550,452));
setDefaultCloseOperation(EXIT_ON_CLOSE);
51
c.setBounds(x,y,width,height);
container.add(c);
//
// TODO: Add any appropriate code in the following Event Handling Methods
//
System.out.println("\njTabbedPane1_stateChanged(ChangeEvent e) called.");
System.out.println("\njTextField1_actionPerformed(ActionEvent e) called.");
System.out.println("\njList1_valueChanged(ListSelectionEvent e) called.");
52
if(!e.getValueIsAdjusting())
Object o = jList1.getSelectedValue();
// TODO: Add any handling code here for the particular object being selected
String dest=(String)combo.getSelectedItem();
str=jTextArea2.getText();
System.out.println("Dest"+dest);
try
dos.writeUTF("getnodeport1");
dos.writeUTF(nodename+"#"+dest);
findedpath1=dis.readUTF();
System.out.println("hghghj:"+findedpath1);
53
sendPackets();
//SendPackets(str,path);
ex.printStackTrace();
try
String validpath1="";
bp1.writeUTF("getbackuppath");
54
bp1.writeUTF(nodename);
System.out.println("backup path");
validpath1=op.readUTF();
validpath.addElement(validpath1);
for(int i=0;i<validpath.size();i++)
String data=String.valueOf(validpath.elementAt(i));
int intlen=data.length();
String strDes=data.substring(intlen-1,intlen);
Vbck.addElement(nodename);
Vbck.addElement(strDes);
Vbck.addElement(data);
if(data.contains("&"))
adddata(Vbck);
Vbck=new Vector();
55
}
String DESTvalidpath1="";
//bp1.writeUTF("getbackuppath");
//bp1.writeUTF(nodename);
//System.out.println("backup path");
DESTvalidpath1=opdest.readUTF();
validpathdest.addElement(DESTvalidpath1);
56
for(int i=0;i<validpathdest.size();i++)//dest to back up path to store jtable
String data=String.valueOf(validpath.elementAt(i));
int intlen=data.length();
String strDes=data.substring(intlen-1,intlen);
Vbck.addElement(strDes);
Vbck.addElement(nodename);
Vbck.addElement(data);
if(data.contains("&"))
adddata(Vbck);
Vbck=new Vector();
57
//valid.add(validpath);
// System.out.println("back"+validpath);
//
// Iterator e2=validpath.iterator();
//
// String strValues="",strBPath="";
//
// while (e2.hasNext())
// {
// strValues+=e2.next().toString()+"&";
// }
// System.out.println("Records "+strValues);
//
// String [] bckpath=strValues.split("&");
// for(int i=0;i<bckpath.length;i++)
// {
// strBPath=bckpath[i];
//
// }
58
}
catch (Exception x)
x.printStackTrace();
try
59
DataOutputStream dal=new DataOutputStream(s2s.getOutputStream());
dal.writeUTF("getalllinks");
dal.writeUTF(nodename);
String allpaths=di.readUTF();
//allpaths=jList1.setText();
//list_view.setListData(vector_list);
//jList1.setListData(allpaths);
System.out.println("helllllllllllllloooooooo:"+allpaths);
String[] arr_ap=allpaths.split("&");
Vector inn=in(arr_ap[0]);
Vector outt=out(arr_ap[1]);
Enumeration e1=inn.elements();
while (e1.hasMoreElements())
60
vv.addElement(e1.nextElement());
Enumeration e2=outt.elements();
while (e2.hasMoreElements())
vv.addElement(e2.nextElement());
//jList1.setListData(inn);
jList1.setListData(vv);
ex.printStackTrace();
61
{
System.out.println("in in loop");
String[] aa1=inarr.split("-");
v1.addElement(nodename+">"+aa1[i]);
return v1;
String[] aa1=outarr.split("-");
v2.addElement(aa1[i]+">"+nodename);
return v2;
try
System.out.println("----fpppp----------------:"+findedpath1);
62
String[] pathh=findedpath1.split(">");
dos1.writeUTF("getnodeport");
dos1.writeUTF(pathh[1]);//lhost
System.out.println("hghghj;;;;;;;;;:");
int portno=Integer.parseInt(diis.readUTF());
ipaddress=diis.readUTF();
int len=findedpath1.length();
findedpath1=findedpath1.substring(2,len);
dout.writeUTF("message");
dout.writeUTF(str+"&"+findedpath1);
63
// String ack1=diis.readUTF();
// System.out.println("this is ack"+ack1);
ex.printStackTrace();
System.out.println("\nBROWSE_actionPerformed(ActionEvent e) called.");
File file;
int val=fc.showOpenDialog(this);
try
if(val==JFileChooser.APPROVE_OPTION)
64
{
file=fc.getSelectedFile();
String path=file.getAbsolutePath();
System.out.println(path);
fis.read(by1);
jTextArea2.setText(st1);
txt_path.setText(path);
//jTextArea1.setText(path);
ex.printStackTrace();
65
System.out.println("\njButton2_actionPerformed(ActionEvent e) called.");
jTextArea3.setText("");
try
String listval="";
System.out.println("\njButton2_actionPerformed(ActionEvent e) called.");
//Object [ ] selected=jList1.getSelectedValues();
System.out.println("This is jList1:"+p_name);
dos1.writeUTF("restrictlink");
dos1.writeUTF(p_name);//lhost
String dmsg1=diis.readUTF();
66
JOptionPane.showMessageDialog(this,dmsg1);
ex.printStackTrace();
try
System.out.println("This is jList1:"+lf_name);
dos1.writeUTF("LinkFailure");
dos1.writeUTF(lf_name);//lhost
String dmsg=diis.readUTF();
67
JOptionPane.showMessageDialog(this,dmsg);
Object o=jList1.getSelectedValue();
// v.add(o);
vv.remove(o);
jList1.setListData(vv);
//int index=Integer.parseInt(lf_name);
//jList1.remove(index);
//jList1.clearSelection();
lf1.printStackTrace();
68
public void adddata(Vector vbpath)
pathtab.addRow(vbpath);
Pathtable()
//
// TODO: Add any method code to meet your needs in the following area
//
69
70
//============================= Testing ================================//
//= =//
//= The following main method is just for testing this class you built.=//
//======================================================================//
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
System.out.println(ex);
ex.printStackTrace();
new NODEA();
71
}
72
//============================= Testing ================================//
//= =//
//= The following main method is just for testing this class you built.=//
//======================================================================//
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
73
System.out.println("Failed loading L&F: ");
System.out.println(ex);
new AddNode();
HOME.java
/****************************************************************/
/* hOME */
/* */
/****************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*/
74
public class Home extends JFrame
// Variables declaration
public Home()
super();
initializeComponent();
//
//
this.setVisible(true);
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always regenerated
* by the Windows Form Designer. Otherwise, retrieving design might not work properly.
* Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
75
* to retrieve your design properly in future, before revising this method.
*/
contentPane = (JPanel)this.getContentPane();
//
// jLabel1
//
jLabel1.setIcon(new ImageIcon("images\\networking2.jpg"));
jLabel1.setText("jLabel1");
//
// jButton1
//
jButton1.setIcon(new ImageIcon("images\\s3.jpg"));
jButton1.setText("jButton1");
jButton1.addActionListener(new ActionListener() {
jButton1_actionPerformed(e);
});
76
//
// contentPane
//
contentPane.setLayout(null);
//
// hOME
//
c.setBounds(x,y,width,height);
container.add(c);
//
// TODO: Add any appropriate code in the following Event Handling Methods
//
77
{
System.out.println("\njButton1_actionPerformed(ActionEvent e) called.");
this.setVisible(false);
//
// TODO: Add any method code to meet your needs in the following area
//
78
//============================= Testing ================================//
//= =//
//= The following main method is just for testing this class you built.=//
//======================================================================//
79
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
System.out.println(ex);
new Home();
path.java
80
import java.sql.*;
import java.util.*;
Connection conn;
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
81
conn = DriverManager.getConnection("jdbc:odbc:MRC");
st = conn.createStatement();
st.execute("delete findedpath");
// st=DB.connect();
//System.out.println(start);
//System.out.println(strDst);
//st.execute("delete possibledelay");
strDest = strDst;
strStart = start;
flip = true;
flip1 = true;
flip2 = false;
index = -1;
weight = 0;
getPath( start );
catch( Exception e )
e.printStackTrace( );
82
}
try
while( rs.next( ) )
flip2 = true;
stack[i] = stack[i+1];
index--;
flip = true;
83
}
//System.out.println("entered2");
//System.out.println("entered3");
flip1 = false;
flip1 = true;
84
{
flip2 = false;
findNode( stack[i] );
else
index--;
flip2 = true;
findNode( stack[0] );
strStart = nodePath;
85
//System.out.println("bhghg");
if(nodePath.substring(end + 1).equals(strDest))
findWeight( nodePath );
if( index != 0 )
stack[i] = stack[i+1];
index--;
flip = true;
strStart = stack[0];
findNode( stack[0] );
else
flip = false;
getPath( nodePath.substring(end + 1) );
86
public void findWeight( String nodePath )
try
if( rs.next())
weight += rs.getInt(3);
System.out.println("Path-->"+nodePath);
System.out.println("Weight-->"+weight);
System.out.println("Find path"+pathweight);
if(rs.next())
87
{
else
System.out.println( "weight"+weight );
//cost = 0;
weight = 0;
System.out.println("Find path");
vPathWeigth.add(pathweight);
catch( Exception e )
e.printStackTrace( );
88
pathcon.java
/****************************************************************/
/* pathcon */
/* */
/****************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
/**
*/
// Variables declaration
89
private JButton CREATE;
Connection con;
Statement st;
public pathcon()
super();
initializeComponent();
//
//
this.setVisible(true);
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
90
con=DriverManager.getConnection("jdbc:odbc:MRC","sa","");
st=con.createStatement();
System.out.println(e1);
e1.printStackTrace();
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always regenerated
* by the Windows Form Designer. Otherwise, retrieving design might not work properly.
* Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
*/
91
jLabel3 = new JLabel();
contentPane = (JPanel)this.getContentPane();
//
// jLabel2
//
//
// jLabel3
//
//
// jLabel4
//
jLabel4.setText(" WEIGHTS");
92
//
// jLabel6
//
jLabel6.setText("jLabel6");
//
// jTextField1
//
//jTextField1.addActionListener(new ActionListener() {
//{
// jTextField1_actionPerformed(e);
//}
//});
//
// jTextField2
//
//jTextField2.addActionListener(new ActionListener() {
//{
// jTextField2_actionPerformed(e);
//}
//});
93
//
// jTextField3
//
jTextField3.addActionListener(new ActionListener() {
jTextField3_actionPerformed(e);
});
jComboBox1.addActionListener(new ActionListener() {
jComboBox1_actionPerformed(e);
});
jComboBox2.addActionListener(new ActionListener() {
jComboBox2_actionPerformed(e);
94
}
});
//
// CREATE
//
CREATE.setText("CREATE");
CREATE.addActionListener(new ActionListener() {
CREATE_actionPerformed(e);
});
FINISH.setText("FINISH");
95
FINISH.addActionListener(new ActionListener() {
FINISH_actionPerformed(e);
});
//
// contentPane
//
contentPane.setLayout(null);
96
addComponent(contentPane, jLabel6, -314,1,701,275);
//
// pathcon
//
addcombo();
c.setBounds(x,y,width,height);
container.add(c);
//
// TODO: Add any appropriate code in the following Event Handling Methods
//
97
System.out.println("\njTextField3_actionPerformed(ActionEvent e) called.");
System.out.println("\njComboBox1_actionPerformed(ActionEvent e) called.");
Object o = jComboBox1.getSelectedItem();
// TODO: Add any handling code here for the particular object being selected
System.out.println("\njComboBox1_actionPerformed(ActionEvent e) called.");
Object o = jComboBox2.getSelectedItem();
// TODO: Add any handling code here for the particular object being selected
98
public void addcombo()
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:MRC","sa","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery(sql12);
while(rs.next())
String addnode=rs.getString(1);
jComboBox1.addItem(addnode);
jComboBox2.addItem(addnode);
addnode="";
catch (Exception e)
System.out.println(e);
99
private void CREATE_actionPerformed(ActionEvent e)
try
System.out.println("\nADD_actionPerformed(ActionEvent e) called.");
String s11=(String)jComboBox1.getSelectedItem();
String s22=(String)jComboBox2.getSelectedItem();
String s33=jTextField3.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:MRC","sa","");
Statement st=con.createStatement();
st.executeUpdate(sql);
//jComboBox1.setText("");
//jComboBox2.setText("");
100
jTextField3.setText("");
catch(Exception e1)
e1.printStackTrace();
this.setVisible(false);
//
// TODO: Add any method code to meet your needs in the following area
//
101
102
//============================= Testing ================================//
//= =//
//= The following main method is just for testing this class you built.=//
//======================================================================//
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
System.out.println(ex);
new pathcon();
103
}
104
DIAGRAMS
105
System Architecture
USER
SQL
106
CLASS DIAGRAM:
USECASE DIAGRAM:
107
Database Schema
nodename nvarchar
ipaddress nvarchar
portno nvarchar
sourcenode nvarchar
108
destinationnode nvarchar
weights nvarchar
Destination nvarchar
path nvarchar
weights nvarchar
Appendixes
109
110
111
112
113
114
115
116
117
118
119
CONCLUSION
We have presented Multiple Routing Configurations as an approach to achieve fast
recovery in IP networks. MRC is based on providing the routers with additional routing configurations,
allowing them to forward packets along routes that avoid a failed component. MRC guarantees recovery
from any single node or link failure in an arbitrary bi-connected network. By calculating backup
configurations in advance, and operating based on locally available information only, MRC can act
promptly after failure discovery. MRC operates without knowing the root cause of failure, i.e., whether
the forwarding disruption is caused by a node or link failure. This is achieved by using careful link weight
assignment according to the rules we have described. The link weight assignment rules also provide
basis for the specification of a forwarding procedure that successfully solves the last hop problem.The
performance of the algorithm and the forwarding mechanism has been evaluated using simulations. We
have shown that MRC scales well: 3 or 4 backup configurations is typically enough to isolate all links and
nodes in our test topologies. MRC backup path lengths are comparable to the optimal backup path
lengths—MRC backup paths are typically zero to two hops longer.We have evaluated the effect MRC has
on the load distribution in the network while traffic is routed in the backup configurations, and we have
proposed a method that minimizes the risk of congestion after a link failure if we have an estimate of
the demand matrix. In the COST239 network, this approach gave a maximum link load after the worst
case link failure that was even lower than after a full IGP re-convergence on the altered topology. MRC
thus achieves fast recovery with a very limited performance penalty.
120
REFERENCES:
[1] D. D. Clark, “The design philosophy of theDARPAinternet protocols,”ACM IGCOMM Comput.
Commun. Rev., vol. 18, no. 4, pp. 106–114,
Aug. 1988.
System Support for Digital Audio and Video, 2002, pp. 63–71.
Comput. Commun. Rev., vol. 35, no. 2, pp. 35–44, Jul. 2005.
121
Web Sites:
Java2s.com
Javaranch.com
Books Referred:
Core Java2, Pearson Education-2007, Cay S. Horstmann and Gary Cornell
122