Start line:  
End line:  

Snippet Preview

Snippet HTML Code

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

Tim Bardzil <>. Acknowledgement: This code was contributed by Tim Bardzil <>. 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
                    buffer = in.readLine();
                SniffMessage sniffMsg = new SniffMessage(sniffMsgList);
                buffer = in.readLine();
        } catch (Exception e) {
        return ;

The main entry point.

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!");
        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)
New to GrepCode? Check out our FAQ X