hello, please i make a code that i want it to work as follows:
the user input 3 value and after an inspection(that i am not put it now, i want to try it now so i make the condition, if k%2==0)the input is be either spoof or valed,at the begining the state is alert, then i compute the (th)it is a threshold value, so if it is spoof and the th is less than T1 the o/p is accept, and still that(when the user enter other 3 values) untill the th be larger than T1 and then it is switch to the action state and the o/p is (if it is spoof the o/p is drop and if it is not spoof the o/p is forword)and still that (when the user enter other 3 values) until the th is less than T2
so i do my best and write that code but it's o/p is not like that i want, please can u do any help for me,
thank u very much in advance
import java.io.*;
import java.*;
import java.util.*;
import java.lang.*;
public class IP2HC_Inspect{
//instanceof ttt= new table;
public static void main(String[] args) {
int totalpkt=0,k=0,th=0,spoofpkt=0;
double T1=0.3,T2=0.7;
boolean done=true,spoof=false,sw1=true,sw2=false;
do{
System.out.println(" \n Enter your packet that contain a valid IP Add with the field of the TTL and the connection type \n ");
++totalpkt;
Scanner keyboard = new Scanner(System.in);
System.out.println("ip is");
String IP = keyboard.nextLine();
System.out.println("ttl is");
String TTL = keyboard.nextLine();
System.out.println("conn is");
String conntype = keyboard.nextLine();
if (conntype.equalsIgnoreCase("TCP"))
++k;
//int x = Integer.parseInt( scanner.nextLine() );DIC
int T=Integer.parseInt(TTL);
//long ss = IpConvert.ipToLong(IP);
//int s=Integer.parseInt(IP);
int T0=0,Hc;
if(T<=32)
T0=32;
else if(T>32 && T<=64)
T0=64;
else if(T>64 && T<=128)
T0=128;
else if(T>128 && T<=255)
T0=255;
System.out.println("T0 is "+T0);
Hc=T0-T;
System.out.println("Hc is "+Hc);
long s=IpConvert.ipToLong(IP);
System.out.println("ip in long is "+s);
System.out.println("totalpkt is "+totalpkt);
System.out.println("k is "+k);
if(k%2==0)
{spoof=true;
++spoofpkt;
System.out.println("spoof is "+spoof+" spoofpkt is "+spoofpkt);
}else
System.out.println("ligtmate");
th=spoofpkt/totalpkt;
System.out.println("th is "+th);
if (sw1)
{
if(th<T1)
{System.out.println("alert state");
System.out.println("pkt accepted");}
if(spoof && th>T1)
{sw2=true;
sw1=false;
}
if (sw2){
System.out.println("action state");
if (spoof && th>T1)
System.out.println("pkt is droped");
else if (!spoof && th>T1)
System.out.println("pkt in action is forword");
else if(!spoof && th<T2)
{System.out.println("back to alert");
sw1=true;sw2=false;
}
}
//if (k==10)
//break;
}
}while(done);
best regards