EPONImplementationforOMNet++  0.8Beta
MPCPTools Class Reference

A class to handle simTime and convert it to nanoseconds clock 32 bit with 16ns granularity. More...

#include <MPCPTools.h>

List of all members.

Public Member Functions

 MPCPTools ()
virtual ~MPCPTools ()

Static Public Member Functions

static void setGateLen (MPCPGate &gate, uint8_t len)
static uint64_t simTimeToNS16 ()
static uint64_t simTimeToNS16 (uint64_t time)
static uint64_t ns16ToSimTime (uint64_t time)
static uint64_t nsToSimTime (uint64_t time)
static uint64_t bitsToNS16 (uint64_t bits, uint8_t gigRate)
 Convert bits to ns16.
static uint64_t bytesToNS16 (uint64_t bytes, uint8_t gigRate)
 Convert bytes to ns16.
static uint64_t ns16ToBits (uint64_t ns16, uint8_t gigRate)
 Convert ns16 to bits.
static uint64_t ns16ToBytes (uint64_t ns16, uint8_t gigRate)
 Convert ns16 to Bytes.

Detailed Description

A class to handle simTime and convert it to nanoseconds clock 32 bit with 16ns granularity.

NOTE: DO NEVER COMPARE IN SIM TIME WHEN YOU ARE USING THE ns16ToSimTime... NEVER. DO THE OPPOSITE COMPARE IN DEVICE TIME USING simTimeToNS16(). (<- Now I don't remember why... but I should be right...)


Constructor & Destructor Documentation

                     {
      // TODO Auto-generated constructor stub

}
MPCPTools::~MPCPTools ( ) [virtual]
                      {
      // TODO Auto-generated destructor stub
}

Member Function Documentation

uint64_t MPCPTools::bitsToNS16 ( uint64_t  bits,
uint8_t  gigRate 
) [static]

Convert bits to ns16.

Uses the line rate given in Gbps

                                                            {
      uint64_t rate = gigRate * pow(10,9);
      // tx time in seconds
      double txtime = ((double)bits)/rate;
      // tx time in ns
      txtime*=pow(10,9);
      // ns16
      return (txtime/16);
}
uint64_t MPCPTools::bytesToNS16 ( uint64_t  bytes,
uint8_t  gigRate 
) [static]

Convert bytes to ns16.

Uses the line rate given in Gbps

                                                              {
      return bitsToNS16(bytes*8, gigRate);
}
uint64_t MPCPTools::ns16ToBits ( uint64_t  ns16,
uint8_t  gigRate 
) [static]

Convert ns16 to bits.

Uses the line rate given in Gbps

                                                            {
      uint64_t rate = gigRate * pow(10,9);
      // ns
      uint64_t bits = 16*ns16;

      // sec
      double seconds = ((double)bits)/pow(10,9);

      // bits
      bits = seconds*rate;
      return bits;
}
uint64_t MPCPTools::ns16ToBytes ( uint64_t  ns16,
uint8_t  gigRate 
) [static]

Convert ns16 to Bytes.

Uses the line rate given in Gbps

                                                             {
      return ns16ToBits(ns16,gigRate)/8;
}
uint64_t MPCPTools::ns16ToSimTime ( uint64_t  time) [static]
                                              {
      int scale= (-9 -simTime().getScaleExp())/3;
      // Clock Granularity is 16ns
      return time * (scale*1000*16);
}
uint64_t MPCPTools::nsToSimTime ( uint64_t  time) [static]
                                            {
      int scale= (-9 -simTime().getScaleExp())/3;
      // Clock Granularity is 16ns
      return time * (scale*1000);
}
void MPCPTools::setGateLen ( MPCPGate gate,
uint8_t  len 
) [static]
                                                     {
      gate.setListLen(len);
      gate.setStartTimeArraySize(len);
      gate.setDurationArraySize(len);
}
uint64_t MPCPTools::simTimeToNS16 ( ) [static]
                                 {
      // NOTE: You can add skew here...
      int scale= (-9 -simTime().getScaleExp())/3;
      // Clock Granularity is 16ns
      return (simTime().raw()/(scale*1000*16))%MPCP_CLOCK_MAX;
}
uint64_t MPCPTools::simTimeToNS16 ( uint64_t  time) [static]
                                              {
      int scale= (-9 -simTime().getScaleExp())/3;
      // Clock Granularity is 16ns
      return (time/(scale*1000*16))%MPCP_CLOCK_MAX;
}

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Friends Defines