Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
11. BIBLIOGRAPHY
12. APPENDICES
APPENDIX A: SAMPLE SCREENS
Disadvantages:
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:
Ram : 128Mb.
Java Technology
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.
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.
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.
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
IP datagram’s
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
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
Port addresses
Sockets
#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
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:
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.
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:
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:
FUNCTIONAL TESTING:
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 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.
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 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.
Test Results: All the test cases mentioned above passed successfully. No
defects encountered.
Test Results: All the test cases mentioned above passed successfully. No
defects encountered.
SYSTEM IMPLEMENTATION
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.
/* 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();
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;
}
findnode1.addElement(findnode.elementAt(i).toString());
}
PathTraverse(findnode1);
PathTraverse(findnode);
}catch (Exception e) { e.printStackTrace();}
}
path=path+fn.elementAt(j).toString()+"#";
dest=fn.elementAt(j).toString();
if(!source.equals(dest))
try
{
//System.out.println("In
serted s"+source+"d"+dest+"p"+path);
}catch (Exception e)
{ e.printStackTrace();}
}
fn.removeElementAt(i);
vsize=fn.size();
}
}
/****************************************************************/
/* 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);
//
// 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
System.out.println("\njPasswordField1_actionPerformed(ActionEvent e)
called.");
// TODO: Add any handling code here
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));
//JOptionPane.showMessageDialog((Component) null,"The
IPTraceback for this packet is : "+iPTB,"Click
OK",JOptionPane.INFORMATION_MESSAGE);//--
TraceBackGraph tbc=new TraceBackGraph();
tbc.constructGraph(iPTB);
}
//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="";
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);
//
// 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
//fpath=file.getSelectedFile().getPath().toString();
}
}
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();}
}
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();}
}
}
}
// 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.*;
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("tb"+traceback+"tB"+traceBack);
if(traceback.equals(traceBack))
{
System.out.println("Both are
same");
totalpack=totalpack+packets;
System.out.println(packets);
}
else
{
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)
{
JOptionPane.showMessageDialog((Component) null,msg,"Click
OK",JOptionPane.INFORMATION_MESSAGE);
}
if(recbytesize==bytesize)
{
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();}
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();}
}
/*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();}
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();}
}
11. BIBLIOGRAPHY
Good Teachers are worth more than thousand books, we have them in
Our Department
[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.
[10] D.X. Song and A. Perrig, “Advanced and Authenticated Marking Schemes for IP
Traceback,” Proc. IEEE INFOCOM ’01, pp. 878-886, Apr. 2001.