Ver código fonte

feat : create newNode

master
우인혜 6 anos atrás
pai
commit
15f2ee3097

+ 18
- 3
src/main/java/com/mycompany/app/App.java Ver arquivo

@@ -30,6 +30,8 @@ public class App {
30 30
                 JSONObject jsonObject = new JSONObject();
31 31
                 Node node = new Node();
32 32
                 Packet packet = new Packet();
33
+                Nips destinationAssign = new Nips();
34
+                Eips sourceAssign = new Eips();
33 35
                 try {
34 36
                     jsonObject = (JSONObject) jsonParser.parse(line);
35 37
 
@@ -54,10 +56,23 @@ public class App {
54 56
                     try {
55 57
                         //  Create newNode When probe new IP
56 58
                         Node newNode = node.getClass().newInstance();
57
-                        newNode.eip = (String)newPacket.eip;  //    Insert "eip" in newNode
58
-                        newNode.
59
-                        networkNode.add(newNode);
59
+                        Eips newSource = sourceAssign.getClass().newInstance();
60
+                        Nips newDest = destinationAssign.getClass().newInstance();
60 61
                         
62
+                        //  Insert node value
63
+                        newSource.setSourceIp(newPacket.eip);
64
+                        newSource.setSourcePort(newPacket.eport);
65
+                        newDest.setDestIp(newPacket.nip);
66
+                        newDest.setDestPort(newPacket.nport);
67
+                        newNode.ip = newSource.getSourceIp();
68
+                        //  Insert source & destination address
69
+                        newNode.source.add(newSource);
70
+                        newNode.destination.add(newDest);
71
+                        //  sum packet & byte
72
+                        newNode.sumPkt(newPacket.out_pkt);
73
+                        newNode.sumByte(newPacket.out_byte);
74
+                        //  Insert newNode
75
+                        networkNode.add(newNode);
61 76
                     } catch (InstantiationException e) {
62 77
 
63 78
                     } catch (IllegalAccessException e) {

+ 2
- 2
src/main/java/com/mycompany/app/Nips.java Ver arquivo

@@ -8,10 +8,10 @@ class Nips{
8 8
     int getDestPort(){
9 9
         return port;
10 10
     }
11
-    void SetDestIp(Object obj){
11
+    void setDestIp(Object obj){
12 12
         ip = (String)obj;
13 13
     }
14
-    void SetDestPort(Object obj){
14
+    void setDestPort(Object obj){
15 15
         port = (int)obj;
16 16
     }
17 17
 }

+ 11
- 33
src/main/java/com/mycompany/app/Node.java Ver arquivo

@@ -3,45 +3,23 @@ package com.mycompany.app;
3 3
 import java.util.Vector;
4 4
 
5 5
 class Node {
6
-    class Eips{
7
-        String ip = eip;
8
-        int port;
9
-        String getSourceIp(){
10
-            return ip;
11
-        }
12
-        int getSourcePort(){
13
-            return port;
14
-        }
15
-        void setSourcePort(int num){
16
-            port = num;
17
-        }
18
-    }
19
-    class Nips{
20
-        String ip;
21
-        int port;
22
-        String getDestIp(){
23
-            return ip;
24
-        }
25
-        int getDestPort(){
26
-            return port;
27
-        }
28
-        void SetDestIp(String str){
29
-            ip = str;
30
-        }
31
-        void SetDestPort(int num){
32
-            port = num;
33
-        }
34
-    }
35 6
     Vector<Eips> source;
36 7
     Vector<Nips> destination; 
37
-    String eip; //  ip
8
+    String ip; //  ip
38 9
 
39
-    double vulnerability;   //  inbound value
10
+    double vulnerability = 1/30;   //  inbound value
40 11
     double aggression;      //  outbound value
41 12
     double co_efficient;
42 13
 
43
-    long total_pkt;
44
-    long total_bytes;
14
+    long total_pkt = 0;
15
+    long total_bytes = 0;
45 16
 
46 17
     Integer total_port_counts;
18
+
19
+    long sumPkt(Object obj){
20
+        return total_pkt + (long)obj;
21
+    }
22
+    long sumByte(Object obj){
23
+        return total_bytes + (long)obj;
24
+    }
47 25
 }

BIN
target/classes/com/mycompany/app/App.class Ver arquivo


BIN
target/classes/com/mycompany/app/Nips.class Ver arquivo


BIN
target/classes/com/mycompany/app/Node$Eips.class Ver arquivo


BIN
target/classes/com/mycompany/app/Node$Nips.class Ver arquivo


BIN
target/classes/com/mycompany/app/Node.class Ver arquivo


Carregando…
Cancelar
Salvar