Sei sulla pagina 1di 84

Flexible Deterministic Packet

Marking:
An IP Traceback System to Find
The Real Source of Attacks
CONTENTS

1. INTRODUCTION
1.1About the Project

3. SYSTEM ANALYSIS
3.1 Existing System
3.2 Proposed System

4. PROBLEM FORMULATION
4.1 Hardware Specification
4.2 Software Specification
4.3 Software Descriptions

5. SYSTEM DESIGN
5.1 Design Overview
5.2 Context Analysis Diagram
5.3 Data Flow Diagram

6. MODULE DESCRIPTION

7. SYSTEM TESTING
6.1 Unit Testing
6.2 Integration Testing
6.3 Acceptance Testing

8. SYSTEM IMPLMENTATION

9. CONCLUSION

10. FUTURE ENCHANCEMENTS

11. BIBLIOGRAPHY

12. APPENDICES
APPENDIX A: SAMPLE SCREENS

1. About the Project


We present a novel and practical IP traceback system called Flexible
Deterministic Packet Marking (FDPM) which provides a defense system with
the ability to find out the real sources of attacking packets that traverse through
the network. While a number of other traceback schemes exist, FDPM provides
innovative features to trace the source of IP packets and can obtain better
tracing capability than others. In particular, FDPM adopts a flexible mark
length strategy to make it compatible to different network environments; it also
adaptively changes its marking rate according to the load of the participating
router by a flexible flow-based marking scheme. Evaluations on both simulation
and real system implementation demonstrate that FDPM requires a moderately
small number of packets to complete the Traceback process; add little
additional load to routers and can trace a large number of sources in one
traceback process with low false positive rates. The built-in overload prevention
mechanism makes this system capable of achieving a satisfactory traceback
result even when the router is heavily loaded. The motivation of this traceback
system is from DDoS defense. It has been used to not only trace DDoS
attacking packets but also enhance filtering attacking traffic. It has a wide array
of applications for other security systems.
3. SYSTEM ANALYSIS

3.1 EXISTING SYSTEM:


PPM algorithm:
More importantly, without a proper termination condition,
the attack graph constructed by the PPM algorithm would be wrong.

Disadvantages:

 Cannot find out Packet travel Path.


 Packet can be losses and Duplication of packet Receive the Receiver.
 Receiver does not have the original packet. Because the More no of
Duplication message receive the receiver.
3.2 PROPOSED SYSTEM:

 FDPM Algorithm:
The FDPM algorithm provides an autonomous way for
the original PPM algorithm to determine its termination, and it
is a promising means of enhancing the reliability of the PPM
algorithm.
The most significant merit of the FDPM algorithm is
that when the algorithm terminates, the algorithm guarantees
that the constructed attack graph is correct, with a specified
level of confidence.
We carry out simulations on the FDPM algorithm and
show that the FDPM algorithm can guarantee the correctness
of the constructed attack graph.

Advantages:

 Different probabilities that a router marks the attack packets .


 Easy to find out packet loss and Duplicate packets.
 Find out each and every packet path.
 To reduce the network traffic.
4.1 Hardware requirements:

Processor : Any Processor above 500 Mhz.

Ram : 128Mb.

Hard Disk : 10 Gb.

Compact Disk : 650 Mb.

Input device : Standard Keyboard and Mouse.

Output device : VGA and High Resolution Monitor.

4.2 Software requirements:

Operating System : Windows 2000 server Family.

Techniques : JDK 1.5

Data Bases : MS Acess


Front End : Java Swing.
Implementation Concept: Socket in Java.

4.3 Software and Technologies Description:

Java Technology

Java technology is both a programming language and a platform.

The Java Programming Language

The Java programming language is a high-level language that can be


characterized by all of the following buzzwords:
 Simple
 Architecture neutral
 Object oriented
 Portable
 Distributed
 High performance
 Interpreted
 Multithreaded
 Robust
 Dynamic
 Secure
With most programming languages, you either compile or interpret a program
so that you can run it on your computer. The Java programming language is
unusual in that a program is both compiled and interpreted. With the compiler,
first you translate a program into an intermediate language called Java byte
codes —the platform-independent codes interpreted by the interpreter on the
Java platform. The interpreter parses and runs each Java byte code instruction
on the computer. Compilation happens just once; interpretation occurs each
time the program is executed. The following figure illustrates how this works.

FIGURE 2- WORKING OF JAVA


You can think of Java bytecodes as the machine code instructions for the
Java Virtual Machine (Java VM). Every Java interpreter, whether it’s a
development tool or a Web browser that can run applets, is an implementation
of the Java VM. Java bytecodes help make “write once, run anywhere”
possible. You can compile your program into bytecodes on any platform that
has a Java compiler. The bytecodes can then be run on any implementation of
the Java VM. That means that as long as a computer has a Java VM, the same
program written in the Java programming language can run on Windows 2000,
a Solaris workstation, or on an iMac.
The Java Platform

A platform is the hardware or software environment in which a program


runs. We’ve already mentioned some of the most popular platforms like
Windows 2000, Linux, Solaris, and MacOS. Most platforms can be described as
a combination of the operating system and hardware. 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.
The Java platform has two components:
• The Java Virtual Machine (Java VM)
• The Java Application Programming Interface (Java API)
You’ve already been introduced to the Java VM. It’s 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 of related classes and interfaces;
these libraries are known as packages. The next section, What Can Java
Technology Do?, highlights what functionality some of the packages in the Java
API provide.
The following figure depicts a program that’s running on the Java
platform. As the figure shows, the Java API and the virtual machine insulate the
program from the hardware.
FIGURE 3- THE JAVA PLATFORM

Native code is code that after you compile it, the compiled code runs on a
specific hardware platform. As a platform-independent environment, the Java
platform can be a bit slower than native code. However, smart compilers, well-
tuned interpreters, and just-in-time byte code compilers can bring performance
close to that of native code without threatening portability.

What Can Java Technology Do?


The most common types of programs written in the Java programming
language are applets and applications. If you surfed the Web, you’re probably
already familiar with applets. An applet is a program that adheres to certain
conventions that allow it to run within a Java-enabled browser.
However, the Java programming language is not just for writing cute,
entertaining applets for the Web. The general-purpose, high-level Java
programming language is also a powerful software platform. Using the
generous API, you can write many types of programs.
An application is a standalone program that runs directly on the Java
platform. A special kind of application known as a server serves and supports
clients on a network. Examples of servers are Web servers, proxy servers, mail
servers, and print servers. Another specialized program is a servlet. A servlet
can almost be thought of as an applet that runs on the server side. Java Servlets
are a popular choice for building interactive web applications, replacing the use
of CGI scripts. Servlets are similar to applets in that they are runtime extensions
of applications. Instead of working in browsers, though, servlets run within Java
Web servers, configuring or tailoring the server.
How does the API support all these kinds of programs? It does so with
packages of software components that provides a wide range of functionality.
Every full implementation of the Java platform gives you the following
features:
• The essentials: Objects, strings, threads, numbers, input and output, data
structures, system properties, date and time, and so on.
• Applets: The set of conventions used by applets.
• Networking: URLs, TCP (Transmission Control Protocol), UDP (User
Data gram Protocol) sockets, and IP (Internet Protocol) addresses.
• 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 and private key management, access control, and certificates.
• Software components: Known as JavaBeansTM, can plug into existing
component architectures.
• Object serialization: Allows lightweight persistence and communication
via Remote Method Invocation (RMI).
• Java Database Connectivity (JDBCTM): Provides uniform access to a
wide range of relational databases.
The Java platform also has APIs for 2D and 3D graphics, accessibility, servers,
collaboration, telephony, speech, animation, and more. The following figure
depicts what is included in the Java 2 SDK.
FIGURE 4 – JAVA 2 SDK

ODBC
Microsoft Open Database Connectivity (ODBC) is a standard
programming interface for application developers and database systems
providers. Before ODBC became a de facto standard for Windows programs to
interface with database systems, programmers had to use proprietary languages
for each database they wanted to connect to. Now, ODBC has made the choice
of the database system almost irrelevant from a coding perspective, which is as
it should be. Application developers have much more important things to worry
about than the syntax that is needed to port their program from one database to
another when business needs suddenly change.
Through the ODBC Administrator in Control Panel, you can specify the
particular database that is associated with a data source that an ODBC
application program is written to use. Think of an ODBC data source as a door
with a name on it. Each door will lead you to a particular database. For
example, the data source named Sales Figures might be a SQL Server database,
whereas the Accounts Payable data source could refer to an Access database.
The physical database referred to by a data source can reside anywhere on the
LAN.
The ODBC system files are not installed on your system by Windows 95.
Rather, they are installed when you setup a separate database application, such
as SQL Server Client or Visual Basic 4.0. When the ODBC icon is installed in
Control Panel, it uses a file called ODBCINST.DLL. It is also possible to
administer your ODBC data sources through a stand-alone program called
ODBCADM.EXE. There is a 16-bit and a 32-bit version of this program and
each maintains a separate list of ODBC data sources.

From a programming perspective, the beauty of ODBC is that the


application can be written to use the same set of function calls to interface with
any data source, regardless of the database vendor. The source code of the
application doesn’t change whether it talks to Oracle or SQL Server. We only
mention these two as an example. There are ODBC drivers available for several
dozen popular database systems. Even Excel spreadsheets and plain text files
can be turned into data sources. The operating system uses the Registry
information written by ODBC Administrator to determine which low-level
ODBC drivers are needed to talk to the data source (such as the interface to
Oracle or SQL Server). The loading of the ODBC drivers is transparent to the
ODBC application program. In a client/server environment, the ODBC API
even handles many of the network issues for the application programmer.

The advantages of this scheme are so numerous that you are probably
thinking there must be some catch. The only disadvantage of ODBC is that it
isn’t as efficient as talking directly to the native database interface. ODBC has
had many detractors make the charge that it is too slow. Microsoft has always
claimed that the critical factor in performance is the quality of the driver
software that is used. In our humble opinion, this is true. The availability of
good ODBC drivers has improved a great deal recently. And anyway, the
criticism about performance is somewhat analogous to those who said that
compilers would never match the speed of pure assembly language. Maybe not,
but the compiler (or ODBC) gives you the opportunity to write cleaner
programs, which means you finish sooner. Meanwhile, computers get faster
every year.

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 was announced in March of 1996. It was released for a 90 day public
review that ended June 8, 1996. Because of user input, the final JDBC v1.0
specification was released soon after.
The remainder of this section will cover enough information about JDBC
for you to know what it is about and how to use it effectively. This is by no
means a complete overview of JDBC. That would fill an entire book.

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:
1. SQL Level API
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. This goal
allows for future tool vendors to “generate” JDBC code and to hide many of
JDBC’s complexities from the end user.
2. SQL Conformance
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.
3. JDBC must be implemental on top of common database interfaces

The JDBC SQL API must “sit” on top of other common SQL level
APIs. This goal allows JDBC to use existing ODBC level drivers by the
use of a software interface. This interface would translate JDBC calls to
ODBC and vice versa.
4. 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.
5. 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.
6. Use strong, static typing wherever possible
Strong typing allows for more error checking to be done at compile time;
also, fewer errors appear at runtime.
7. Keep the common cases simple
Because more often than not, the usual SQL calls used by the programmer
are simple SELECT’s, INSERT’s, DELETE’s and UPDATE’s, these queries
should be simple to perform with JDBC. However, more complex SQL
statements should also be possible.

Networking

TCP/IP stack

The TCP/IP stack is shorter than the OSI one:


FIGURE 5 – TCP/IP STACK

TCP is a connection-oriented protocol; UDP (User Datagram Protocol) is a


connectionless protocol.

IP datagram’s

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.
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

FIGURE 6 - IP ADDRESSING

The 32 bit address is usually written as 4 integers separated by dots.

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 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 Read File and Write File functions.

#include <sys/types.h>
#include <sys/socket.h>
int socket(int family, int type, int protocol);
Here "family" will be AF_INET for IP communications, protocol will be
zero, and type will depend on whether TCP or UDP is used. Two processes
wishing to communicate over a network create a socket each. These are similar
to two ends of a pipe - but the actual pipe does not yet exist.
5. SYSTEM DESIGN

5.1 Design Overview

Design involves identification of classes, their relationships as well as


their collaboration. In objector, classes are divided into entity classes, interface
classes and control classes. The Computer Aided Software Engineering (CASE)
tools that are available commercially do not provide any assistance in this
transition. CASE tools take advantage of Meta modeling that are helpful only
after the construction of the class diagram. In the Fusion method, some object-
oriented approaches like Object Modeling Technique (OMT), Classes,
Responsibilities, Collaborators (CRC), etc, are used. Objectory used the term
“agents” to represent some of the hardware and software systems .In Fusion
method, there is no requirement phase, where a user will supply the initial
requirement document. Any software project is worked out by both the analyst
and the designer. The analyst creates the use case diagram. The designer creates
the class diagram. But the designer can do this only after the analyst creates the
use case diagram. Once the design is over, it is essential to decide which
software is suitable for the application.
5.2 System Architecture:
The process of the design implemented with the system architecture view
comprises of the parts of the project work that encapsulates all modules ranging
from module to module communication, setting initializations and system.

sender find path Intermediate nodes packet Encoding

Grapth construction Trace path Destination

5.3 Use Case Diagram:


Select
Destinatio
n

Find Path

Send text
file

Terminate
DOS
packets
Source
Find the Destination
dos
attackers

Class Diagrams:
5.4 Data Flow Diagram:
Sequence Diagrams:
sender

2 f
Object Diagram
6. MODULE DESCRIPTION
Modules:

 User login

 Packet Encoding

 Used Methods
1. Routing Trace back system:
2. Flow-Based Marking Scheme
3. FDPM scheme
 Termination of Dos Packets

Modules Description:

User Login
In this module the user login window, Message Transfer
window, Receiving window, and Graph construction window are designed.

User can send or receive messages for this they have to get login
After successfully login the user gets the Message Transfer window using this
window one can type or browse the messages which have to send other nodes
When a user receives the message the receiver window automatically opened on
the receiver side and the dos attacker packet are shown in alert box if there is
any.
In this window there is a button option to see the graph in the way which it is
traversed.
After reading the message he close widow and reply to that window through his
own widow.

Packet Encoding
The FDPM algorithm is designed to automatically determine when the
algorithm should terminate. We aim at achieving the following properties:

1. The algorithm does not require any prior knowledge about the network
topology.

2. The algorithm determines the certainty that the constructed graph is the
attack graph when the algorithm terminates.

Our goal is to devise an algorithm that guarantees that the constructed graph is
the same as the attack graph with probability greater than P*, where we name
P* the trace back confidence level. To accomplish this goal, the graph
reconstruction procedure of the original PPM algorithm is completely replaced,
and we name the new procedure the rectified graph reconstruction procedure.
On the other hand, we preserve the packet marking procedure so that every
router deployed with the PPM algorithm is not required to change.

For each router, we assume that it is equipped with the ability to mark packets
as in the original PPM algorithm. We also assume that each router shares the
same marking probability. Specifically, a router can either be a transit router or
a leaf router. A transit router is a router that forwards traffic from upstream
routers to its downstream routers (or the victim), whereas a leaf router is a
router whose upstream router is connected to client computers (not routers) and
forwards the clients’ traffic to its downstream routers (or the victim). Certainly,
the clients are
mixed with honest and malicious parties. In addition, we assume that all leaf
routers in an attack graph are the sources of the attack packets, and each leaf
router sends out a similar number of attack packets. Note that we are not
assuming that there is only one attacker, but we are considering a multiple-
attacker environment.

USED METHODS:

Routing Trace back system:

Packet marking schemes insert trace back data into an


IP packet header to mark the packet on its way through the various routers from
the attack source to the destination; then the marks in the packets can be used to
deduce the sources of packets or the paths of the traffic. As this method
overwrites some rarely used fields in IP header, it does not require modification
of the current Internet infrastructure. This property makes it a promising trace
back scheme to be part of DDoS defense systems. However, the space in IP

FDPM scheme:
The FDPM scheme utilizes various bits (called marks) in the
IP header. The mark has flexible lengths depending on the network protocols
used, which is called flexible mark length strategy. When an IP packet enters
the protected network, it is marked by the interface close to the source of the
packet on an edge ingress router. The source IP addresses are stored in the
marking fields. The mark will not be overwritten by intermediate routers when
the packet traverses the network. At any point within the network, e.g., the
victim host, the source IP addresses can be reconstructed when required.

Flow-Based Marking Scheme:


The idea of flow-based marking is to selectively
mark the packets according to the flow information when the router is under a
high load. Therefore, it can reduce the packet marking load of a router but still
maintain the marking and trace back function. Because the main application of
FDPM in our research is DDoS defense, the flow-based marking mainly
deals with the packets in DDoS attack scenarios. For other applications, this
overload prevention mechanism can be modified accordingly to target most
possible attacking packets.
Termination of Dos Packets

we provide an algorithm for calculating the packet-type probability of every


edge of an input graph. The algorithm first constructs the paths that lead from
every leaf router to the victim. Then, for each path, the algorithm calculates and
accumulates the packet-type probability for every edge in the path. Eventually,
it returns the packet-type probabilities of all edges of the input graph.
Note that the calculations of the packet-type probability for an unmarked packet
and the strict packet-type probabilities are not included in the pseudo code, but
one can calculate these probabilities, together with the results obtained by the
algorithm. After deriving the calculation of the packet-type probability, we are
ready for the calculation of the termination packet number

Using the encoded information in the packets the received node constructs the
graph. In this we can see the path in which packet are traversed
header that can be utilized is limited. Thus, the information that one packet can
carry is also limited.
SYSTEM TESTING

PROCESS:

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 TESTING:

Functional tests provide 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 : identified classes of valid input must be accepted.
Invalid Input : identified classes of invalid input must be rejected.
Functions : identified functions must be exercised.
Output : identified classes of application outputs must be
exercised.
Systems/Procedures: interfacing systems or procedures must be invoked.

Organization and preparation of functional tests is focused on requirements,


key functions, or special test cases. In addition, systematic coverage pertaining
to identify
Business process flows; data fields, predefined processes, and successive
processes must be considered for testing. Before functional testing is complete,
additional tests are identified and the effective value of current tests is
determined.

SYSTEM TESTING:

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.

WHITE BOX TESTING:

White Box Testing is a testing in which in which the software tester has
knowledge of the inner workings, structure and language of the software, or at
least its purpose. It is purpose. It is used to test areas that cannot be reached
from a black box level .
BLACK BOX TESTING:

Black Box Testing is testing the software without any knowledge of the
inner workings, structure or language of the module being tested . Black box
tests, as most other kinds of tests, must be written from a definitive source
document, such as specification or requirements document, such as
specification or requirements document. It is a testing in which the software
under test is treated, as a black box .you cannot “see” into it. The test provides
inputs and responds to outputs without considering how the software works.

6.1 Unit Testing:

Unit testing is usually conducted as part of a combined code and unit test
phase of the software lifecycle, although it is not uncommon for coding and unit
testing to be conducted as two distinct phases.

Test strategy and approach


Field testing will be performed manually and functional tests will be
written in detail.

Test objectives
All field entries must work properly.
Pages must be activated from the identified link.
The entry screen, messages and responses must not be delayed.
Features to be tested
Verify that the entries are of the correct format
No duplicate entries should be allowed
All links should take the user to the correct page.

6.2 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.

Test Results: All the test cases mentioned above passed successfully. No
defects encountered.

6.3 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.

Test Results: All the test cases mentioned above passed successfully. No
defects encountered.
SYSTEM IMPLEMENTATION

Implementation is the stage of the project when the theoretical design is


turned out into a working system. Thus it can be considered to be the most
critical stage in achieving a successful new system and in giving the user,
confidence that the new system will work and be effective.

The implementation stage involves careful planning, investigation of the


existing system and it’s constraints on implementation, designing of methods to
achieve changeover and evaluation of changeover methods.

Implementation is the process of converting a new system design into


operation. It is the phase that focuses on user training, site preparation and file
conversion for installing a candidate system. The important factor that should
be considered here is that the conversion should not disrupt the functioning of
the organization.

The implementation can be preceded through Socket in java but it will be


considered as one to all communication .For proactive broadcasting we need
dynamic linking. So java will be more suitable for platform independence and
networking concepts. For maintaining route information we go for SQL-server
as database back end.

The aim of this project is used to avoid the disadvantage of the network
traffic, duplication message, and waste lot of energy. And the proposed system
to avoid these disadvantages.
.

10. CONCLUSIONS
The PPM algorithm lacks a proper definition of the termination
condition. Meanwhile, using the expected number of required
marked packets E½X as the termination condition is not sufficient.
The above two outstanding problems only lead to an undesirable
outcome: there is no guarantee of the correctness of the
constructed graph produced by the PPM algorithm.

The new trace back approaches the FDPM algorithm. The FDPM algorithm, on one
hand, does not require any previous knowledge about the network graph. On the other hand,
it guarantees that the constructed graph is a correct one, with a specified probability, and
such a probability is an input parameter of the algorithm. The FDPM algorithm is an
effective means of improving the reliability of the original PPM algorithm.

11. FUTURE WORK:

The FDPM algorithm is an extension of the PPM


algorithm; the FDPM algorithm inherits defects of the PPM
algorithm. Problems such as scalability and different
attack patterns will be future research directions. The
proposed system finds out the attack packet and find out
which is attack the packet. In future first find attacker and
then send the message.

12.1 APPENDIX 1: SCREEN SHOTS


Appendix 2- Sample Code:

/* DBSERVER */
import java.io.*;
import java.net.*;
import java.util.*;
import java.sql.*;
public class DBServer
{
public ServerSocket ss;
public Socket s;
public Connection Con;
public Statement St;
DBServer()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Con=DriverManager.getConnection("Jdbc:Odbc:FDPM","sa","");
St=Con.createStatement();
St.executeUpdate("delete from Nodes");
Vector findnodes=getNodeList();

System.out.println("The Router's Are =>"+findnodes);


SetDestinationPath(findnodes);
ss=new ServerSocket(1880);//1680
while(true)
{
System.out.println("Routing Table is Instantiated
");//DataBase Server is Listening");
s=ss.accept();
DataInputStream dis=new
DataInputStream(s.getInputStream());
DataOutputStream dos=new
DataOutputStream(s.getOutputStream());
String flag=dis.readUTF();
if(flag.equals("Path"))
{
String source=dis.readUTF();
String destination=dis.readUTF();
String path=getPath(source,destination);
dos.writeUTF(path);
System.out.println("path is send to
sender :"+path);
}
}
}catch (Exception e){e.printStackTrace();}

public String getPath(String source,String destination)


{
String path="";
try
{

ResultSet rs=St.executeQuery("select Path from Nodes where


Source='"+source+"' and Destination='"+destination+"'");
while(rs.next())
{
path=rs.getString(1);
}
}catch (Exception e){ e.printStackTrace();}
return path;
}

public Vector getNodeList()


{
Vector vnode = new Vector();
try
{
/*Runtime r = Runtime.getRuntime();
Process p = r.exec("net view");
BufferedReader br = new
BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedWriter wr = new
BufferedWriter(new OutputStreamWriter(netpath.txt));

String node="";
int i=1;
while((node=br.readLine()) != null)
{
if(node.startsWith("\\"))
{
String[] node1 = node.split("
");
node = node1[0].trim();
String fnode =
node.substring(node.indexOf("\\")+2, node.length());
vnode.addElement(fnode);

}
}*/
int s=vnode.size();
if(s==0)
{
BufferedReader br1= new BufferedReader(new
FileReader("NodeLists.txt"));
int c;
String str="";
while((str=br1.readLine())!=null)
{
String[] input = str.split("#");
//int sl=1;
for(int j=0;j<input.length;j++)
{
vnode.addElement(input[j]);
}
}
System.out.println("Number of Router
is"+vnode.size());
}
}catch (Exception e){e.printStackTrace();}
return vnode;
}

public void SetDestinationPath(Vector findnode)


{
try
{

Vector findnode1=new Vector();


int vsize=findnode.size();
for(int i=vsize-1;i>=0;i--)
{

findnode1.addElement(findnode.elementAt(i).toString());
}
PathTraverse(findnode1);
PathTraverse(findnode);
}catch (Exception e) { e.printStackTrace();}
}

public void PathTraverse(Vector fn)


{
int vsize=fn.size();
while(vsize>0)
{
int i = 0;
String source=fn.elementAt(i).toString();
String path="";
String dest="";
int dps,sps;
for(int j=i;j<vsize;j++)
{
//dps=fn.indexOf(fn.elementAt(
j).toString());

path=path+fn.elementAt(j).toString()+"#";

dest=fn.elementAt(j).toString();
if(!source.equals(dest))
try
{

St.executeUpdate("insert into Nodes values('"+source


+"','"+dest+"','"+path+"')");

//System.out.println("In
serted s"+source+"d"+dest+"p"+path);
}catch (Exception e)
{ e.printStackTrace();}
}
fn.removeElementAt(i);
vsize=fn.size();
}
}

public static void main(String[] args)


{
new DBServer();
}
}

/****************************************************************/
/* LoginFrame */
/* */
/****************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
/**
* Summary description for LoginFrame
*
*/
public class LoginFrame extends JFrame
{
// Variables declaration
private JLabel jLabel3;
private JTextField userField;
private JPasswordField jPasswordField1;
private JButton login;
private JPanel contentPane;
String userName="",password="",sender="";
public Connection con;
public Statement st;
// End of variables declaration

public LoginFrame()
{
super();

initializeComponent();
this.setVisible(true);
//this.setDefaultCloseOperation(EXIT_ON_CLOSE);

}
public LoginFrame(String source)
{
super();
sender=source;
initializeComponent();
//
// TODO: Add any constructor code after initializeComponent call
//
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("Jdbc:Odbc:FDPM","sa","");
st=con.createStatement();
}
catch (Exception se)
{
se.printStackTrace();
}

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
* to retrieve your design properly in future, before revising this method.
*/
private void initializeComponent()
{
jLabel3 = new JLabel();
userField = new JTextField();
jPasswordField1 = new JPasswordField();
login = new JButton();
contentPane = (JPanel)this.getContentPane();

//
// jLabel3
//
jLabel3.setIcon(new ImageIcon("images\\login2.png"));
//login
login.setIcon(new ImageIcon("images\\BIcon.JPG"));
// userField
//
userField.setText("");
userField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
userField_actionPerformed(e);
}

});
//
// jPasswordField1
//
jPasswordField1.setText("");
jPasswordField1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jPasswordField1_actionPerformed(e);
}

});
//
// login
//
//login.setText("login");
login.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
login_actionPerformed(e);
}

});
//
// contentPane
//
contentPane.setLayout(null);

addComponent(contentPane, userField, 175,138,125,16);


addComponent(contentPane, jPasswordField1, 175,166,125,16);
addComponent(contentPane, login, 172,190,60,28);
addComponent(contentPane, jLabel3, 0,0,541,330);
//
// LoginFrame
//
this.setTitle("LoginFrame "+sender);
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(410, 365));
this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}

/** Add Component Without a Layout Manager (Absolute Positioning) */


private void addComponent(Container container,Component c,int x,int
y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}

//
// TODO: Add any appropriate code in the following Event Handling
Methods
//
private void userField_actionPerformed(ActionEvent e)
{
System.out.println("\nuserField_actionPerformed(ActionEvent e)
called.");
// TODO: Add any handling code here

private void jPasswordField1_actionPerformed(ActionEvent e)


{

System.out.println("\njPasswordField1_actionPerformed(ActionEvent e)
called.");
// TODO: Add any handling code here

private void login_actionPerformed(ActionEvent e)


{
System.out.println("\nlogin_actionPerformed(ActionEvent e)
called.");
// TODO: Add any handling code here
userName=userField.getText().trim();
password=jPasswordField1.getText().trim();

if( userName.length()<1 || password.length()<1 )


{
JOptionPane.showMessageDialog((Component)
null,"Please enter username and password","Click
OK",JOptionPane.INFORMATION_MESSAGE);
}
else
{
try
{

String res="";
int flag=0;
String query="select * from login where users =
'"+userName+"' and pass = '"+password+"'";
ResultSet rs=st.executeQuery(query);

if(rs.next())
{
flag=1;
System.out.println("----------------");
res=rs.getString(1);
System.out.println("user :-"+res);
res=rs.getString(2);
System.out.println("pass:-"+res);
System.out.println("----------------");
}

if(flag!=1){
JOptionPane.showMessageDialog((Component) null,"Invalid
username and password \n Please enter correct username and password","Click
OK",JOptionPane.INFORMATION_MESSAGE);
}
else{
PPMSender A=new PPMSender(sender);
this.setVisible(false);
//JOptionPane.showMessageDialog((Compon
ent) null,"Correct username and password","Click
OK",JOptionPane.INFORMATION_MESSAGE);
rs.close();
st.close();
con.close();
}
}
catch (SQLException se)
{
se.printStackTrace();
}

//
// TODO: Add any method code to meet your needs in the following area
//

//============================= Testing
================================//
//= =//
//= The following main method is just for testing this class you built.=//
//= After testing,you may simply delete it. =//
//===========================================================
===========//
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel
");
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
new LoginFrame();
}
//= End of Testing =

/* PPM RECEIVER*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class PPMReceiver extends JFrame
{
private JLabel jLabel5;
private JTextArea TA;
private JScrollPane jScrollPane1;
private JButton Graph,Clear,Main,Close;
private JPanel contentPane;
public ServerSocket ss;
public Socket s;
String iPTB="",receiver="";//--
public PPMReceiver()
{
super();
initializeComponent();
this.setVisible(true);
}
public PPMReceiver(String dest)
{
super();
receiver=dest;
initializeComponent();
this.setVisible(true);
}
private void initializeComponent()
{
jLabel5 = new JLabel();
TA = new JTextArea();
jScrollPane1 = new JScrollPane();
Clear = new JButton();
Main = new JButton();
Graph = new JButton();
Close = new JButton();
contentPane = (JPanel)this.getContentPane();
jLabel5.setIcon(new ImageIcon("images\\10.jpg"));
jScrollPane1.setViewportView(TA);
Graph.setText("Graph");
Graph.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Graph_actionPerformed(e);
}

});

Clear.setText("Clear");
Clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Clear_actionPerformed(e);
}

});

Main.setText("Main");
Main.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Main_actionPerformed(e);
}

});

Close.setText("Close");
Close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Close_actionPerformed(e);
}

});
contentPane.setLayout(null);
contentPane.setBackground(new Color(255, 255, 255));

addComponent(contentPane, jScrollPane1, 167,220,634,200);


addComponent(contentPane, Graph, 300,461,83,28);
addComponent(contentPane, Clear, 400,461,83,28);
addComponent(contentPane, Main, 500,461,83,28);
addComponent(contentPane, Close, 600,461,83,28);
addComponent(contentPane, jLabel5, -2,-2,888,768);
this.setTitle("FDPM Receiver"+receiver);
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(824, 539));
//this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );//--
}
private void addComponent(Container container,Component c,int x,int
y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
private void Graph_actionPerformed(ActionEvent e)
{

//JOptionPane.showMessageDialog((Component) null,"The
IPTraceback for this packet is : "+iPTB,"Click
OK",JOptionPane.INFORMATION_MESSAGE);//--
TraceBackGraph tbc=new TraceBackGraph();
tbc.constructGraph(iPTB);
}

private void Clear_actionPerformed(ActionEvent e)


{
System.out.println("\nClear_actionPerformed(ActionEvent e)
called.");
TA.setText("");//--
}

private void Main_actionPerformed(ActionEvent e)


{
System.out.println("\nMain_actionPerformed(ActionEvent e)
called.");
}

private void Close_actionPerformed(ActionEvent e)


{
System.out.println("\n Receiver
Close_actionPerformed(ActionEvent e) called.");
System.exit(0);
}

public void SetText(String packets,String traceback)


{
iPTB=traceback;//--
TA.setText(packets);

//JOptionPane.showMessageDialog((Component) null,"The
IPTraceback for this packet is : "+traceback,"Click
OK",JOptionPane.INFORMATION_MESSAGE);
}

/****************************************************************/
/* PPMSender */
/* */
/****************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.Random;

/**
* Summary description for PPMSender
*
*/
public class PPMSender extends JFrame
{
// Variables declaration
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4;
private JLabel jLabel5;
private JTextField Destinations;
private JTextField TxtFile;
private JTextArea TA;
private JScrollPane jScrollPane1;
private JButton Browse;
private JButton Send,Clear,Main,Close;
private JPanel contentPane;
// End of variables declaration
String fname="";
String nexthost="",sender="";

public PPMSender(String source)


{
super();
sender=source;
initializeComponent();
//
// TODO: Add any constructor code after initializeComponent call
//

this.setVisible(true);

}
public PPMSender()
{
super();
initializeComponent();
//
// TODO: Add any constructor code after initializeComponent call
//

this.setVisible(true);

}
public void setSource(String source)
{
sender=source;
System.out.println("sender"+sender);
}
/**
* 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
* to retrieve your design properly in future, before revising this method.
*/
private void initializeComponent()
{
//setSource("B");
jLabel2 = new JLabel();
jLabel3 = new JLabel();
jLabel4 = new JLabel();
jLabel5 = new JLabel();
Destinations = new JTextField();
TxtFile = new JTextField();
TA = new JTextArea();
jScrollPane1 = new JScrollPane();
Browse = new JButton();
Clear = new JButton();
Main = new JButton();
Send = new JButton();
Close = new JButton();
contentPane = (JPanel)this.getContentPane();

//
// jLabel2
//
jLabel2.setIcon(new ImageIcon("images\\desti.jpg"));
//
// jLabel3
//
jLabel3.setIcon(new ImageIcon("images\\file.jpg"));
//
// jLabel4
//
jLabel4.setIcon(new ImageIcon("images\\filetext.jpg"));
//
// jLabel5
//
jLabel5.setIcon(new ImageIcon("images\\103.jpg"));
//
// Destinations
//
Destinations.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Destinations_actionPerformed(e);
}

});
//
// TxtFile
//
TxtFile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
TxtFile_actionPerformed(e);
}

});
//
// TA
//
//
// jScrollPane1
//
jScrollPane1.setViewportView(TA);
//
// Browse
//
Browse.setText("Browse");
Browse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Browse_actionPerformed(e);
}

});
//
// Close
//
Send.setText("Send");
Send.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Send_actionPerformed(e);
}

});

Clear.setText("Clear");
Clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Clear_actionPerformed(e);
}

});

Main.setText("Main");
Main.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Main_actionPerformed(e);
}

});

Close.setText("Close");
Close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Close_actionPerformed(e);
}

});

//
// contentPane
//
contentPane.setLayout(null);
contentPane.setBackground(new Color(255, 255, 255));
addComponent(contentPane, jLabel2, 50,145,184,29);
addComponent(contentPane, jLabel3, 50,175,180,35);
addComponent(contentPane, jLabel4, 21,221,187,33);

addComponent(contentPane, Destinations, 235,144,155,26);


addComponent(contentPane, TxtFile, 235,175,155,27);
addComponent(contentPane, jScrollPane1, 167,257,334,190);
addComponent(contentPane, Browse, 405,175,83,25);
addComponent(contentPane, Send, 140,461,83,28);
addComponent(contentPane, Clear, 235,461,83,28);
addComponent(contentPane, Main, 330,461,83,28);
addComponent(contentPane, Close, 425,461,83,28);
addComponent(contentPane, jLabel5, -2,-2,888,768);
//
// PPMSender
//
this.setTitle(sender+" Node Sender");
this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(524, 539));
}

/** Add Component Without a Layout Manager (Absolute Positioning) */


private void addComponent(Container container,Component c,int x,int
y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}

//
// TODO: Add any appropriate code in the following Event Handling
Methods
//
private void Destinations_actionPerformed(ActionEvent e)
{
System.out.println("\nDestinations_actionPerformed(ActionEvent
e) called.");
// TODO: Add any handling code here

private void TxtFile_actionPerformed(ActionEvent e)


{
System.out.println("\nTxtFile_actionPerformed(ActionEvent e)
called.");
// TODO: Add any handling code here

private void Browse_actionPerformed(ActionEvent e)


{
System.out.println("\nBrowse_actionPerformed(ActionEvent e)
called.");
if((e.getSource())==Browse)
{
JFileChooser file=new JFileChooser();
int val=file.showOpenDialog(PPMSender.this);
if(val==JFileChooser.APPROVE_OPTION)
{
String fn=file.getSelectedFile().getName();
String fpath=file.getSelectedFile().getPath().toString();
if(fn.endsWith(".txt"))
{
TxtFile.setText(fpath);
}
else
{
JOptionPane.showMessageDialog((Component)
null,"Invalid File Format","Click OK",JOptionPane.INFORMATION_MESSAGE);
}

//fpath=file.getSelectedFile().getPath().toString();
}
}

private void Send_actionPerformed(ActionEvent e)


{
System.out.println("\nSend_actionPerformed(ActionEvent e)
called.");
fname=TxtFile.getText();
String temp="",str="",path="";
str=TA.getText();
System.out.println("fname : "+fname);
if((!fname.equals(""))||(!str.equals("")))
{
try
{
if(!fname.equals(""))
{
str="";
File f=new File(fname);
BufferedReader br=new
BufferedReader(new FileReader(f));
while((temp=br.readLine())!=null)
{
//System.out.println("LFile data :
"+temp);
str=str+"\n"+temp;
}
br.close();
}TA.setText(str);
System.out.println("File data : "+str);
InetAddress inet = InetAddress.getLocalHost();

String lhost = inet.getHostName();


System.out.println("Localhost"+lhost);
String dest=Destinations.getText();
System.out.println("Dest"+dest);
if(!lhost.equals(dest))
{
Socket ss=new
Socket("localhost",1880);//1680
//System.out.println("Dest"+dest);
if(true)
{
DataOutputStream dos=new
DataOutputStream(ss.getOutputStream());
DataInputStream dis=new
DataInputStream(ss.getInputStream());
dos.writeUTF("Path");
dos.writeUTF(sender);//lhost
dos.writeUTF(dest);
path=dis.readUTF();
System.out.println("Path : "+path);
}
SendPackets(str,path);
}
}catch (Exception ex){ex.printStackTrace();}
}
}

private void Clear_actionPerformed(ActionEvent e)


{
Destinations.setText("");
TxtFile.setText("");
TA.setText("");
}

private void Main_actionPerformed(ActionEvent e)


{
this.setVisible(false);
new PPMMain();
}

private void Close_actionPerformed(ActionEvent e)


{
//System.exit(0);
}

public void SendPackets(String data,String path)


{
try{
String pck="";
String[] paths=path.split("#");
Vector vnode=new Vector();
nexthost=paths[0];
String nextpaths="";
for(int i=1;i<paths.length;i++)
{
//System.out.println(paths[i]);
vnode.addElement(paths[i]);
nextpaths=nextpaths+paths[i]+"#";
}
//System.out.println("Vector : "+vnode);
System.out.println("Next Node to send : "+nexthost);
byte[] packets=data.getBytes();
int len=packets.length;
int packetsize=(len/48)+1;
Random generator = new Random();
int randomnum = generator.nextInt(packetsize);
nextpaths=nextpaths+packetsize+"@"+len+"@"+randomnum+"@";//
+"@"+path;
System.out.println( "nextpaths : "+nextpaths);//+" packet size :
"+packetsize+" len @ "+len+" randomnum@ "+randomnum);
SocketSend(nextpaths,"Header");

if(true)
{
if(len<=48)
{
pck=new String(packets,0,len);
SocketSend(pck,"Packet");
}
else
{
int start=0,end=48;
while(len>48)
{
System.out.println( "packet.length :
"+packets.length+" start : "+start+" end : "+(start+end));
pck=new String(packets,start,end);
SocketSend(pck,"Packet");
len=len-48;
start=start+48;
if(len<=48)
{
end=packets.length;
len=end-start;
System.out.println("len :"+len);
pck=new String(packets,start,len);
SocketSend(pck,"Packet");

}
}
}
}
}catch (Exception ex){ex.printStackTrace();}
}

public void SocketSend(String pck,String status)


{
try{

int port=0;
/////////////////////////////////////////////////////
if(nexthost.equals("A"))
{
port=1683;
}
if(nexthost.equals("B"))
{
port=1686;
}

if(nexthost.equals("C"))
{
port=1689;
}

if(nexthost.equals("D"))
{
port=1691;
}
if(nexthost.equals("E"))
{
port=1693;
}

////////////////////////////////////////////////////
Socket s=new Socket("localhost",port);
DataOutputStream dos=new
DataOutputStream(s.getOutputStream());
if(status.equals("Header"))
{
dos.writeUTF("Header");
dos.writeUTF(pck);
}
else
{
dos.writeUTF("Packets");
dos.writeUTF(pck);
}
}catch (Exception e){e.printStackTrace();}
}

public static void main(String[] args)


{
new PPMSender("C");

}
}

// try{
// String[] paths=path.split("#");
// Vector vnode=new Vector();
// String pck="";
// for(int i=0;i<paths.length;i++)
// {
// vnode.addElement(paths[i]);
// }
// byte[] packets=data.getBytes();
// String host=vnode.elementAt(0).toString();
// if(true)
// {
// int len=packets.length;
// if(len<=48)
// {
// System.out.println("Length less than 48");
// System.out.println("Start : 0 End : "+len);
// System.out.println("Pck Length : "+pck.length());
// pck="";
// pck=new String(packets,0,len);
// System.out.println("Pck Length : "+pck.length());
// SocketSend(pck);
// }
// else
// {
// int start=0,end=48;
// while(len>=48)
// {
// System.out.println("Length greater than 48");
// System.out.println("Start : "+start+" End : "+end);
// pck="";
// System.out.println("Pck Length : "+pck.length());
// pck=new String(packets,start,end);
// System.out.println("Pck Length : "+pck.length());
// SocketSend(pck);
// len=len-48;
// start=start+48;
// //end=end+48;
// if(len<=48)
// {
// System.out.println("Length less than 48
Final bytes");
// System.out.println("Start : "+start+" End :
"+packets.length);
// pck="";
// System.out.println("Pck Length :
"+pck.length());
// len=0;
// end=packets.length;
// len=end-start;
// System.out.println("len=len-start; : "+len);
// pck=new String(packets,start,len);
// System.out.println("Pck Length :
"+pck.length());
// SocketSend(pck);
// }
// }
// }
// }
// }catch (Exception ex){ex.printStackTrace();
}

/* ROUTER A*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.util.*;

public class RouterA


{
public ServerSocket ss;
public Socket s;
public String nexthost="",dest="",totalpack="",lhost="",traceback="";
public int packsize=0,bytesize=0,recsize=0,recbytesize=0,randomnum=0;
String traceBack="",extraPackets="";
int ep=0;
public RouterA()
{

LoginFrame A=new LoginFrame("A");


Server();
}
public void Server()
{
try{
InetAddress inet = InetAddress.getLocalHost();
lhost = inet.getHostName();
Vector nodes=new Vector();
ss=new ServerSocket(1683);
System.out.println("Router A is Running\n\n\n");
while(true)
{
//System.out.println("Router C is Running");
s=ss.accept();
DataInputStream dis=new
DataInputStream(s.getInputStream());
String sts=dis.readUTF();
if(sts.equals("Header"))
{
String header=dis.readUTF();
if(!header.equals(""))
{
System.out.println("Header Received
by A :"+header);
if(header.contains("#"))
{
String[]
paths=header.split("#");
nexthost=paths[0];
System.out.println("\n
Nextnode to send : "+nexthost);
String nextpaths="";
//System.out.println("Paths :
"+paths.length);

if(paths.length>2)
{
for(int
i=1;i<paths.length;i++)
{

System.out.print("=>"+paths[i]);

nodes.addElement(paths[i]);

nextpaths=nextpaths+paths[i];
if (i!
=paths.length-1)

nextpaths+="#";
}

System.out.println("Paths : "+nodes);
}
else
{
String[]
pack=header.split("#");
nextpaths=pack[1];
}
nextpaths+=">A";
System.out.println("\n Header
Send to B :"+nextpaths);

SocketSend(nextpaths,"Header");
}
else
{
System.out.println("----
Destination-----");
System.out.println("TraceBack
info :"+header);
String[]
pack=header.split("@");

packsize=Integer.parseInt(pack[0]);

bytesize=Integer.parseInt(pack[1]);

randomnum=Integer.parseInt(pack[2]);
traceBack=pack[3];
System.out.println("Received
Packet Size :"+packsize);
System.out.println("Received
Byte Size :"+bytesize);
System.out.println("Received
Random Num:"+randomnum);
System.out.println("Trace
Back :"+traceBack);
nexthost="";
}
}
else
{
nexthost="";
}

}
else
{
String packets=dis.readUTF();
System.out.println("Received Packets... ");
if(nexthost.equals(""))
{
++recsize;//=recsize+1;
if(true)//recsize==randomnum)
{
String[]
rp=packets.split("@");
packets="";
packets=rp[0];
System.out.println("IP
Traceback");
traceback="";
for(int i=1;i<rp.length;i++)
{
//System.out.prin
t("-> ");
//System.out.prin
t(rp[i]);

traceback=traceback+">"+rp[i];
}

System.out.println(recsize+". Packet tracBack:"+traceback);


}

System.out.println("tb"+traceback+"tB"+traceBack);
if(traceback.equals(traceBack))
{
System.out.println("Both are
same");
totalpack=totalpack+packets;
System.out.println(packets);
}
else
{

//JOptionPane.showMessageDialog((Component) null,"Extra packets are received from


different path...\n"+traceback,"Click
OK",JOptionPane.INFORMATION_MESSAGE);
System.out.println("Both are not
same");
extraPackets +=packets;
--recsize;
++ep;
}
if(packsize==recsize)
{
PPMReceiver ppm=new
PPMReceiver("A");
String tb=traceback+"A";
ppm.SetText(totalpack,tb);

byte[] bs=packets.getBytes();
//recbytesize=recbytesize+bs.le
ngth;
byte[] tbs=totalpack.getBytes();
recbytesize=tbs.length;
System.out.println("----Full
Packet Received-----");
System.out.println("recbytesize : "+recbytesize+" bytesize : "+bytesize);
System.out.println("Extra
packets :"+extraPackets);
if(extraPackets.length()>0)
{

System.out.println(ep+"Extra packets are received from different path...");


String msg
=ep+" :Extra packets are received from different path...";

JOptionPane.showMessageDialog((Component) null,msg,"Click
OK",JOptionPane.INFORMATION_MESSAGE);
}

if(recbytesize==bytesize)
{

System.out.println("Bytes are matched");


}
else
{
if(recbytesize>bytesize)
{

System.out.println("Extra Bytes are added with received data...");

JOptionPane.showMessageDialog((Component) null,"Extra Bytes are added


with received data...","Click OK",JOptionPane.INFORMATION_MESSAGE);
}
else
{

System.out.println("Missing some Bytes in received data...");

JOptionPane.showMessageDialog((Component) null,"Missing some Bytes in


received data...","Click OK",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
else
{

packets=packets+"@"+"A";//packets=packets+"@"+lhost;
Random r=new Random();
int rn=r.nextInt(10);
System.out.println("random
number :"+rn);
if(rn>8)
{
String str="these are extra
Packets that its added by A router its a DOS packet";
SocketSend(str,"Packet");
}
//packets=packets+"a"; //adding extra
packets with received packet
//Removing some of the packets from
received packets
//byte[] ps=packets.getBytes();
//packets="";
//String temp=new
String(ps,0,ps.length-2);
//packets=temp;
//Removed
//System.out.println("pck from A to
B"+packets);
SocketSend(packets,"Packet");
}
}
}
}catch (Exception e){e.printStackTrace();}

public void SocketSend(String pck,String status)


{
try{

int port=0;
/////////////////////////////////////////////////////

if(nexthost.equals("B"))
{
port=1686;
}

if(nexthost.equals("C"))
{
port=1689;
}

if(nexthost.equals("D"))
{
port=1691;
}
if(nexthost.equals("E"))
{
port=1693;
}

////////////////////////////////////////////////////
Socket s=new Socket("localhost",port);
DataOutputStream dos=new
DataOutputStream(s.getOutputStream());
if(status.equals("Header"))
{
dos.writeUTF("Header");
dos.writeUTF(pck);
}
else
{
dos.writeUTF("Packets");
dos.writeUTF(pck);
}
}catch (Exception e){e.printStackTrace();}
}

public static void main(String[] args)


{
new RouterA();
}
}

/*import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class RouterA
{
public ServerSocket ss;
public Socket s;
public String nexthost="",dest="",totalpack="",lhost="",traceback="";
public int packsize=0,bytesize=0,recsize=0,recbytesize=0,randomnum=0;
public RouterA()
{
Server();
}
public void Server()
{
try{
InetAddress inet = InetAddress.getLocalHost();
lhost = inet.getHostName();
Vector nodes=new Vector();
ss=new ServerSocket(1683);
System.out.println("Router A is Running \n\n\n");
while(true)
{

s=ss.accept();
DataInputStream dis=new
DataInputStream(s.getInputStream());
String sts=dis.readUTF();
if(sts.equals("Header"))
{
String header=dis.readUTF();
System.out.println("Header Received by A :
"+header);
String[] paths=header.split("#");
nexthost=paths[0];
System.out.println("Nextnode to send :
"+nexthost);
String nextpaths="";
//System.out.println("Paths :
"+paths.length);
if(paths.length>2)
{
for(int i=1;i<paths.length;i++)
{

System.out.print("=>"+paths[i]);

nodes.addElement(paths[i]);

nextpaths=nextpaths+paths[i];
if (i!
=paths.length-1)
nextpaths+="#";
}

//System.out.println("\n Vector
: Next nodes : "+nodes);
}
else
{
String[]
pack=header.split("#");
nextpaths=pack[1];
}
nextpaths+=">A";
System.out.println("\nHeader Send to B :"+nextpaths);
SocketSend(nextpaths,"Header");

}
else
{
String packets=dis.readUTF();
System.out.println("Received Packets... ");

if(recsize==randomnum)
{

packets=packets+"@"+"A";//packets=packets+"@"+lhost;
}

SocketSend(packets,"Packet");

}
}
}catch (Exception e){e.printStackTrace();}

public void SocketSend(String pck,String status)


{
try{

int port=0;
/////////////////////////////////////////////////////

if(nexthost.equals("B"))
{
port=1686;
}

if(nexthost.equals("C"))
{
port=1689;
}

if(nexthost.equals("D"))
{
port=1691;
}

////////////////////////////////////////////////////
Socket s=new Socket("localhost",port);
DataOutputStream dos=new
DataOutputStream(s.getOutputStream());
if(status.equals("Header"))
{
dos.writeUTF("Header");
dos.writeUTF(pck);
}
else
{
dos.writeUTF("Packets");
dos.writeUTF(pck);
}
}catch (Exception e){e.printStackTrace();}
}

public static void main(String[] args)


{
new RouterA();
}
}
*/

11. BIBLIOGRAPHY
Good Teachers are worth more than thousand books, we have them in
Our Department

References Made From:

[1] ”CERT Advisory CA-2000-01: Denial-of-Service Developments,” Computer Emergency


Response Team, http://www.cert.org/- advisories/-CA-2000-01.html, 2006.

[2] J. Ioannidis and S.M. Bellovin, “Implementing Pushback: Router- Based Defense against
DDoS Attacks,” Proc. Network and Distributed System Security Symp., pp. 100-108, Feb.
2002.

[3] S. Bellovin, M. Leech, and T. Taylor, ICMP Traceback Messages, Internet Draft Draft-
Bellovin-Itrace-04.txt, Feb. 2003.

[4] K. Park and H. Lee, “On the Effectiveness of Route-Based Packet Filtering for
Distributed DoS Attack Prevention in Power-Law Internets,” Proc. ACM SIGCOMM ’01,
pp. 15-26, 2001.

[5] P. Ferguson and D. Senie, “RFC 2267: Network Ingress Filtering: Defeating Denial of
Service Attacks Which Employ IP Source Address Spoofing,” The Internet Soc., Jan. 1998.

[6] D.K.Y. Yau, J.C.S. Lui, F. Liang, and Y. Yam, “Defending againstDistributed Denial-of-
Service Attacks with Max-Min Fair Server-Centric Router Throttles,” IEEE/ACM Trans.
Networking, no. 1,pp. 29-42, 2005.

[7] C.W. Tan, D.M. Chiu, J.C. Lui, and D.K.Y. Yau, “A Distributed Throttling Approach for
Handling High-Bandwidth Aggregates,” IEEE Trans. Parallel and Distributed Systems, vol.
18, no. 7, pp. 983- 995, July 2007.

[8] S. Savage, D. Wetherall, A. Karlin, and T. Anderson, “Practical Network Support for IP
Traceback,” Proc. ACM SIGCOMM ’00, pp. 295-306, 2000.

[9] D. Dean, M. Franklin, and A. Stubblefield, “An Algebraic Approach to IP Traceback,”


ACM Trans. Information and System Security, vol. 5, no. 2, pp. 119-137, 2002.

[10] D.X. Song and A. Perrig, “Advanced and Authenticated Marking Schemes for IP
Traceback,” Proc. IEEE INFOCOM ’01, pp. 878-886, Apr. 2001.

Potrebbero piacerti anche