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)
The packetSize parameter in BackgroundFlow.ned was declared as:
int packetSize @unit(B) = default(1500); // ❌ WRONGBut 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.
Before:
int packetSize @unit(B) = default(1500);After:
int packetSize = default(1500); // ✅ Plain integer, no unit annotationFile: src/gpu/modules/BackgroundFlow.ned (line 19)
Removed the "B" suffix from all packetSize assignments:
Before:
*.bgFlow10[*].packetSize = 512B
*.bgFlow10[*].packetSize = 1024B
*.bgFlow10[*].packetSize = 1500BAfter:
*.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)
- Integer parameters don't need unit annotations when the unit is fixed and doesn't require conversion
- Packet sizes are always in bytes - there's no need for unit conversion (we never express packet size in kilobytes or megabytes)
- Comments in the code document the unit (e.g., "// Packet size in bytes")
- Consistency with OMNeT++ best practices: Use
@unitonly fordoubleparameters that might need conversion
After applying this fix, the simulation should:
- ✅ Build without errors (no need to rebuild, only NED/INI files changed)
- ✅ Initialize BackgroundFlow modules without parameter errors
- ✅ Run all configurations (NoBackground, LightBackground, MediumBackground, HeavyBackground)
- ✅ Generate background traffic with correct packet sizes (512, 1024, 1500 bytes)
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)cd d:\omnetpp-6.2.0\samples\gpu_share\simulations\gpu_share_background
..\..\src\gpu_share.exe -f omnetpp.ini -c LightBackground -u QtenvIn 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)
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
The C++ implementation correctly reads packetSize as an integer:
packetSize = par("packetSize"); // Line 62And uses it directly:
pkt->setBytes(packetSize); // Line 147
totalBytesSent += packetSize; // Line 148VlanBus 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- ✅ src/gpu/modules/BackgroundFlow.ned - Removed
@unit(B)frompacketSize - ✅ simulations/gpu_share_background/omnetpp.ini - Removed "B" suffix from all
packetSizevalues
- ✅ src/gpu/modules/BackgroundFlow.cc - Already correct
- ✅ src/gpu/messages/Lan.msg - DataPkt.bytes field unchanged
- ✅ src/gpu/modules/VlanBus.cc - Correctly handles DataPkt
- ✅ Any other Phase 0-4 files
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) |
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