⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v9_packet.java

📁 接收网络设备上NetFlow工具导出的NetFlow数据
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        V5_Flow f;
                        try {
                            f = new V5_Flow(RouterIP, buf, p, tOfData);
                            flows.add(f); // 加入到Vector中,所有归并就可以起作用了
                        } catch (DoneException e) {
                            if (Params.DEBUG) {
                                e.printStackTrace();
                            }
                            if ((e.toString() != null)
                                && (!e.toString().equals(""))) {
                                if (e.toString().startsWith("savePacket")) {
                                    try {
                                        ObjectOutputStream fOut;
                                        fOut = new ObjectOutputStream(new
                                                FileOutputStream("./" +
                                                e.toString() + ".cache.tmp"));
                                        fOut.writeObject(buf);
                                        fOut.writeObject(new Integer(len));
                                        fOut.flush();
                                        fOut.close();
                                        System.err.println("Saved ");
                                    } catch (FileNotFoundException e2) {
                                        e2.printStackTrace();
                                    } catch (IOException e1) {
                                        e1.printStackTrace();
                                    }
                                } else {
                                    System.err.println(e.toString());
                                }
                            }
                        }
                    }
                } else { //options packet, should refer to option template, not in use now
                    continue;
//                    OptionTemplate otOfData = OptionTemplateManager
//                                              .getOptionTemplateManager().
//                                              getOptionTemplate(
//                            this.routerIP, (int) flowsetId);
//                    if (otOfData != null) {
//                        int dataRecordLen = otOfData.getTypeOffset( -1); // 每个流记录的长度
//                        // packetOffset+4 让出flowsetId 和 length空间
//                        for (int idx = 0, p = packetOffset + 4; p
//                                              - packetOffset < flowsetLength;
//                                              idx++, p += dataRecordLen) {
//                            OptionFlow of;
//                            try {
//                                of = new OptionFlow(RouterIP, buf, p, otOfData);
////                                optionFlows.add(of); // 加入到Vector中,所有归并就可以起作用了
//                            } catch (DoneException e) {
//                                if (Params.DEBUG) {
//                                    e.printStackTrace();
//                                }
//                                System.err.println(e.toString());
//                            }
//                        }
//                    } else {
//                        System.err.println(this.routerIP + "的" + flowsetId
//                                           + "是一个不能识别的template号");
//                    }
                }
            }
        }
    }

    protected static String add_raw_sql = null;

    public void process_raw(SQL sql) {
        if (add_raw_sql == null) {
            add_raw_sql = SQL.resources.getAndTrim("SQL.Add.RawV9");
        }

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            ((V5_Flow) flowenum.nextElement()).save_raw4v9(SysUptime,
                    unix_secs, packageSequence, sourceId, sql.prepareStatement(
                            "Prepare INSERT to V9 raw table", add_raw_sql));
        }
        for (Enumeration oflowenum = optionFlows.elements(); oflowenum
                                     .hasMoreElements(); ) {
            ((OptionFlow) oflowenum.nextElement()).save_raw(SysUptime,
                    unix_secs, packageSequence, sourceId, sql.prepareStatement(
                            "Prepare INSERT to Option table", SQL.resources
                            .getAndTrim("SQL.Add.OptionsTable")));
        }
    }

    public Vector getSrcASVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataSrcAS());
        }

        return v;
    }

    public Vector getDstASVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataDstAS());
        }

        return v;
    }

    public Vector getASMatrixVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataASMatrix());
        }

        return v;
    }

    public Vector getSrcNodeVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataSrcNode());
        }

        return v;
    }

    public Vector getDstNodeVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataDstNode());
        }

        return v;
    }

    public Vector getHostMatrixVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataHostMatrix());
        }

        return v;
    }

    public Vector getSrcInterfaceVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataSrcInterface());
        }

        return v;
    }

    public Vector getDstInterfaceVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataDstInterface());
        }

        return v;
    }

    public Vector getInterfaceMatrixVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataInterfaceMatrix());
        }

        return v;
    }

    public Vector getSrcPrefixVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            Scheme_DataPrefix pfx = ((V5_Flow) flowenum.nextElement())
                                    .getDataSrcPrefix();
            if (pfx != null) {
                v.add(pfx);
            }
        }

        return v;
    }

    public Vector getDstPrefixVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            Scheme_DataPrefix dpfx = ((V5_Flow) flowenum.nextElement())
                                     .getDataDstPrefix();
            if (dpfx != null) {
                v.add(dpfx);
            }
        }
        return v;
    }

    public Vector getPrefixMatrixVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataPrefixMatrix());
        }

        return v;
    }

    public Vector getProtocolVector() {
        Vector v = new Vector((int) count, (int) count);

        for (Enumeration flowenum = flows.elements(); flowenum
                                    .hasMoreElements(); ) {
            v.add(((V5_Flow) flowenum.nextElement()).getDataProtocol());
        }

        return v;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -