Skip to content

Commit

Permalink
test: adjusted tests to new message sizes with headers
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Schrab <[email protected]>
  • Loading branch information
kschrab committed Dec 1, 2023
1 parent a3bf92e commit 6e6508b
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"networkConfigurationFile": "network.json",
"regionConfigurationFile": "regions.json"
"regionConfigurationFile": "regions.json",
"headerLengths": {
"udpHeader": "8 Bytes",
"tcpHeader": "20 Bytes",
"ipHeader": "20 Bytes",
"cellularHeader": "26 Bytes",
"ethernetHeader": "38 Bytes"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ public static class CHeaderLengths {

/**
* The size of all headers of the ethernet link layer (used only for server nodes).
* E.g. Ethernet + MAC Header = ~ 38 bytes
* E.g. Ethernet + MAC + PHY Header = ~ 38 bytes
*/
@JsonAdapter(DataFieldAdapter.SizeQuiet.class)
public long ethernetHeader = 38 * DATA.BYTE;

/**
* The size of all headers of the cellular link layer.<br>
* For example, for LTE we estimate ~20 bytes (PDCP (6 bytes) + RLC (4 bytes) + MAC (10 bytes))
* For example, for LTE we estimate ~20 bytes (PDCP (6 bytes) + RLC (4 bytes) + MAC (10 bytes) + PHY (6 bytes))
*/
@JsonAdapter(DataFieldAdapter.SizeQuiet.class)
public long cellularHeader = 20 * DATA.BYTE;
public long cellularHeader = 26 * DATA.BYTE;

/**
* The size of IP header added to all messages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

package org.eclipse.mosaic.fed.cell.utility;

import static org.eclipse.mosaic.lib.objects.UnitNameGenerator.isServer;
import static org.eclipse.mosaic.lib.objects.UnitNameGenerator.isTmc;

import org.eclipse.mosaic.fed.cell.config.CCell;
import org.eclipse.mosaic.fed.cell.config.model.CNetworkProperties;
import org.eclipse.mosaic.fed.cell.config.model.TransmissionMode;
import org.eclipse.mosaic.fed.cell.data.ConfigurationData;
import org.eclipse.mosaic.lib.objects.UnitNameGenerator;
import org.eclipse.mosaic.lib.objects.communication.CellConfiguration;
import org.eclipse.mosaic.lib.objects.v2x.MessageStreamRouting;
import org.eclipse.mosaic.lib.objects.v2x.V2xMessage;
Expand Down Expand Up @@ -139,7 +141,7 @@ public static void consumeCapacity(TransmissionMode mode, CNetworkProperties reg
public static long getMessageLengthWithHeaders(V2xMessage msg, String senderOrReceiver) {
final CCell.CHeaderLengths headerLengths = ConfigurationData.INSTANCE.getCellConfig().headerLengths;
final long linkLayerHeader;
if (UnitNameGenerator.isServer(senderOrReceiver) || UnitNameGenerator.isTmc(senderOrReceiver)) {
if (senderOrReceiver != null && (isServer(senderOrReceiver) || isTmc(senderOrReceiver))) {
// let's assume everything is connected via cellular link, except servers and tmcs which are connected with the backbone
linkLayerHeader = headerLengths.ethernetHeader;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ protected void before() throws Throwable {
File cellConfigFile = copyToFile(cellConfigPath, targetFolder);
cellConfig = ConfigurationReader.importCellConfig(cellConfigFile.getAbsolutePath());
ConfigurationData.INSTANCE.setCellConfig(cellConfig);
} else {
ConfigurationData.INSTANCE.setCellConfig(new CCell());
}

if (regionConfigPath != null) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@

public class UpstreamModuleTest {

private static final long HEADER_UDP = 8 * DATA.BYTE;
private static final long HEADER_IP = 20 * DATA.BYTE;
private static final long HEADER_TCP = 20 * DATA.BYTE;
private static final long HEADER_CELLULAR = 26 * DATA.BYTE;

@Rule
public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.LENIENT);

Expand Down Expand Up @@ -162,7 +167,7 @@ public void testProcessMessage_regularMessageNodeLimited() throws InternalFedera

SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE);
Event event = new Event(10 * TIME.SECOND, upstreamModule, sampleV2XMessage);
CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 400 * DATA.BIT, 400 * DATA.BIT);
CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 2560 * DATA.BIT, 2560 * DATA.BIT);
SimulationData.INSTANCE.setCellConfigurationOfNode("veh_0", cellConfiguration);

// RUN
Expand All @@ -172,13 +177,13 @@ public void testProcessMessage_regularMessageNodeLimited() throws InternalFedera
assertEquals(0, rtiInteractionsSent.size());
assertEquals(2, cellModuleMessages.size());
CellModuleMessage notifyOnFinishMessage = cellModuleMessages.get(0);
checkNotifyOnFinishMessage(notifyOnFinishMessage, 400 * DATA.BIT, 10 * TIME.SECOND, (long) (10.2 * TIME.SECOND));
checkNotifyOnFinishMessage(notifyOnFinishMessage, 2560 * DATA.BIT, 10 * TIME.SECOND, (long) (10.2 * TIME.SECOND));

CellModuleMessage resultMessage = cellModuleMessages.get(1);
checkResultMessage(resultMessage, 400 * DATA.BIT, 10 * TIME.SECOND, (long) (10.2 * TIME.SECOND));
checkResultMessage(resultMessage, 2560 * DATA.BIT, 10 * TIME.SECOND, (long) (10.2 * TIME.SECOND));

assertEquals(0L, SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0").getAvailableUplinkBitrate());
assertEquals((21000 - 400) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity);
assertEquals((21000 - 2560) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity);
}

@Test
Expand All @@ -187,10 +192,10 @@ public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() thro
// UDP
routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 2, 0, 0}));

CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 400 * DATA.BIT, 400 * DATA.BIT);
CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 2560 * DATA.BIT, 2560 * DATA.BIT);
SimulationData.INSTANCE.setCellConfigurationOfNode("veh_0", cellConfiguration);
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity = 600 * DATA.BIT;
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.maxCapacity = 600 * DATA.BIT;
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity = 3000 * DATA.BIT;
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.maxCapacity = 3000 * DATA.BIT;

SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE);
Event event = new Event(10 * TIME.SECOND, upstreamModule, sampleV2XMessage);
Expand All @@ -202,13 +207,13 @@ public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() thro
assertEquals(0, rtiInteractionsSent.size());
assertEquals(2, cellModuleMessages.size());
CellModuleMessage notifyOnFinishMessage = cellModuleMessages.get(0);
checkNotifyOnFinishMessage(notifyOnFinishMessage, 400 * DATA.BIT, 10 * TIME.SECOND, (long) (10.2 * TIME.SECOND));
checkNotifyOnFinishMessage(notifyOnFinishMessage, 2560 * DATA.BIT, 10 * TIME.SECOND, (long) (10.2 * TIME.SECOND));

CellModuleMessage resultMessage = cellModuleMessages.get(1);
checkResultMessage(resultMessage, 400 * DATA.BIT, 10 * TIME.SECOND, (long) (10.2 * TIME.SECOND));
checkResultMessage(resultMessage, 2560 * DATA.BIT, 10 * TIME.SECOND, (long) (10.2 * TIME.SECOND));

assertEquals(0L, SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0").getAvailableUplinkBitrate());
assertEquals((600 - 400) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity);
assertEquals((3000 - 2560) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity);
}

@Test
Expand All @@ -217,10 +222,10 @@ public void testProcessMessage_regularMessageNodeLimitedRegionMoreLimited() thro
// UDP
routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 2, 0, 0}));

CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 400 * DATA.BIT, 400 * DATA.BIT);
CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 2560 * DATA.BIT, 2560 * DATA.BIT);
SimulationData.INSTANCE.setCellConfigurationOfNode("veh_0", cellConfiguration);
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity = 200 * DATA.BIT;
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.maxCapacity = 200 * DATA.BIT;
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity = 1280 * DATA.BIT;
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.maxCapacity = 1280 * DATA.BIT;

SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE);
Event event = new Event(10 * TIME.SECOND, upstreamModule, sampleV2XMessage);
Expand All @@ -232,12 +237,12 @@ public void testProcessMessage_regularMessageNodeLimitedRegionMoreLimited() thro
assertEquals(0, rtiInteractionsSent.size());
assertEquals(2, cellModuleMessages.size());
CellModuleMessage notifyOnFinishMessage = cellModuleMessages.get(0);
checkNotifyOnFinishMessage(notifyOnFinishMessage, 200, 10 * TIME.SECOND, (long) (10.4 * TIME.SECOND));
checkNotifyOnFinishMessage(notifyOnFinishMessage, 1280, 10 * TIME.SECOND, (long) (10.4 * TIME.SECOND));

CellModuleMessage resultMessage = cellModuleMessages.get(1);
checkResultMessage(resultMessage, 200, 10 * TIME.SECOND, (long) (10.4 * TIME.SECOND));
checkResultMessage(resultMessage, 1280, 10 * TIME.SECOND, (long) (10.4 * TIME.SECOND));

assertEquals((400 - 200) * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0").getAvailableUplinkBitrate());
assertEquals((2560 - 1280) * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0").getAvailableUplinkBitrate());
assertEquals(0L, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity);
}

Expand Down Expand Up @@ -289,7 +294,8 @@ public void testProcessMessage_regularMessageNodeUnlimited_plusFreeBandwidth() t
// ASSERT
assertEquals(0, rtiInteractionsSent.size());

long expectedBandwidth = (long) (messageLength / (DELAY_VALUE_IN_MS / (double) TIME.SECOND));
long actualMessageLength = messageLength + HEADER_UDP + HEADER_IP + HEADER_CELLULAR;
long expectedBandwidth = (long) (actualMessageLength / (DELAY_VALUE_IN_MS / (double) TIME.SECOND));

assertEquals(2, cellModuleMessages.size());
CellModuleMessage notifyOnFinishMessage = cellModuleMessages.get(0);
Expand Down Expand Up @@ -325,8 +331,8 @@ public void testProcessMessage_regularMessageNodeUnlimitedRegionLimited() throws
long messageLength = 10 * DATA.BYTE;
SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), messageLength);
Event event = new Event(10 * TIME.SECOND, upstreamModule, sampleV2XMessage);
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity = 200 * DATA.BIT;
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.maxCapacity = 200 * DATA.BIT;
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity = 1000 * DATA.BIT;
ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.maxCapacity = 1000 * DATA.BIT;

// RUN
upstreamModule.processEvent(event);
Expand All @@ -337,12 +343,13 @@ public void testProcessMessage_regularMessageNodeUnlimitedRegionLimited() throws
assertEquals(2, cellModuleMessages.size());
CellModuleMessage notifyOnFinishMessage = cellModuleMessages.get(0);

long expectedBandwidth = 200 * DATA.BIT;
checkNotifyOnFinishMessage(notifyOnFinishMessage, expectedBandwidth, 10 * TIME.SECOND, (long) (10.4 * TIME.SECOND));
// actual message length = 10 + UDP + IP + CELLULAR = 64 Bytes = 512 Bit
long expectedBandwidth = 1000 * DATA.BIT;
checkNotifyOnFinishMessage(notifyOnFinishMessage, expectedBandwidth, 10 * TIME.SECOND, (long) (10.512 * TIME.SECOND));

CellModuleMessage resultMessage = cellModuleMessages.get(1);
checkResultMessage(resultMessage, expectedBandwidth, 10 * TIME.SECOND,
(long) (10.4 * TIME.SECOND));
(long) (10.512 * TIME.SECOND));

assertEquals(
(Long.MAX_VALUE - expectedBandwidth) * DATA.BIT,
Expand All @@ -369,7 +376,8 @@ public void testProcessMessage_packetLossTcp() throws InternalFederateException

double delayInS = ((ConstantDelay) ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.delay).delay
/ (double) TIME.SECOND;
long expectedBandwidth = (long) (messageLength / delayInS);
long actualMessageLength = messageLength + HEADER_TCP + HEADER_IP + HEADER_CELLULAR;
long expectedBandwidth = (long) (actualMessageLength / delayInS);

// RUN
upstreamModule.processEvent(event);
Expand Down Expand Up @@ -414,7 +422,8 @@ public void testProcessMessage_packetLossUdp() throws InternalFederateException

double delayInS = ((ConstantDelay) ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.delay).delay
/ (double) TIME.SECOND;
long expectedBandwidth = (long) (messageLength / delayInS);
long actualMessageLength = messageLength + HEADER_UDP + HEADER_IP + HEADER_CELLULAR;
long expectedBandwidth = (long) (actualMessageLength / delayInS);
checkNotifyOnFinishMessage(notifyOnFinishMessage, expectedBandwidth, 10 * TIME.SECOND,
10 * TIME.SECOND + DELAY_VALUE_IN_MS);

Expand Down
12 changes: 12 additions & 0 deletions fed/mosaic-cell/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ public void cellMessagesHandledInModules() throws Exception {
// send 150 uplink messages from veh_0 and veh_1 + 2*RoundTripMessage + 2*Messages for nack + 1*Nack-test = 305
LogAssert.contains(simulationRule, CELL_LOG, ".*ChainManager - \\[Upstream\\] Processed messages: 305.*");
/* received (26 rsu_0 + 30 rsu_1 + 30 rsu_2 + 150 self) messages from veh_0 = 236
and (150 broadcast + 2 region overlap) - (113 messages not sendable due to capacity limit) messages from veh_1 = 39
and (150 broadcast + 2 region overlap) - (126 messages not sendable due to capacity limit) messages from veh_1 = 26
and 2*RoundTripMessage = 2
and 2*Messages for nack test = 2
and 1*Nack-Test ==> total 280*/
LogAssert.contains(simulationRule, CELL_LOG, ".*ChainManager - \\[Downstream\\] Processed messages: 280.*");
and 1*Nack-Test ==> total 267*/
LogAssert.contains(simulationRule, CELL_LOG, ".*ChainManager - \\[Downstream\\] Processed messages: 267.*");
}

@Test
Expand Down Expand Up @@ -180,11 +180,11 @@ public void applicationsCamReceptions() throws Exception {

// geo broadcast
// locate rsu_0 and rsu_1 in the same mbms broadcast region
assertOccurrences(RSU_0_RECEIVE_MSG_APP_CELL_LOG, ".*Received CAM from veh_1.*", 10);
assertOccurrences(RSU_0_RECEIVE_MSG_APP_CELL_LOG, ".*Received CAM from veh_1.*", 7);
// locate rsu_0 and rsu_1 in the same mbms broadcast region
assertOccurrences(RSU_1_RECEIVE_MSG_APP_CELL_LOG, ".*Received CAM from veh_1.*", 10);
assertOccurrences(RSU_1_RECEIVE_MSG_APP_CELL_LOG, ".*Received CAM from veh_1.*", 7);
// locate rsu_0 and rsu_2 in the same mbms broadcast region
assertOccurrences(RSU_2_RECEIVE_MSG_APP_CELL_LOG, ".*Received CAM from veh_1.*", 18);
assertOccurrences(RSU_2_RECEIVE_MSG_APP_CELL_LOG, ".*Received CAM from veh_1.*", 12);

// adhoc
// test pattern no interference with ad hoc rsus
Expand All @@ -210,7 +210,7 @@ public void roundTripMessageTakesRightAmountOfTime() throws Exception {
long timeOfSending = 310 * TIME.SECOND;
long delayTmcUpload = 50 * TIME.MILLI_SECOND;
long delayTmcDownload = 50 * TIME.MILLI_SECOND;
long delayVehUpload = 86 * TIME.MILLI_SECOND; //TODO check those values, are those random?
long delayVehUpload = 106 * TIME.MILLI_SECOND; //TODO check those values, are those random?
long delayVehDownload = 57 * TIME.MILLI_SECOND; //TODO check those values, are those random? if so, than its not ideal for a test

long timeFromTmcToVeh = delayTmcUpload + delayVehDownload;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"networkConfigurationFile": "network.json",
"regionConfigurationFile": "regions.json"
"regionConfigurationFile": "regions.json",
"headerLengths": {
"udpHeader": "8 Bytes",
"tcpHeader": "20 Bytes",
"ipHeader": "20 Bytes",
"cellularHeader": "26 Bytes",
"ethernetHeader": "38 Bytes"
}
}

0 comments on commit 6e6508b

Please sign in to comment.