Documente Academic
Documente Profesional
Documente Cultură
For
Distance Nodes
CONTENTS
1. INTRODUCTION
2. ORGANIZATION PROFILE
3. SYSTEM ANALYSIS
3.1 Existing System
3.2 Limitations
3.3 Proposed System
4. PROBLEM FORMULATION
4.1 Hardware Specification
4.2 Software Specification
4.3 Software Descriptions
5. SYSTEM DESIGN
5.1 Data Flow Diagram
6. SYSTEM TESTING
6.1 Unit Testing
6.2 Integration Testing
6.3 Acceptance Testing
7. SYSTEM IMPLMENTATION
8. CONCLUSION
9. BIBLIOGRAPHY
10. APPENDICES
APPENDIX A: SAMPLE SCREENS
APPENDIX B: SAMPLE CODE
1. INTRODUCTION
An location based routing is a collection of mobile nodes that are dynamically
and arbitrarily located in such a manner that the interconnections between nodes are
capable of changing on a continual basis. The primary goal of this routing is correct
and efficient route establishment between a pair of nodes so that messages may be
delivered in a timely manner. LAR is an on-demand protocol who is based on the
DSR(Dynamic Source Routing). The Location Aided Routing protocol uses location
information to reduce routing overhead of the ad-hoc network! Normally the LAR
protocol uses the GPS(Gloal Positioning System) to get these location informations.
With the availability of GPS, the mobile hosts knows there physical location.
Unlike traditional distance networks, networks do not rely on any fixed
infrastructure. Instead, hosts rely on each other to keep the network connected. The
military tactical and other security-sensitive operations are still the main applications
of ad hoc networks, although there is a trend to adopt ad hoc networks for commercial
uses due to their unique properties. One main challenge in design of these networks is
their vulnerability to security attacks. In this paper, we study the threats an ad hoc
network faces and the security goals to be achieved. We identify the new challenges
and opportunities posed by this new networking environment and explore new
approaches to secure its communication. In particular, we take advantage of the
inherent redundancy in ad hoc networks multiple routes between nodes to
defend routing against denial of service attacks. We also use replication and new
cryptographic schemes, such as threshold cryptography, to build a highly secure and
highly available key management service, which forms the core of our security
framework.
The networks are a new paradigm of wireless communication for mobile hosts (which
we call nodes). In this routing, there is no fixed infrastructure such as base stations or
mobile switching centers. Mobile nodes that are within each others radio range
communicate directly via wireless links, while those that are far apart rely on other
nodes to relay messages as routers. Node mobility in an ad hoc network causes
frequent changes of the network topology. Figure 1 shows such an example: initially,
nodes A and D have a direct link between them. When D moves out of As radio
range, the link is broken. However, the network is still connected, because A can
reach D through C, E, and F. Military tactical operations are still the main application
of ad hoc networks today. For example, military units (e.g., soldiers, tanks, or planes),
equipped with wireless communication devices, could form an ad hoc network when
they roam in a battlefield. The networks can also be used for emergency, law
enforcement, and rescue missions. Since an ad hoc network can be deployed rapidly
with relatively low cost, it becomes an attractive option for commercial uses such as
sensor networks or virtual classrooms.
2. ORGANIZATION PROFILE
COMPANY PROFILE.
At Blue Chip Technologies, We go beyond providing software solutions. We
work with our clients technologies and business changes that shape their
competitive advantages.
Founded in 2000, Blue Chip Technologies (P) Ltd. is a software and service
provider that helps organizations deploy, manage, and support their businesscritical software more effectively. Utilizing a combination of proprietary
software, services and specialized expertise, Blue Chip Technologies (P) Ltd.
helps mid-to-large enterprises, software companies and IT service providers
improve consistency, speed, and transparency with service delivery at lower
costs. Blue Chip Technologies (P) Ltd. helps companies avoid many of the
delays, costs and risks associated with the distribution and support of software
on desktops, servers and remote devices. Our automated solutions include
rapid, touch-free deployments, ongoing software upgrades, fixes and security
patches,
technology
asset
inventory
and
tracking,
software
license
Clientele.
Aray InfoTech
Inquirre consultancy (U.S.A)
K square consultancy pvt Ltd (U.S.A)
Opal solutions
Texlab Solutions
Vertex Business Machines
JM InfoTech
3. SYSTEM ANALYSIS
6
D
BASE STATION
E (OUT OF RANGE)
Here the base stations range is illustrated by the oval. The two nodes S and D which want to
communicate are in the range of the base station. S send the message to the base station which
in turn forwards it to destination node D. Thus communication is carried out with help of a
base station. All messages have to pass through the base station. Node E is out of the range of
the base station this prevents it from communicating to other nodes in the network. When
node E wants to communicate to any node in the network it has to contact the base station.
Since it is out of range communication is not possible.
What happens if the base station is unavailable? Or what happens if we are in a situation
where such an infrastructure does not exist at the first place?
The answer is that we simply do not communicate! This is where the second approach is
useful. JNote however that this form of centralized administration is very popular among
wide cellular networks such as GSM etc.
3.2 Limitations
The following are the limitations of the existing system.
Locating the appropriate server and client profile and updating it whenever required
becomes cumbersome.
Location Based Routing introduces a completely new flavor of network formation. The
routers and hosts are free to move randomly and organize themselves in an arbitrary fashion,
thus the network topology changes rapidly and unpredictably. Absence of a supporting
structure in mobile ad-hoc networks, to a certain extent, invalidates almost all of the existing
techniques developed for routine network controls in the existing wireless networks.
A MANET consists of mobile platforms (e.g., a router with multiple hosts and wireless
communications devices)--herein simply referred to as "nodes"--which are free to move about
arbitrarily. The nodes may be located in or on airplanes, ships, trucks, cars, perhaps even on
people or very small devices, and there may be multiple hosts per router. A MANET is an
autonomous system of mobile nodes. The system may operate in isolation, or may have
gateways to and interface with a fixed network.
communicate to D, first sends the message to E which inturn forwards it to D. Thus the node
E acts as a router and a node.
10
4. System Requirements
Ram
: 128Mb.
Hard Disk
: 10 Gb.
Compact Disk
: 650 Mb.
Input device
Output device
11
Architecture-neutral
Object-oriented
Portable
Distributed
High-performance
Interpreted
multithreaded
Robust
Dynamic
Secure
Java is also unusual in that each Java program is both compiled and
interpreted. With a compile you translate a Java program into an
intermediate language called Java bytecodes the platform-independent
code instruction is passed and run on the computer.
Compilation happens just once; interpretation occurs each time the
program is executed. The figure illustrates how this works.
Interpreter
Java
Program
Compilers
My Program
You can think of Java byte codes as the machine code instructions for
the Java Virtual Machine (Java VM). Every Java interpreter, whether its 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.
12
Java byte codes help make write once, run anywhere possible. You
can compile your Java program into byte codes on my platform that has a
Java compiler. The byte codes can then be run any implementation of the
Java VM. For example, the same Java program can run Windows NT,
Solaris, and Macintosh.
JAVA PLATFORM
A platform is the hardware of software environment in which
a program runs. The Java platform differs from most other platforms in that
its a software only platform that runs on the top of other, hardware-based
platform. Most other platforms are described as a combination of hardware
and operating system.
The Java platform has two components:
The Java Virtual Machine (Java VM)
The Java Application Programming Interface (Java API)
Youve already been introduced to the Java VM. Its the base
for the Java platform and is ported onto various hardware-based platforms.
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 (package) of related
components. The next sections, what can Java do? Highlights each area
of functionally provided by the package in the Java API.
The following figure depicts a Java program, such as an
application or applet, thats running on the Java platform. A special kind of
application known
13
Java API
Java Program
Hard Ware
14
Networking
Introduction
Description
This article presents a new socket class which supports both TCP
and UDP communication. But it provides some advantages compared to
other classes that you may find here or on some other Socket
Programming articles. First of all, this class doesn't have any limitation
like the need to provide a window handle to be used. This limitation is
bad if all you want is a simple console application. So this library doesn't
have such a limitation. It also provides threading support automatically
for you, which handles the socket connection and disconnection to a
peer. It also features some options not yet found in any socket classes
that I have seen so far. It supports both client and server sockets. A
server socket can be referred as to a socket that can accept many
connections. And a client socket is a socket that is connected to server
socket. You may still use this class to communicate between two
applications without establishing a connection. In the latter case, you
will want to create two UDP server sockets (one for each application).
This class also helps reduce coding need to create chat-like applications
and IPC (Inter-Process Communication) between two or more
applications (processes). Reliable communication between two peers is
also supported with TCP/IP with error handling. You may want to use
the smart addressing operation to control the destination of the data
being transmitted (UDP only). TCP operation of this class deals only
with communication between two peers.
15
TCP/IP stack
The TCP/IP stack is shorter than the OSI one:
IP datagrams
The IP layer provides a connectionless and unreliable delivery system. It
considers each datagram independently of the others. Any association
between datagram must be supplied by the higher layers. The IP layer
supplies a checksum that includes its own header. The header includes the
source and destination addresses. The IP layer handles routing through an
Internet. It is also responsible for breaking up large datagram into smaller
ones for transmission and reassembling them at the other end.
UDP
UDP is also connectionless and unreliable. What it adds to IP is a
checksum for the contents of the datagram and port numbers. These are used
to give a client/server model - see later.
16
TCP
TCP supplies logic to give a reliable connection-oriented protocol above
IP. It provides a virtual circuit that two processes can use to communicate.
Internet addresses
In order to use a service, you must be able to find it. The Internet uses an
address scheme for machines so that they can be located. The address is a 32
bit integer which gives the IP address. This encodes a network ID and more
addressing. The network ID falls into various classes according to the size of
the network address.
Network address
Class A uses 8 bits for the network address with 24 bits left over for
other addressing. Class B uses 16 bit network addressing. Class C uses 24 bit
network addressing and class D uses all 32.
Subnet address
Internally, the UNIX network is divided into sub networks. Building 11
is currently on one sub network and uses 10-bit addressing, allowing 1024
different hosts.
Host address
8 bits are finally used for host addresses within our subnet. This places a
limit of 256 machines that can be on the subnet.
Total address
Port addresses
A service exists on a host, and is identified by its port. This is a 16 bit
number. To send a message to a server, you send it to the port for that service
17
of the host that it is running on. This is not location transparency! Certain of
these ports are "well known".
Sockets
A socket is a data structure maintained by the system to handle network
connections. A socket is created using the call socket. It returns an integer
that is like a file descriptor. In fact, under Windows, this handle can be used
with ReadFile and WriteFile functions.
#include <sys/types.h>
#include <sys/socket.h>
int socket(int family, int type, int protocol);
18
SOCKET_ERROR, and
WSAGetLastError.
closes a socket
19
HOSTENT:
This struct is used to tell the socket to which computer and port to
connect to. These struct can appear as LPHOSTENT, but it actually means that
they are pointer to HOSTENT.
20
21
5. SYSTEM DESIGN
5.1 DATA FLOW DIAGRAM
The data flow diagrams are very helpful in determining the flow of data in an
application.
User
Route Discover
Encryp
t
Check
node
Core Node
Recore
Decryp
t
Transmission
22
IS MY.IPADDR
>
COREIPADDR
23
HAS
DISCOVERY
TIMER
EXPIRED
RECEIVED
JOIN_ACK
MESSAGE
INCREMENT HOPCOUNT
24
25
6. 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.
Integration testing
Integration tests are designed to test integrated software components to determine if
they actually run as one program. Testing is event driven and is more concerned with the
basic outcome of screens or fields. Integration tests demonstrate that although the components
were individually satisfaction, as shown by successfully unit testing, the combination of
components is correct and consistent. Integration testing is specifically aimed at exposing
the problems that arise from the combination of components.
Functional test
26
Functional tests provide a systematic demonstrations that functions tested are available
as specified by the business and technical requirements, system documentation , and user
manuals.
Functional testing is centered on the following items:
Valid Input
Invalid Input
Functions
Output
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.
27
Features to be tested
28
Testing the links that call the Change Username & password, Migration and
Synchronization screens etc.
The username should be retained throughout the application in the form of hidden
variables or by using cookies.
If the login user does not have enough privileges to invoke a screen, the link should
be disabled.
Any modification in the Master server should be reflected in the Slave server.
The XML file should retrieve only the records, which have been modified.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
Users should have the ability to modify the privilege for a screen.
Once the Synchronization starts, the Master server or Slave Server should not be
stopped without notifying the other.
29
The XML file should be generated in short time, i.e., before the next modification
occurs.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
30
7. 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.
An implementation co-ordination committee based on policies of individual organization
has been appointed. The implementation process begins with preparing a plan for the
implementation of the system. According to this plan, the activities are to be carried out,
discussions made regarding the equipment and resources and the additional equipment has to
be acquired to implement the new system.
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 be
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.
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.
31
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.
Performance:
Database connection is through a connection pool mechanism. Database Connections
are being created as and when required, instead they are retrieved from a pool of
connections. This way the transactions are faster in execution.
Java standard API objects are used wherever possible to hold data.
The second database acts as a backup server to improve performance and survive
database crashes.
Security:
Failure of one database does not affect the data in the other database.
7.1. Modules
identifies the initiator and target of the Route Discovery, and also contains a unique
request identification determined by the initiator of the Request. Each Route Request
also contains a record listing the address of each intermediate node through which
this particular copy of the Route Request has been forwarded.
32
Re-Core Selection
To select the re-core node address for finding the destination
address.
Re-Core selection is used when the core process is not able to
find the destination address.
33
8. CONCLUSION
Terminode routing aims to support location-based routing on
irregular topologies with mobile nodes. It achieves its goal by
combining a location-based routing method with a link state-based
mechanism. Further, it introduces the concept of anchors, which are
geographical points imagined by sources for routing to specific
destinations, and proposes low overhead methods for computing
anchors. Last, a
special form of restricted search mode (Restricted Local Flooding,
RLF), solves problems due to the inaccuracy of location information,
in particular for control packets. The performance analysis shows
that, in large mobile ad hoc networks, terminode routing performs
better than MANET-like, or existing location-based routing protocols.
It does so by maintaining its routing overhead low and by
efficiently solving location inaccuracies.
34
Future Enhancement
A Mobile Gateway has been developed that uses a cellular network for the
connection. It handles the challenges that had to be solved to realize this
interconnection and describes a way how to connect two IPv6 networks over an IPv4
infrastructure. Different levels of mobility are described. Mobility within the ad hoc
domain and between different Mobile Gateways of this ad hoc domain is handled
using an enhanced AODV routing protocol. Mobility of the whole ad hoc network is
handled by the mobility mechanisms of the cellular network and finally the seamless
mobility of single ad hoc nodes is realized using two interfaces and a modified
MobileIPv6 implementation.
35
9. BIBLIOGRAPHY
Good Teachers are worth more than thousand books, we have
them in Our Department
Sites Referred:
http://java.sun.com
www.beta.ece.ucsb.edu
www.ietf.org
www.ecst.csuchoco.edu
36
37
38
39
40
41
42
43
44
Sample Code
45
Core.java
import java.io.*;
import java.net.*;
import java.util.*;
class Core
{
static String g1="";
static String n=" ";
static String core="";
static String nul=null;
static File fk;
public static void main(String a[])
{
}
static String findCore() throws Exception
{
String s="";
String k="";
InetAddress in;
TreeSet v=new TreeSet();
String b="";
BufferedReader bf=new BufferedReader(new FileReader("f2.txt"));
while((s=bf.readLine())!=null)
{
try
{
in=InetAddress.getByName(s);
b=in.getHostAddress();
v.add(b);
System.out.println("Inetaddress : "+in);
System.out.println("Address : "+b);
}
catch(Exception e)
{
System.out.println("Error in finding the core ");
continue;
}
}
bf.close();
core=(String)v.last();
System.out.println("The Core Node's Address Is : "+core);
return core;
}
static void sendFileToCore(String core,String source,String destination,String msg)
throws Exception
{
46
String str="",str1="";
//FileReader fr=new FileReader(f1);
//BufferedReader br=new BufferedReader(fr);
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@"+core);
Socket s=new Socket(core,8888);
ObjectOutputStream obop=new
ObjectOutputStream(s.getOutputStream());
obop.writeObject("file");
obop.writeObject(source);
System.out.println("The Source address is : "+source);
obop.writeObject(destination);
System.out.println("The destined address is : "+destination);
obop.writeObject(msg);
obop.writeObject(nul);
}
//s.close();
public static String met1()
{
int i;
int b[]=new int[5000];
int a[]=new int[5000];
String g=" ";
char x[]=new char[5000];
char d,s;
String s1;
try
{
n=FileOpen.jta.getText();
int len=n.length();
System.out.println("StringLength:"+len);
System.out.print("Ascii-CODE:");
for(i=0;i<len;i++)
{
int aa= n.charAt(i);
System.out.print("\t"+ aa);
a[i]=aa;
}
System.out.print("\n");
System.out.print("HEX-CODE:");
47
for(i=0;i<len;i++)
{
g=" ";
b[i]=a[i]%16;
a[i]=a[i]/16;
if(a[i]==10)
{
s='A';
g=g+s;
}
else if(a[i]==11)
{
s='B';
g=g+s;
}
else if(a[i]==12)
{
s='C';
g=g+s;
}
else if(a[i]==13)
{
s='D';
g=g+s;
}
else if(a[i]==14)
{
s='E';
g=g+s;
}
else if(a[i]==15)
{
48
s='F';
g=g+s;
}
else
{
s=(char) a[i];
g=g+a[i];
}
if(b[i]==10)
{
s='A';
g=g+s;
System.out.print(g.trim());
}
else if(b[i]==11)
{
s='B';
g=g+s;
System.out.print(g.trim());
}
else if(b[i]==12)
{
s='C';
g=g+s;
System.out.print(g.trim());
}
else if(b[i]==13)
{
s='D';
g=g+s;
System.out.print(g.trim());
}
else if(b[i]==14)
{
s='E';
g=g+s;
49
System.out.print(g.trim());
}
else if(b[i]==15)
{
s='F';
g=g+s;
System.out.print(g.trim());
}
else
{
s=(char) b[i];
g=g+b[i];
System.out.print(g.trim());
}
g1=g1+g.trim();
}
FileWriter fr=new FileWriter("encc.txt");
BufferedWriter bw=new BufferedWriter(fr);
bw.write(g1,0,g1.length());
bw.flush();
//fk=new File("encc.txt");
}
catch(Exception e)
{
System.out.println(e);
}
return(g1);
//System.out.println("Struibg"+g1);
}
}
Destination.java
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
50
*/
for(i=0;i<len;i++)
{
char aa= ((str2).charAt(i));
a[i]=aa;
if(a[i]=='A')
{
st="1010";
st1=st;
}
else if(a[i]=='B')
{
st="1011";
st1=st;
}
else if(a[i]=='C')
{
st="1100";
st1=st;
}
else if(a[i]=='D')
{
st="1101";
st1=st;
}
else if(a[i]=='E')
{
st="1110";
st1=st;
}
else if(a[i]=='F')
{
st="1111";
st1=st;
}
else if(a[i]=='0')
{
st="0000";
st1=st;
}
else if(a[i]=='1')
{
st="0001";
53
st1=st;
}
else if(a[i]=='2')
{
st="0010";
st1=st;
}
else if(a[i]=='3')
{
st="0011";
st1=st;
}
else if(a[i]=='4')
{
st="0100";
st1=st;
}
else if(a[i]=='5')
{
st="0101";
st1=st;
}
else if(a[i]=='6')
{
st="0110";
st1=st;
}
else if(a[i]=='7')
{
st="0111";
st1=st;
}
else if(a[i]=='8')
{
st="1000";
}
else if(a[i]=='9')
{
st="1001";
}
w=w+st;
}
char w_ch[]=w.toCharArray();
String x=w.toString();
System.out.print(x);
System.out.println("Length:"+len);
/* Converting Hexcode into Character */
54
try
{
if(len==8)
{
int k;
k=len;
for(j=k-1;j>=0;j--)
{
c=c+(w_ch[j]-48)*d;
y=y+c;
d=d*2;
}
System.out.print("\n");
vj=vj+(char)c;
//System.out.print((char)c);
}
else
{
int k;
for(i=0;i<5000;i++)
{
c=0; d=1;
k=i*8;
for(j=k+7;j>=k;j--)
{
c=c+(w_ch[j]-48)*d;
y=y+c;
d=d*2;
}
vj=vj+(char)c;
//System.out.print((char) c);
}
}
}
catch(Exception e)
{
}
}
catch(Exception e)
{
System.out.println(e);
}
System.out.println("the file content is :"+vj);
System.out.println("File Ends *********** ");
ta1.append(vj);
55
String str="";
Core co;
ReCore rc;
String pass="";
String path="";
String coreaddr="";
String core="";
String nextcore="";
String dest="";
String dest1="";
File f;
File fg;
FileOpen()
{
jl1=new JLabel("Plz Enter The Destination Name ");
jl2=new JLabel("Plz Choose File ");
jl3=new JLabel("File Name Will Be Displayed Here..");
jl5=new JLabel("Next Core Address ");
jb1=new JButton("Send");
jb2=new JButton("Reset");
jb3=new JButton("Browse..");
jt1=new JTextField(10);
jt2=new JTextField(10);
ii=new ImageIcon("Multi.gif");
jl4=new JLabel(ii);
jta=new JTextArea();
jsp=new JScrollPane(jta);
c=getContentPane();
c.setLayout(null);
c.add(jl1);
c.add(jt1);
c.add(jl2);
c.add(jl3);
c.add(jb3);
c.add(jb1);
c.add(jb2);
c.add(jsp);
c.add(jl4);
c.add(jl5);
c.add(jt2);
jl1.setBounds(70,100,200,25);
jt1.setBounds(300,100,100,25);
jl2.setBounds(70,135,200,25);
jt2.setBounds(300,135,100,25);
jb3.setBounds(300,170,100,25);
jsp.setBounds(410,100,280,400);
jb1.setBounds(150,225,100,25);
jb2.setBounds(300,225,100,25);
jl4.setBounds(700,50,250,500);
57
jl3.setBounds(70,400,600,25);
jl5.setBounds(70,500,600,25);
setSize(800,800);
setVisible(true);
jb3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae)
{
JFileChooser jf=new JFileChooser();
int m=jf.showOpenDialog(null);
if(m==JFileChooser.APPROVE_OPTION)
{
f=jf.getSelectedFile();
str=f.getPath();
path=f.getAbsolutePath();
jl3.setText("U Have Selected The File
Named \""+str+"\""+"from "+path);
try
{
FileInputStream fis=new FileInputStream(str);
byte b[]=new byte[fis.available()];
jt2.setText(str);
fis.read(b);
String str1=new String(b);
jta.setText(str1);
}
catch(Exception ui){}
}
}
} );
jb1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae)
{
co=new Core();
rc=new ReCore();
try {
coreaddr=co.findCore();
jl3.setText("The Core Address is : "+coreaddr);
String
d=((InetAddress.getLocalHost()).getHostAddress());
System.out.println("The local address is : "+d);
dest=jt1.getText();
dest1=jt2.getText();
jl5.setText(dest);
58
pass=co.met1();
if(coreaddr.equals((InetAddress.getLocalHost()).getHostAddress()))
{
// nextcore = ReCore.sss;
nextcore=rc.reqCore();
jl5.setText("The Next Mesh Core is :"+nextcore);
co.sendFileToCore(nextcore,
(InetAddress.getLocalHost()).getHostAddress(),dest,pass);
//Thread.sleep(1000);
co.sendFileToCore(nextcore,
(InetAddress.getLocalHost()).getHostAddress(),dest1,pass);
}
else
{
co.sendFileToCore(coreaddr,
(InetAddress.getLocalHost()).getHostAddress(),dest,pass);
//Thread.sleep(1000);
co.sendFileToCore(coreaddr,
(InetAddress.getLocalHost()).getHostAddress(),dest1,pass);
System.out.println("Successful transfer of file
");
jl5.setText("The Next Mesh Core
is :"+coreaddr);
}
}
catch(Exception e) { System.out.println(e); }
}
} );
}
public static void main(String a[])
{
new FileOpen();
}
}
Main_server.java
import java.io.*;
import java.net.*;
import java.util.*;
class Main_Server
{
59
{
System.out.println(ie);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Pack.java
class Pack
{
static String subs1;
static String sub="";
public static String Pack1(String g1)
{
int len=g1.length();
System.out.println("Length:"+len);
int len1=len/16;
System.out.println("Length1:"+len1);
int len2=len%16;
int k=16;
System.out.println("Length2:"+len2);
int c=0;
for(int l=0;l<len;l+=16)
{
if(k<=len-len2)
{
String subs = g1.substring(l,k);
subs1 = subs + "\n";
sub+=subs1;
c++;
k+=16;
}
}
if(len2>0)
{
System.out.println("inside ");
int g =(len- c*16);
System.out.println("Value:"+g);
subs1 = g1.substring(c*16,len);
sub+=subs1;
}
System.out.println("Packets:"+sub);
63
return sub;
}
}
Recore.java
import java.io.*;
import java.net.*;
class ReCore
{
static String add="";
public static void main(String a[])
{
try{
String add=reqCore();
System.out.println("aaaaaaaaaaaaaaaaaaaaaaaa"+add);
} catch(Exception e) { System.out.println(e); }
}
public static String reqCore() throws Exception
{
System.out.println("The local 1");
String h="";
System.out.println("Socket side ");
String s1="";
String s2="request";
String addr="";
Socket s;
String sss="";
boolean b=true;
//ObjectInputStream obip;
//ObjectOutputStream obop;
BufferedReader br;
BufferedWriter bw;
FileReader fr=new FileReader("NEXTMESH.txt");
BufferedReader brf=new BufferedReader(fr);
System.out.println("Socket side after file read ");
//System.out.println("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"+s1);
while((s1=brf.readLine())!=null)
{
if(b)
{
System.out.println("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"+s1);
sss = s1;
System.out.println("B4 try ");
try
{
64
s=new Socket(s1,8888);
System.out.println("after connection ");
InputStream is=s.getInputStream();
OutputStream os=s.getOutputStream();
//ObjectInputStream ois=new ObjectInputStream(is);
ObjectOutputStream oos=new ObjectOutputStream(os);
//os.write(1);
oos.writeObject("request");
ObjectInputStream obip=new
ObjectInputStream(s.getInputStream());
add=(String)obip.readObject();
b=false;
System.out.println("The Next Core Address :"+add);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
return sss;
}
}
65