Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package tools.sniffer;
 
 import java.io.*;
 import java.util.*;
Code to convert Ethereal frames to the XML format that the trace viewer application likes.

Author(s):
Tim Bardzil <bardzil@colorado.edu>. Acknowledgement: This code was contributed by Tim Bardzil <bardzil@colorado.edu>. This code was completed as part of a class project in TLEN 5843 Singaling Protocols, taught by Professor Douglas C. Sicker, Ph.D. at the University of Colorado, Boulder. Minor modifications to the code were made by M. Ranganathan .
public class SniffFileParser {
    public SniffFileParser(String messageFile) {
        String buffer = new String();
        ArrayList sniffMsgList;
         = new SniffSessionList();
        try {
            BufferedReader in = new BufferedReader(new FileReader(messageFile));
            buffer = in.readLine();
            while (buffer != null) { //read until EOF
                sniffMsgList = new ArrayList();
                while (buffer != null
                    && buffer.length() > 0) { //read one frame
                    sniffMsgList.add(buffer.trim());
                    buffer = in.readLine();
                }
                SniffMessage sniffMsg = new SniffMessage(sniffMsgList);
                .add(sniffMsg);
                buffer = in.readLine();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
        return ;
    }

    
The main entry point.

Parameters:
args is the argument file. args[0] is the Ethereral packet sniffer output to convert to the format that the trace viewer likes.
    public static void main(String args[]) {
        String fileName = args[0];
        . = fileName;
        if (args[0] == null) {
            ..println("Please specify sniffer file");
            ..println("Bailing Out!");
            System.exit(0);
        }
        SniffFileParser sfp = new SniffFileParser(args[0]);
        SniffSessionList sniffSessions = sfp.getSniffSessionList();
        //String[] sessionNames = sniffSessions.getCallIds();
        LogFileParser parser = new LogFileParser();
        Hashtable traces = parser.parseLogsFromString(sniffSessions.toXML());
        new TracesViewer(tracesfileName"Ethereal Sniffer Trace"null)
            .show();
    }
New to GrepCode? Check out our FAQ X