Page 1 of 2 12 LastLast
Results 1 to 20 of 27
  1. #1
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default how to read flow file ?

    hi all,
    i have a binary file that are flow version 5 data ,
    anyone can tell me how to print out the data by java ?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: how to read flow file ?

    Do you have documentation on the contents (byte by byte) of the file?
    Do you want to print out the contents of the bytes in hexidecimal?

    How does this relate to networking?

  3. #3
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi Norm,
    my file is netflow file, because the forum can't let me attach the file here ,
    because i want to parse the netflow record ,
    so how can i print out the contents of the netflow file ?

    thanks,

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: how to read flow file ?

    Do you have documentation on the contents (byte by byte) of the file?

    how can i print out the contents of the netflow file ?
    You could read it byte by byte and print out each byte in hexidecimal.

  5. #5
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    it 's netflow version 5 structure
    Netflow :: Version 5

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: how to read flow file ?

    If you know the layout of the file, then you should be able to write a java program to read the file and extract and print its contents.

  7. #7
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm,
    that's what i want . can you give me more hint about how to read the file and extract and print its ?
    can you give me an example code ?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: how to read flow file ?

    What is in the file? numbers, Strings or ???
    If you read the bytes of each record into a byte array, you can then pick out the bytes to build numbers or Strings.
    For numbers, use the shift operator to build the number. Load a byte into an int, shift it left 8 bits and add in the next byte, shift it left 8 bits and add in the next byte up to four bytes.
    For Strings, look at the String class's constructors. I think you can use a byte array with indexes into the array to say where the bytes for the String begin and end.

  9. #9
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm,
    i still can't print out the file ,can i send the file to you by email ?

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: how to read flow file ?

    Why do I need the file? Do you have a hex editor that you can view the contents of the file with?
    Here is what the contents of a text file in Unicode format starts with:
    FFFE 5400 6800 6900 7300 ...

    This was created on Windows with WordPad using the Unicode text format option in the Save As dialog.

  11. #11
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm,
    actually, my problem is how to read the file by java ,
    it's two records of my file ,can you give me sample code for how to print out this to readable ?

    000000 11001111 00010000 00000001 00000011 01011000 00000000 00000000 00000000 00000010 00000000 00000010 00000000 00000101 00000000 00000110 00000000


    000010 00000100 00000000 11011101 10010110 11100110 01001011 00000111 00000000 00000100 00000000 00001000 10011000 11100110 01001011 00001000 00000000

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: how to read flow file ?

    Without knowing the format of the file that is going to be essentially meaningless gibberish.

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: how to read flow file ?

    how to print out this to readable
    What do the 0's and 1's in your post represent? The bits in the file?
    Why does the first group have 6 digits?

    If what you posted is supposed to be binary, the file does not contain ASCII text.

  14. #14
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm,
    it's netflow data , i get 0's and 1's is using binary viewer tool .
    it's should be represent like this :

    185.56.83.89 156.110.16.1 17 53037 53 72 1


    and for the seven column is
    srcIP dstIP prot srcPort dstPort octets packets

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: how to read flow file ?

    You need a byte by byte format for the contents of the file that describes what is in the file. When you have that you can decide the best way to convert the bytes in the file to the format that you want the data in.
    Are you trying to convert the data to a String?

  16. #16
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm,
    i have format the content for byte ,

    000000 207 016 001 003 088 000 000 000
    000008 002 000 002 000 005 000 006 000
    000010 004 000 221 150 230 075 007 000

    i want to convert the data to readable string like :
    185.56.83.89 156.110.16.1 17 53037 53 72 1


    it's can let me know the seven column value :
    srcIP dstIP prot srcPort dstPort octets packets

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: how to read flow file ?

    By format I mean a description of what is in each byte. For example
    In the first column is which bytes, the second column is its contents
    0-1 Message Id
    2-5 Count of items
    6-7 Item one id
    ...

  18. #18
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm ,

    Flow record format :

    Bytes Contents Description
    0-3 srcaddr Source IP address
    4-7 dstaddr Destination IP address
    8-11 nexthop IP address of next hop router
    12-13 input SNMP index of input interface
    14-15 output SNMP index of output interface
    16-19 dPkts Packets in the flow
    20-23 dOctets Total number of Layer 3 bytes in the packets of the flow

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: how to read flow file ?

    Looks like you could use the methods of the DataInputStream to read the first three fields as int, then read the 2 byte fields as shorts. Then convert the int to Strings.

  20. #20
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm,
    but how can i read the file :
    ft-v05.2010-05-09.190501+0800
    it's not txt file

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 08-05-2011, 09:21 PM
  2. How to generate Data Flow Diagram(Work Flow Diagram)
    By stsivaraj in forum AWT / Swing
    Replies: 1
    Last Post: 12-22-2010, 11:21 PM
  3. Replies: 2
    Last Post: 05-11-2009, 10:07 AM
  4. Replies: 0
    Last Post: 02-11-2009, 09:53 AM
  5. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •