Skip to content

Latest commit

 

History

History
177 lines (131 loc) · 6.03 KB

PHASE5_BUGFIX.md

File metadata and controls

177 lines (131 loc) · 6.03 KB

Phase 5 Bug Fix: Unit Conversion Error

Issue Description

Error Message:

<!> Error setting up parameter 'packetSize': Cannot convert integer from unit none to B:
no conversion or conversion rate is not integer

When it occurred: When selecting "LightBackground" configuration (or any config with background flows)

Root Cause

The packetSize parameter in BackgroundFlow.ned was declared as:

int packetSize @unit(B) = default(1500);  // ❌ WRONG

But the omnetpp.ini configurations set it with a unit suffix:

*.bgFlow10[*].packetSize = 512B  // ❌ Trying to assign "512B" to int parameter with @unit(B)

The problem: OMNeT++ doesn't allow assigning a value with a unit suffix (like 512B) to an int parameter with a @unit(...) annotation. The @unit annotation is meant for double parameters that need unit conversion (e.g., converting seconds to milliseconds).

For integer parameters representing discrete byte counts, the unit annotation should be omitted.

Solution Applied

Fixed: BackgroundFlow.ned

Before:

int packetSize @unit(B) = default(1500);

After:

int packetSize = default(1500);  // ✅ Plain integer, no unit annotation

File: src/gpu/modules/BackgroundFlow.ned (line 19)

Fixed: omnetpp.ini

Removed the "B" suffix from all packetSize assignments:

Before:

*.bgFlow10[*].packetSize = 512B
*.bgFlow10[*].packetSize = 1024B
*.bgFlow10[*].packetSize = 1500B

After:

*.bgFlow10[*].packetSize = 512   # ✅ Plain integer value (bytes implied)
*.bgFlow10[*].packetSize = 1024  # ✅ Plain integer value (bytes implied)
*.bgFlow10[*].packetSize = 1500  # ✅ Plain integer value (bytes implied)

File: simulations/gpu_share_background/omnetpp.ini

  • Lines 114, 123 (LightBackground config)
  • Lines 143, 152 (MediumBackground config)
  • Lines 172, 181 (HeavyBackground config)

Why This Fix Works

  1. Integer parameters don't need unit annotations when the unit is fixed and doesn't require conversion
  2. Packet sizes are always in bytes - there's no need for unit conversion (we never express packet size in kilobytes or megabytes)
  3. Comments in the code document the unit (e.g., "// Packet size in bytes")
  4. Consistency with OMNeT++ best practices: Use @unit only for double parameters that might need conversion

Verification

After applying this fix, the simulation should:

  1. ✅ Build without errors (no need to rebuild, only NED/INI files changed)
  2. ✅ Initialize BackgroundFlow modules without parameter errors
  3. ✅ Run all configurations (NoBackground, LightBackground, MediumBackground, HeavyBackground)
  4. ✅ Generate background traffic with correct packet sizes (512, 1024, 1500 bytes)

How to Test the Fix

Step 1: No rebuild needed (unless you want to be safe)

cd d:\omnetpp-6.2.0\samples\gpu_share\src
# Optional: make clean && make -j16
# (Only needed if you had partially compiled before the fix)

Step 2: Run the simulation

cd d:\omnetpp-6.2.0\samples\gpu_share\simulations\gpu_share_background
..\..\src\gpu_share.exe -f omnetpp.ini -c LightBackground -u Qtenv

Step 3: Verify initialization

In the Qtenv event log, you should see:

t=0.000s: BackgroundFlow50 initialized: vlanId=10, srcAddr=50, destAddr=-1,
          burstInterval=2s, burstSize=5, packetSize=512 bytes, packetInterval=0.02s

Note: packetSize=512 (not packetSize=512B)

Step 4: Verify packet generation

After a few seconds, you should see:

t=0.523s: BackgroundFlow50 starting burst #1 at t=0.523
t=0.523s: BackgroundFlow50 sent packet 1 (burst 1, pkt 1/5), 512 bytes

Cross-Reference Validation

BackgroundFlow.cc (No changes needed)

The C++ implementation correctly reads packetSize as an integer:

packetSize = par("packetSize");  // Line 62

And uses it directly:

pkt->setBytes(packetSize);       // Line 147
totalBytesSent += packetSize;    // Line 148

VlanBus.cc (No changes needed)

VlanBus correctly handles DataPkt with explicit byte counts:

if (DataPkt *dataPkt = dynamic_cast<DataPkt*>(frame)) {
    frameBytes = dataPkt->getBytes();  // Reads the bytes field set by BackgroundFlow
}
serializationDelay = (frameBytes * 8.0) / datarate;  // Applies delay

Related Files Modified

  1. ✅ src/gpu/modules/BackgroundFlow.ned - Removed @unit(B) from packetSize
  2. ✅ simulations/gpu_share_background/omnetpp.ini - Removed "B" suffix from all packetSize values

No Changes Needed To

Lesson Learned

OMNeT++ Parameter Unit Annotations:

Parameter Type Use Case Example Unit Annotation
double with unit conversion Time, distance, rate double delay @unit(s) ✅ Use @unit(...)
int with fixed unit Byte counts, packet counts int packetSize ❌ No @unit(...)
bool or string Flags, names bool debug ❌ No @unit(...)

Assignment Rules:

Parameter Declaration INI File Assignment Valid?
double delay @unit(s) *.delay = 1s ✅ Yes
double delay @unit(s) *.delay = 1000ms ✅ Yes (converted)
int packetSize @unit(B) *.packetSize = 512B ❌ No (our bug)
int packetSize *.packetSize = 512 ✅ Yes (our fix)

Bug Status: ✅ FIXED

The simulation should now run correctly with all background traffic configurations.


Fixed on: 2025-10-29 Affected configs: LightBackground, MediumBackground, HeavyBackground Resolution time: ~5 minutes