bcds.phison.io
Class TrafficReader

java.lang.Object
  extended by bcds.tools.DataFileReader
      extended by bcds.phison.io.TrafficReader

public class TrafficReader
extends DataFileReader

Reads a "traffic" file (usually, .trf), that is, the file that lists the events (connection requests, connection release, time marks, and other failure events). A traffic file is a text file (which can be GZIP-compressed) where each line describes an event. See SimEvents for a list of the possible events.

Comments start with the character '#' and run until the end of the line. A line containing the word "end" as its sole value is considered the logical end-of-file marker.

File format: The format of a traffic file is dependant on the traffic generator. See gentraf for more details on format.

Author:
Juan Segovia S.

Constructor Summary
TrafficReader(java.io.Reader ips)
           
TrafficReader(java.lang.String fname)
          Creates a reader for the file fname.
 
Method Summary
 int getCap()
          Returns the requested capacity when the type is SimEvents.CONN_REQUEST; otherwise returns -1.
 int getClock()
          Returns the time of the event last read.
 java.lang.String getDemandType()
          Returns the demand type of a connection request event, or nul if the event type is not {CONN_REQUEST}.
 int getDest()
          Returns the destination of connection request when the type is SimEvents.CONN_REQUEST; otherwise returns -1.
 int getDuration()
          Returns the requested connection duration when the type is SimEvents.CONN_REQUEST; or the duration of the failure for failure types.
 int getId()
          Returns the connection id line last read.
 int getSrc()
          Returns the source of connection request when the type is SimEvents.CONN_REQUEST; otherwise returns -1.
 SimEvents getType()
          Returns the type of the line last read, or null at end-of-file.
 SimEvents next()
          Reads one line of the traffic file and returns the traffic "type" (the same value returned by getType().
 
Methods inherited from class bcds.tools.DataFileReader
getFileName, getLineNum, getReader, newFileReader, nextLine, rewind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrafficReader

public TrafficReader(java.lang.String fname)
Creates a reader for the file fname.

Throws:
java.io.IOException - for any error detected by the DataFileReader constructor.

TrafficReader

public TrafficReader(java.io.Reader ips)
Method Detail

getType

public SimEvents getType()
Returns the type of the line last read, or null at end-of-file.


getId

public int getId()
Returns the connection id line last read. If that field is not present in the line, returns -1 (for example, a TIME mark does not have connection id).


getSrc

public int getSrc()
Returns the source of connection request when the type is SimEvents.CONN_REQUEST; otherwise returns -1.


getDest

public int getDest()
Returns the destination of connection request when the type is SimEvents.CONN_REQUEST; otherwise returns -1.


getCap

public int getCap()
Returns the requested capacity when the type is SimEvents.CONN_REQUEST; otherwise returns -1.


getDuration

public int getDuration()
Returns the requested connection duration when the type is SimEvents.CONN_REQUEST; or the duration of the failure for failure types. Otherwise returns -1.


getClock

public int getClock()
Returns the time of the event last read. This item is present in event type.


getDemandType

public java.lang.String getDemandType()
Returns the demand type of a connection request event, or nul if the event type is not {CONN_REQUEST}.

This is a user-defined value, and is not related to getType(). See DemandTypesReader for more information on demand types.


next

public SimEvents next()
Reads one line of the traffic file and returns the traffic "type" (the same value returned by getType(). After next() returns the getXXX() methods can be used to obtain the items.

Throws:
BadFormatException - if the file is syntactically erroneous.
java.lang.NumberFormatException - when a value for a numeric item cannot be converted to integer.