Loading...
Logo
Processing Forum
joshbillions's Profile
1 Posts
1 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    Hi everyone. 

    I'm working on a sketch to build a set of 3D objects based off information gathered from tcpdump. I've setup a class called 'packet' that contains the source, destination, and protocol of each packet I've captured. All of the packet objects are stored in an array.

    I would like to have the sketch walk through this array and group packet objects that have matching source strings together with hopes of drawing cubes for each source in a similar x, y, z space.

    My code is a mess, I'm a bit frustrated, and I feel like I need a fresh perspective on the problem.

    Here's the code with different attempts commented out:

    CSV File "csv":
    1. "1","0.000000","10.73.30.223","255.255.255.255","DB-LSP-DISC","Dropbox LAN sync Discovery Protocol"
    2. "2","0.000354","10.73.30.223","10.73.31.255","DB-LSP-DISC","Dropbox LAN sync Discovery Protocol"
    3. "3","0.072580","184.50.45.206","10.73.27.148","TCP","[TCP segment of a reassembled PDU]"
    4. "4","0.072807","184.50.45.206","10.73.27.148","TCP","[TCP segment of a reassembled PDU]"
    5. "5","0.073097","184.50.45.206","10.73.27.148","TCP","[TCP segment of a reassembled PDU]"


    1. boolean firstRun = true;
    2. boolean debug = true;

    3. String[] csvStrings;
    4. ArrayList packetZones;
    5. ArrayList knownSource;
    6. ArrayList knownDest;
    7. Packet[] packetArray;

    8. int mC = 0; //Master Counter



    9. void setup() {
    10.   size(1280,720, P3D);
    11.   scene = new Scene(this);

    12.   csvStrings = loadStrings("csv");
    13.   packetArray = new Packet[csvStrings.length];
    14.   knownSource = new ArrayList();
    15.   packetZones = new ArrayList();

    16.   knownSource.add("127.0.0.1"); //Go ahead and add localhost as filler

    17.   if(debug) println("Setting up packet objects");
    18.   for(int i=0; i < csvStrings.length; i++) {
    19.     String[] pieces = split(csvStrings[i], ',');
    20.     packetArray[i] = new Packet(pieces);
    21.   }
    22. }

    23. void draw() {
    24.   for(int i=0; i < packetArray.length; i++){
    25.     String currSource = packetArray[i].source;
    26.     for(int j=i; j < packetArray.length; j++){
    27.       if(currSource.equals(packetArray[j].source){
    28.       //STOPPED HERE OUT OF FRUSTRATION/SLEEP DEPRIVATION
    29.       //AND THE HEAVENS DID RUMBLE WITH OUR LORD'S KEEN DISPLEASURE
    30. }


    31. //  while(mC < csvStrings.length) {
    32. //    String[] pieces = split(csvStrings[mC], ',');
    33. //    packetArray[mC] = new Packet(pieces);
    34. //    if(firstRun) {
    35. //      knownSource.add(packetArray[mC].source);
    36. //      packetArray[mC].zoned = true;
    37. //      firstRun = false;
    38. //      if(debug) println("First run completed.");
    39. //    }
    40. //    for(int i=0; i < packetArray.length; i++) {
    41. //      for(int j=0; j < knownSource.size(); j++) {
    42. //        String currSource = (String) knownSource.get(j);
    43. //        if(!packetArray[i].source.equals(currSource) && packetArray[i].zoned != true) {
    44. //          knownSource.add(packetArray[mC].source);
    45. //          packetArray[i].zoned = true;
    46. //          if(debug) {
    47. //            println("Added unknown source: " + packetArray[mC].source);
    48. //            println("# known sources: " + knownSource.size());
    49. //            println(packetArray[mC].zoned);
    50. //          }
    51. //        }
    52. //      }
    53. //    }
    54. //    mC++;
    55. //  }
    56. //  if(debug) println("while() loop finished inside of draw()");

    57. //    String[] pieces = split(csvStrings[mC], ',');
    58. //    packetArray[mC] = new Packet(pieces);
    59. //    for(int i=0; i < knownSource.size(); i++) {
    60. //      if(packetArray[mC].source.equals(knownSource.get(i))) {
    61. //        packetArray[mC].singular = false;
    62. //        knownSource.add(packetArray[mC].source);
    63. //      }else if(!packetArray[mC].source.equals(knownSource.get(i))){
    64. //        packetArray[mC].singular = true;
    65. //      }
    66. //      println(packetArray[mC].singular);
    67. //      println(knownSource.size());
    68. //      println(knownSource);
    69. //      mC++;
    70. //    }


    71. //void drawBoxes() {
    72. //  int counter = 0;
    73. //  for(int i=0; i < recordCount; i++) {
    74. //    for(int j=0; j < recordCount; j++) {
    75. //      if(dumpRecords[i].source.equals("\"10.73.27.148\"")) {
    76. //        
    77. //      }
    78. //    }
    79. //    if(counter > 0) {
    80. //      println(dumpRecords[i].source + " matches: " + counter);
    81. //      counter = 0;
    82. //    }
    83. //  }
    84. //  firstRun = false;
    85. //}

    86. //  for(int i=0; i < csvStrings.length; i++) {
    87. //    String[] pieces = split(csvStrings[i], ',');
    88. //    dumpRecords[recordCount] = new Record(pieces);
    89. //    recordCount++;
    90. //  }




    91. class Packet {
    92.   boolean singular;
    93.   boolean zoned = false;
    94.   String number;
    95.   String time;
    96.   String source;
    97.   String dest;
    98.   String protocol;
    99.   String info;
    100.   int xPos;
    101.   int yPos;
    102.   int zPos;
    103.   
    104.   public Packet(String[] dumpLine){
    105.     number = dumpLine[0];
    106.     time = dumpLine[1];
    107.     source = dumpLine[2];
    108.     dest = dumpLine[3];
    109.     protocol = dumpLine[4];
    110.     info = dumpLine[5];
    111.   }
    112.   
    113.   public void setPosition(int x, int y, int z){
    114.     xPos = x;
    115.     yPos = y;
    116.     zPos = z;
    117.   }
    118. }




    119. class PacketZone {
    120.   boolean sourceZone = false;
    121.   boolean destZone = false;
    122.   boolean undefined = true;
    123.   
    124.   String name;
    125.   String source;
    126.   String dest;
    127.   int xMin;
    128.   int yMin;
    129.   int zMin;
    130.   int xArea;
    131.   int yArea;
    132.   int zArea;
    133.   
    134.   public PacketZone(String passedName, int minx, int x, int miny, int y, int minz, int z){
    135.     name = passedName;
    136.     xMin = minx;
    137.     yMin = miny;
    138.     zMin = minz;
    139.     xArea = x;
    140.     yArea = y;
    141.     zArea = z;
    142.   }
    143.   
    144.   public void setSource(String thisSource){
    145.     source = thisSource;
    146.     sourceZone = true;
    147.     undefined = false;
    148.     if(destZone){
    149.       println("WHOA whoa whoa. I was a destZone!");
    150.     }
    151.   }
    152.   
    153.   public void setDest(String destination){
    154.     dest = destination;
    155.     destZone = true;
    156.     undefined = false;
    157.     if(sourceZone){
    158.       println("WHOA whoa whoa. I was a sourceZone!");
    159.     }
    160.   }
    161. }