From 2767799b1e96b87b961144405d8f32f8c4a58b13 Mon Sep 17 00:00:00 2001 From: Karl Schrab Date: Fri, 16 Feb 2024 17:52:04 +0100 Subject: [PATCH] feat(cell): model header sizes for messages transmitted by cell (#369) * feat(cell): consider header size when transmitting via UDP or TCP * feat(cell): consider header size for linklayer, too * test: adjusted tests to new message sizes with headers * fix(cell): apply API changes (getPayLoad() -> getPayload()) * clean(cell): fixed default values after review, improved documentation --------- Signed-off-by: Karl Schrab --- .../scenarios/Barnim/cell/cell_config.json | 9 +- .../Tiergarten/cell/cell_config.json | 9 +- .../eclipse/mosaic/fed/cell/config/CCell.java | 50 +++++++++ .../StreamModulesDebugLogger.java | 10 +- .../module/streammodules/StreamProcessor.java | 2 +- .../fed/cell/utility/CapacityUtility.java | 33 +++++- .../fed/cell/junit/CellConfigurationRule.java | 2 + .../fed/cell/module/DownstreamModuleTest.java | 106 ++++++++++-------- .../fed/cell/module/UpstreamModuleTest.java | 57 ++++++---- .../src/test/resources/logback-test.xml | 12 ++ .../lib/util/gson/DataFieldAdapter.java | 17 ++- .../test/CellSnsCamSendAndReceiveIT.java | 14 +-- .../cell/cell_config.json | 9 +- 13 files changed, 237 insertions(+), 93 deletions(-) create mode 100644 fed/mosaic-cell/src/test/resources/logback-test.xml diff --git a/bundle/src/assembly/resources/scenarios/Barnim/cell/cell_config.json b/bundle/src/assembly/resources/scenarios/Barnim/cell/cell_config.json index ff729782a..920100c68 100644 --- a/bundle/src/assembly/resources/scenarios/Barnim/cell/cell_config.json +++ b/bundle/src/assembly/resources/scenarios/Barnim/cell/cell_config.json @@ -1,4 +1,11 @@ { "networkConfigurationFile": "network.json", - "regionConfigurationFile": "regions.json" + "regionConfigurationFile": "regions.json", + "headerLengths": { + "udpHeader": "8 Bytes", + "tcpHeader": "20 Bytes", + "ipHeader": "20 Bytes", + "cellularHeader": "18 Bytes", + "ethernetHeader": "18 Bytes" + } } \ No newline at end of file diff --git a/bundle/src/assembly/resources/scenarios/Tiergarten/cell/cell_config.json b/bundle/src/assembly/resources/scenarios/Tiergarten/cell/cell_config.json index ff729782a..920100c68 100644 --- a/bundle/src/assembly/resources/scenarios/Tiergarten/cell/cell_config.json +++ b/bundle/src/assembly/resources/scenarios/Tiergarten/cell/cell_config.json @@ -1,4 +1,11 @@ { "networkConfigurationFile": "network.json", - "regionConfigurationFile": "regions.json" + "regionConfigurationFile": "regions.json", + "headerLengths": { + "udpHeader": "8 Bytes", + "tcpHeader": "20 Bytes", + "ipHeader": "20 Bytes", + "cellularHeader": "18 Bytes", + "ethernetHeader": "18 Bytes" + } } \ No newline at end of file diff --git a/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/config/CCell.java b/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/config/CCell.java index 24beb4600..ce9eea4ab 100644 --- a/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/config/CCell.java +++ b/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/config/CCell.java @@ -16,6 +16,10 @@ package org.eclipse.mosaic.fed.cell.config; import org.eclipse.mosaic.fed.cell.config.model.TransmissionMode; +import org.eclipse.mosaic.lib.util.gson.DataFieldAdapter; +import org.eclipse.mosaic.rti.DATA; + +import com.google.gson.annotations.JsonAdapter; import java.util.ArrayList; import java.util.List; @@ -26,6 +30,12 @@ */ public final class CCell { + /** + * Configuration of header sizes added to all messages before + * simulating packet transmission. + */ + public final CHeaderLengths headerLengths = new CHeaderLengths(); + /** * Interval (in seconds) in which the bandwidth is aggregated. * @@ -83,4 +93,44 @@ public static class CBandwidthMeasurement { */ public String applicationClass = "*"; } + + public static class CHeaderLengths { + + /** + * The size of all headers of the ethernet link layer (used only for server nodes). + * E.g. Ethernet (6 Bytes) + MAC Header (12 Bytes) = ~ 18 bytes + */ + @JsonAdapter(DataFieldAdapter.Size.class) + public long ethernetHeader = 18 * DATA.BYTE; + + /** + * The size of all headers of the cellular link layer.
+ * For example, for 5G we estimate ~18 bytes: SDAP(1 Bytes) + PDCP (3 bytes) + RLC (4 bytes) + MAC (10 bytes) + */ + @JsonAdapter(DataFieldAdapter.Size.class) + public long cellularHeader = 18 * DATA.BYTE; + + /** + * The size of IP header added to all messages. + * In the default configuration we assume IPv4 (20 bytes) + */ + @JsonAdapter(DataFieldAdapter.Size.class) + public long ipHeader = 20 * DATA.BYTE; + + /** + * The size of TCP header added to all messages which use + * {@link org.eclipse.mosaic.lib.enums.ProtocolType#TCP} + * for transmission. + */ + @JsonAdapter(DataFieldAdapter.Size.class) + public long tcpHeader = 20 * DATA.BYTE; + + /** + * The size of UDP headers added to all messages which use + * {@link org.eclipse.mosaic.lib.enums.ProtocolType#UDP} + * for transmission. + */ + @JsonAdapter(DataFieldAdapter.Size.class) + public long udpHeader = 8 * DATA.BYTE; + } } diff --git a/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/module/streammodules/StreamModulesDebugLogger.java b/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/module/streammodules/StreamModulesDebugLogger.java index b0e0e6aad..d4017b7d1 100644 --- a/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/module/streammodules/StreamModulesDebugLogger.java +++ b/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/module/streammodules/StreamModulesDebugLogger.java @@ -60,7 +60,7 @@ static void logChannelCapacityExceeded(Logger log, StreamProcessor.Input input, } long delayInNs = (messageEndTime - input.getMessageStartTime()); - long msgLenInBit = CapacityUtility.getMessageLength(input.getV2xMessage()); + long msgLenInBit = CapacityUtility.getMessageLengthWithHeaders(input.getV2xMessage(), input.getNodeId()); int msgId = input.getV2xMessage().getId(); final String senderId = input.getV2xMessage().getRouting().getSource().getSourceName(); if (input.getMode().isUplink()) { @@ -106,7 +106,7 @@ static void logSuccessfulDelivery(Logger log, StreamProcessor.Input input, Strea } long delayInNs = (result.getMessageEndTime() - input.getMessageStartTime()); - long msgLenInBit = CapacityUtility.getMessageLength(input.getV2xMessage()); + long msgLenInBit = CapacityUtility.getMessageLengthWithHeaders(input.getV2xMessage(), input.getNodeId()); int msgId = input.getV2xMessage().getId(); if (input.getMode().isUplink()) { log.debug(" msg-{} IS deliverable via {} in region \"{}\" " @@ -157,7 +157,7 @@ static void logUnsuccessfulSending(Logger log, StreamProcessor.Input input, Stre */ private static void logUnsuccessfulSendingWithoutNodeConfig(Logger log, StreamProcessor.Input input, StreamProcessor.Result result) { long delayInNs = (result.getMessageEndTime() - input.getMessageStartTime()); - long msgLenInBit = CapacityUtility.getMessageLength(input.getV2xMessage()); + long msgLenInBit = CapacityUtility.getMessageLengthWithHeaders(input.getV2xMessage(), input.getNodeId()); int msgId = input.getV2xMessage().getId(); if (input.getMode().isUplink()) { log.debug(" msg-{} is not sendable via {} in region \"{}\" due to {}" @@ -188,7 +188,7 @@ private static void logUnsuccessfulSendingWithoutNodeConfig(Logger log, StreamPr */ private static void logUnsuccessfulSendingWithNodeConfig(Logger log, StreamProcessor.Input input, StreamProcessor.Result result) { long delayInNs = (result.getMessageEndTime() - input.getMessageStartTime()); - long msgLenInBit = CapacityUtility.getMessageLength(input.getV2xMessage()); + long msgLenInBit = CapacityUtility.getMessageLengthWithHeaders(input.getV2xMessage(), input.getNodeId()); int msgId = input.getV2xMessage().getId(); if (input.getMode().isUplink()) { log.debug(" msg-{} is not sendable via {} in region \"{}\" due to {}" @@ -225,7 +225,7 @@ static void logUnsuccessfulDelivery(Logger log, StreamProcessor.Input input, Str } long delayInNs = (result.getMessageEndTime() - input.getMessageStartTime()); - long msgLenInBit = CapacityUtility.getMessageLength(input.getV2xMessage()); + long msgLenInBit = CapacityUtility.getMessageLengthWithHeaders(input.getV2xMessage(), input.getNodeId()); int msgId = input.getV2xMessage().getId(); if (input.getMode().isUplink()) { log.debug(" msg-{} IS NOT deliverable via {} in region \"{}\" " diff --git a/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/module/streammodules/StreamProcessor.java b/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/module/streammodules/StreamProcessor.java index 7a11b53c0..e841b4f6c 100644 --- a/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/module/streammodules/StreamProcessor.java +++ b/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/module/streammodules/StreamProcessor.java @@ -196,7 +196,7 @@ private long calculateNeededBandwidthStream(Input input, Result result) { * @return Bandwidth for the data packets. */ private long calculateNeededBandwidthPacket(Input input, Result result, long coreDelayInNs, int prPlAttempts) { - long messageSize = CapacityUtility.getMessageLength(input.v2xMessage); + long messageSize = CapacityUtility.getMessageLengthWithHeaders(input.v2xMessage, input.nodeId); long neededBandwidth = prPlAttempts * CapacityUtility.calculateNeededCapacity(messageSize, coreDelayInNs) * DATA.BIT; // When the bandwidth is sufficient go on and send the packet diff --git a/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/utility/CapacityUtility.java b/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/utility/CapacityUtility.java index a3ce76543..3a6c4f0a5 100644 --- a/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/utility/CapacityUtility.java +++ b/fed/mosaic-cell/src/main/java/org/eclipse/mosaic/fed/cell/utility/CapacityUtility.java @@ -15,8 +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.communication.CellConfiguration; import org.eclipse.mosaic.lib.objects.v2x.MessageStreamRouting; import org.eclipse.mosaic.lib.objects.v2x.V2xMessage; @@ -128,13 +133,35 @@ public static void consumeCapacity(TransmissionMode mode, CNetworkProperties reg } /** - * Helper-function to get the effective message length in bits. + * Helper-function to get the effective message length in bits. For each message, a header is assumed + * to be present according to the protocol type (UDP or TCP) and the link layer (ethernet for servers, or cellular for mobile devices). + * According to our definition, we measure / simulate the message data size on the Link Layer (MAC Layer). * * @param msg V2X message. * @return The length of the V2X message. */ - public static long getMessageLength(V2xMessage msg) { - return msg.getPayload().getEffectiveLength() * DATA.BYTE; + public static long getMessageLengthWithHeaders(V2xMessage msg, String senderOrReceiver) { + final CCell.CHeaderLengths headerLengths = ConfigurationData.INSTANCE.getCellConfig().headerLengths; + final long linkLayerHeader; + 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 { + linkLayerHeader = headerLengths.cellularHeader; + } + switch (msg.getRouting().getDestination().getProtocolType()) { + case UDP: + return linkLayerHeader + + headerLengths.ipHeader + + headerLengths.udpHeader + + msg.getPayload().getEffectiveLength() * DATA.BYTE; + case TCP: + default: + return linkLayerHeader + + headerLengths.ipHeader + + headerLengths.tcpHeader + + msg.getPayload().getEffectiveLength() * DATA.BYTE; + } } /** diff --git a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/junit/CellConfigurationRule.java b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/junit/CellConfigurationRule.java index 7e1694a25..69ca7bcbd 100644 --- a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/junit/CellConfigurationRule.java +++ b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/junit/CellConfigurationRule.java @@ -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) { diff --git a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/DownstreamModuleTest.java b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/DownstreamModuleTest.java index 8b15db759..a2950c2f4 100644 --- a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/DownstreamModuleTest.java +++ b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/DownstreamModuleTest.java @@ -84,6 +84,11 @@ public class DownstreamModuleTest { + 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 = 18 * DATA.BYTE; + @Rule public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.LENIENT); @@ -178,7 +183,7 @@ public void testProcessMessage_regularMessageMulticast() throws Exception { assertEquals(3, rtiV2xReceptionsSent.size()); assertEquals(1, cellModuleMessages.size()); long endTime = 10 * TIME.SECOND + DELAY_VALUE_IN_MS; - checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 1600 * DATA.BIT, 10 * TIME.SECOND, endTime); + checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 8960 * DATA.BIT, 10 * TIME.SECOND, endTime); for (int i = 0; i < receivers.length; i++) { testRtiV2xMessages(i, receivers[i], endTime, sampleV2XMessage.getId()); assertEquals( @@ -187,7 +192,7 @@ public void testProcessMessage_regularMessageMulticast() throws Exception { ); } - assertEquals((42000 - 1600) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); + assertEquals((42000 - 8960) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); } @Test @@ -201,7 +206,7 @@ public void testProcessMessage_regularMessageMulticast_NodeLimited() throws Exce for (String receiver : receivers) { CNetworkProperties region = RegionUtility.getRegionForNode(receiver); receiverMap.put(region, receiver); - CellConfiguration cellConfiguration = new CellConfiguration(receiver, true, 400 * DATA.BIT, 400 * DATA.BIT); + CellConfiguration cellConfiguration = new CellConfiguration(receiver, true, 10000 * DATA.BIT, 10000 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode(receiver, cellConfiguration); } @@ -215,21 +220,21 @@ public void testProcessMessage_regularMessageMulticast_NodeLimited() throws Exce assertEquals(3, rtiV2xReceptionsSent.size()); assertEquals(1, cellModuleMessages.size()); long endTime = 10 * TIME.SECOND + DELAY_VALUE_IN_MS; - checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 1600 * DATA.BIT, 10 * TIME.SECOND, endTime); + checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 8960 * DATA.BIT, 10 * TIME.SECOND, endTime); for (int i = 0; i < receivers.length; i++) { testRtiV2xMessages(i, receivers[i], endTime, sampleV2XMessage.getId()); - assertEquals(400 * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode(receivers[i]).getAvailableDownlinkBitrate()); + assertEquals(10000 * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode(receivers[i]).getAvailableDownlinkBitrate()); } - assertEquals((42000 - 1600) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); + assertEquals((42000 - 8960) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); } @Test public void testProcessMessage_regularMessageMulticast_NodeLimitedRegionLimited() throws Exception { // SETUP // UDP - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 200 * DATA.BIT; - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 200 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 1120 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 1120 * DATA.BIT; routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); @@ -238,7 +243,7 @@ public void testProcessMessage_regularMessageMulticast_NodeLimitedRegionLimited( for (String receiver : receivers) { CNetworkProperties region = RegionUtility.getRegionForNode(receiver); receiverMap.put(region, receiver); - CellConfiguration cellConfiguration = new CellConfiguration(receiver, true, 400 * DATA.BIT, 400 * DATA.BIT); + CellConfiguration cellConfiguration = new CellConfiguration(receiver, true, 2240 * DATA.BIT, 2240 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode(receiver, cellConfiguration); } @@ -251,14 +256,14 @@ public void testProcessMessage_regularMessageMulticast_NodeLimitedRegionLimited( assertEquals(3, rtiInteractionsSent.size()); assertEquals(3, rtiV2xReceptionsSent.size()); assertEquals(1, cellModuleMessages.size()); - //120 bps remain, since not the full capacity is usable for the Multicast + //640 bps of capacity remain, since only 50% of the full capacity is usable for the Multicast long endTime = 10 * TIME.SECOND + 800 * TIME.MILLI_SECOND; - checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 100 * DATA.BIT, 10 * TIME.SECOND, endTime); - assertEquals(100 * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); + checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 560 * DATA.BIT, 10 * TIME.SECOND, endTime); + assertEquals(560 * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); for (int i = 0; i < receivers.length; i++) { testRtiV2xMessages(i, receivers[i], endTime, sampleV2XMessage.getId()); - assertEquals(400 * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode(receivers[i]).getAvailableDownlinkBitrate()); + assertEquals(2240 * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode(receivers[i]).getAvailableDownlinkBitrate()); } } @@ -269,8 +274,8 @@ public void testProcessMessage_regularMessageMulticast_MultipleRegions() throws // Moritzplatz GeoPoint moritzplatzKreuzberg = GeoPoint.lonLat(13.423233032226562, 52.50007194840628); - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 200 * DATA.BIT; - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 200 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 1120 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 1120 * DATA.BIT; routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); @@ -280,7 +285,7 @@ public void testProcessMessage_regularMessageMulticast_MultipleRegions() throws for (String receiver : receivers) { CNetworkProperties region = RegionUtility.getRegionForNode(receiver); receiverMap.put(region, receiver); - CellConfiguration cellConfiguration = new CellConfiguration(receiver, true, 400 * DATA.BIT, 400 * DATA.BIT); + CellConfiguration cellConfiguration = new CellConfiguration(receiver, true, 2240 * DATA.BIT, 2240 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode(receiver, cellConfiguration); } @@ -300,7 +305,7 @@ public void testProcessMessage_regularMessageMulticast_MultipleRegions() throws //120 bps remain, since not the full capacity is usable for the Multicast containsNotifyOnFinishMessage( "kreuzberg", - 800 * DATA.BIT, + 4480 * DATA.BIT, startTime, endTimeKreuzberg, TransmissionMode.DownlinkMulticast, null, @@ -308,7 +313,7 @@ public void testProcessMessage_regularMessageMulticast_MultipleRegions() throws ); containsNotifyOnFinishMessage( GLOBAL_NETWORK_ID, - 100 * DATA.BIT, + 560 * DATA.BIT, startTime, endTimeGlobaleRegion, TransmissionMode.DownlinkMulticast, @@ -316,14 +321,14 @@ public void testProcessMessage_regularMessageMulticast_MultipleRegions() throws sampleV2XMessage ); - assertEquals(100 * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); + assertEquals(560 * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); for (int i = 1; i < receivers.length; i++) { - assertEquals(400 * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode(receivers[i]).getAvailableDownlinkBitrate()); + assertEquals(2240 * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode(receivers[i]).getAvailableDownlinkBitrate()); } - containsRtiV2xMessages("veh_0", startTime, endTimeGlobaleRegion, sampleV2XMessage.getId(), 100 * DATA.BIT); - containsRtiV2xMessages("veh_1", startTime, endTimeGlobaleRegion, sampleV2XMessage.getId(), 100 * DATA.BIT); - containsRtiV2xMessages("veh_2", startTime, endTimeKreuzberg, sampleV2XMessage.getId(), 800 * DATA.BIT); + containsRtiV2xMessages("veh_0", startTime, endTimeGlobaleRegion, sampleV2XMessage.getId(), 560 * DATA.BIT); + containsRtiV2xMessages("veh_1", startTime, endTimeGlobaleRegion, sampleV2XMessage.getId(), 560 * DATA.BIT); + containsRtiV2xMessages("veh_2", startTime, endTimeKreuzberg, sampleV2XMessage.getId(), 4480 * DATA.BIT); } @Test @@ -335,7 +340,7 @@ public void testProcessMessage_regularMessageNodeLimited() throws Exception { String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); - CellConfiguration cellConfiguration = new CellConfiguration(receiverName, true, 400 * DATA.BIT, 400 * DATA.BIT); + CellConfiguration cellConfiguration = new CellConfiguration(receiverName, true, 2240 * DATA.BIT, 2240 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode(receiverName, cellConfiguration); // RUN @@ -346,11 +351,11 @@ public void testProcessMessage_regularMessageNodeLimited() throws Exception { assertEquals(1, rtiV2xReceptionsSent.size()); assertEquals(1, cellModuleMessages.size()); long endTime = 10 * TIME.SECOND + 200 * TIME.MILLI_SECOND; - checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 400 * DATA.BIT, 10 * TIME.SECOND, endTime); + checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 2240 * DATA.BIT, 10 * TIME.SECOND, endTime); testRtiV2xMessages(0, receiverName, endTime, sampleV2XMessage.getId()); assertEquals(0L, SimulationData.INSTANCE.getCellConfigurationOfNode(receiverName).getAvailableDownlinkBitrate()); - assertEquals((42000 - 400) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); + assertEquals((42000 - 2240) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); } @Test @@ -362,10 +367,10 @@ public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() thro String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); - CellConfiguration cellConfiguration = new CellConfiguration(receiverName, true, 400 * DATA.BIT, 400 * DATA.BIT); + CellConfiguration cellConfiguration = new CellConfiguration(receiverName, true, 2240 * DATA.BIT, 2240 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode(receiverName, cellConfiguration); - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 600 * DATA.BIT; - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 600 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 3360 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 3360 * DATA.BIT; // RUN downstreamModule.processEvent(event); @@ -375,11 +380,11 @@ public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() thro assertEquals(1, rtiV2xReceptionsSent.size()); assertEquals(1, cellModuleMessages.size()); long endTime = 10 * TIME.SECOND + 200 * TIME.MILLI_SECOND; - checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 400 * DATA.BIT, 10 * TIME.SECOND, endTime); + checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 2240 * DATA.BIT, 10 * TIME.SECOND, endTime); testRtiV2xMessages(0, receiverName, endTime, sampleV2XMessage.getId()); assertEquals(0, SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0").getAvailableDownlinkBitrate()); - assertEquals((600 - 400) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); + assertEquals((3360 - 2240) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); } @Test @@ -391,10 +396,10 @@ public void testProcessMessage_regularMessageNodeLimitedRegionMoreLimited() thro String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); - CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 400 * DATA.BIT, 400 * DATA.BIT); + CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 2240 * DATA.BIT, 2240 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode("veh_0", cellConfiguration); - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 200 * DATA.BIT; - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 200 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 1120 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 1120 * DATA.BIT; // RUN downstreamModule.processEvent(event); @@ -404,10 +409,10 @@ public void testProcessMessage_regularMessageNodeLimitedRegionMoreLimited() thro assertEquals(1, rtiV2xReceptionsSent.size()); assertEquals(1, cellModuleMessages.size()); long endTime = 10 * TIME.SECOND + 400 * TIME.MILLI_SECOND; - checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 200, 10 * TIME.SECOND, endTime); + checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, 1120, 10 * TIME.SECOND, endTime); testRtiV2xMessages(0, receiverName, endTime, sampleV2XMessage.getId()); - assertEquals((400 - 200) * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0").getAvailableDownlinkBitrate()); + assertEquals((2240 - 1120) * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0").getAvailableDownlinkBitrate()); assertEquals(0L, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); } @@ -424,9 +429,9 @@ public void testProcessMessage_regularMessageNodeLimitedRegionBlocked() throws E String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); - CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 400 * DATA.BIT, 400 * DATA.BIT); + CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 2240 * DATA.BIT, 400 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode(receiverName, cellConfiguration); - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 600 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 3360 * DATA.BIT; // RUN downstreamModule.processEvent(event); @@ -439,8 +444,8 @@ public void testProcessMessage_regularMessageNodeLimitedRegionBlocked() throws E List nackReasons = Collections.singletonList(NegativeAckReason.CHANNEL_CAPACITY_EXCEEDED); testRtiAckMessages(0, nackReasons, sampleV2XMessage); - assertEquals(400 * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode(receiverName).getAvailableDownlinkBitrate()); - assertEquals(600 * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); + assertEquals(2240 * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode(receiverName).getAvailableDownlinkBitrate()); + assertEquals(3360 * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); } @Test @@ -462,7 +467,8 @@ public void testProcessMessage_regularMessageNodeUnlimited_plusFreeBandwidth() t assertEquals(1, rtiV2xReceptionsSent.size()); testRtiV2xMessages(0, receiverName, endTime, sampleV2XMessage.getId()); - long expectedBandwidthInBps = (long) (messageLength / (DELAY_VALUE_IN_MS / (double) TIME.SECOND)); + long actualMessageLength = messageLength + HEADER_UDP + HEADER_IP + HEADER_CELLULAR; + long expectedBandwidthInBps = (long) (actualMessageLength / (DELAY_VALUE_IN_MS / (double) TIME.SECOND)); assertEquals(1, cellModuleMessages.size()); checkNotifyOnFinishMessage(0, GLOBAL_NETWORK_ID, expectedBandwidthInBps, 10 * TIME.SECOND, endTime); @@ -501,9 +507,9 @@ public void testProcessMessage_regularMessageNodeUnlimitedRegionLimited() throws String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 200 * DATA.BIT; - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 200 * DATA.BIT; - long expectedBandwidthInBps = 200 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 1120 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 1120 * DATA.BIT; + long expectedBandwidthInBps = 1120 * DATA.BIT; long endTime = (long) (10.4 * TIME.SECOND); // RUN @@ -542,7 +548,8 @@ public void testProcessMessage_packetLossTcp() throws Exception { ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.unicast.transmission.lossProbability = 2d; double delayInS = ((ConstantDelay) ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.unicast.delay).delay / (double) TIME.SECOND; - long expectedBandwidth = (long) (messageLength / delayInS); + long actualMessageLength = messageLength + HEADER_TCP + HEADER_IP + HEADER_CELLULAR; + long expectedBandwidth = (long) (actualMessageLength / delayInS); long endTime = 10 * TIME.SECOND + DELAY_VALUE_IN_MS; // RUN @@ -578,7 +585,8 @@ public void testProcessMessage_packetLossUdp() throws Exception { ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.unicast.transmission.lossProbability = 2d; ConstantDelay delay = (ConstantDelay) ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.unicast.delay; double delayValue = (double) delay.delay / TIME.MILLI_SECOND; - long expectedBandwidth = (long) (messageLength / ((delayValue / (double) TIME.MICRO_SECOND))); + long actualMessageLength = messageLength + HEADER_UDP + HEADER_IP + HEADER_CELLULAR; + long expectedBandwidth = (long) (actualMessageLength / ((delayValue / (double) TIME.MICRO_SECOND))); // RUN downstreamModule.processEvent(event); @@ -644,8 +652,8 @@ public void testProcessMessage_nodeCapacityExceededRegionLimited() throws Except CellConfiguration cellConfiguration = SimulationData.INSTANCE.getCellConfigurationOfNode(receiverName); cellConfiguration.consumeDownlink(Long.MAX_VALUE * DATA.BIT); - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 200 * DATA.BIT; - ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 200 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = 1140 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.maxCapacity = 1140 * DATA.BIT; // RUN downstreamModule.processEvent(event); @@ -659,7 +667,7 @@ public void testProcessMessage_nodeCapacityExceededRegionLimited() throws Except testRtiAckMessages(0, nackReasons, sampleV2XMessage); assertEquals(0L, SimulationData.INSTANCE.getCellConfigurationOfNode(receiverName).getAvailableDownlinkBitrate()); - assertEquals(200 * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); + assertEquals(1140 * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity); } @Test diff --git a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/UpstreamModuleTest.java b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/UpstreamModuleTest.java index ae2ed6bb8..bc6b63763 100644 --- a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/UpstreamModuleTest.java +++ b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/UpstreamModuleTest.java @@ -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 = 18 * DATA.BYTE; + @Rule public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.LENIENT); @@ -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, 2240 * DATA.BIT, 2240 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode("veh_0", cellConfiguration); // RUN @@ -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, 2240 * 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, 2240 * 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 - 2240) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity); } @Test @@ -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, 2240 * DATA.BIT, 2240 * 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); @@ -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, 2240 * 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, 2240 * 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 - 2240) * DATA.BIT, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity); } @Test @@ -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, 2240 * DATA.BIT, 2240 * 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 = 1120 * DATA.BIT; + ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.maxCapacity = 1120 * DATA.BIT; SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); Event event = new Event(10 * TIME.SECOND, upstreamModule, sampleV2XMessage); @@ -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, 1120, 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, 1120, 10 * TIME.SECOND, (long) (10.4 * TIME.SECOND)); - assertEquals((400 - 200) * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0").getAvailableUplinkBitrate()); + assertEquals((2240 - 1120) * DATA.BIT, SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0").getAvailableUplinkBitrate()); assertEquals(0L, ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity); } @@ -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); @@ -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); @@ -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.448 * TIME.SECOND)); CellModuleMessage resultMessage = cellModuleMessages.get(1); checkResultMessage(resultMessage, expectedBandwidth, 10 * TIME.SECOND, - (long) (10.4 * TIME.SECOND)); + (long) (10.448 * TIME.SECOND)); assertEquals( (Long.MAX_VALUE - expectedBandwidth) * DATA.BIT, @@ -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); @@ -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); diff --git a/fed/mosaic-cell/src/test/resources/logback-test.xml b/fed/mosaic-cell/src/test/resources/logback-test.xml new file mode 100644 index 000000000..c75d693ec --- /dev/null +++ b/fed/mosaic-cell/src/test/resources/logback-test.xml @@ -0,0 +1,12 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + \ No newline at end of file diff --git a/lib/mosaic-utils/src/main/java/org/eclipse/mosaic/lib/util/gson/DataFieldAdapter.java b/lib/mosaic-utils/src/main/java/org/eclipse/mosaic/lib/util/gson/DataFieldAdapter.java index 21ad7faad..c9578490f 100644 --- a/lib/mosaic-utils/src/main/java/org/eclipse/mosaic/lib/util/gson/DataFieldAdapter.java +++ b/lib/mosaic-utils/src/main/java/org/eclipse/mosaic/lib/util/gson/DataFieldAdapter.java @@ -36,6 +36,22 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * Adapter for JSON fields which translates values as string representatives to + * actual long values representing the number of bits, e.g. + *
for size: "10 Bytes" -> 80, "2kbit" -> 2000 + *
for bandwidth: "10 MBps km/h" -> 80000000, "5 kbps" -> 5000 + *

+ * Note: using "b" or "B" is a difference, as former stands for bits and later for bytes. + *

+ * Usage: + *
+ *
+ *  @JsonAdapter(DataFieldAdapter.Size.class)
+ *  public long size;
+ *
+ * 
+ */ public class DataFieldAdapter extends TypeAdapter { private static final Logger log = LoggerFactory.getLogger(DataFieldAdapter.class); @@ -149,7 +165,6 @@ private long determineMultiplier(String prefix, String unit) { } } - public static class Bandwidth implements TypeAdapterFactory { @SuppressWarnings("unchecked") diff --git a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/CellSnsCamSendAndReceiveIT.java b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/CellSnsCamSendAndReceiveIT.java index acfaa5175..970d280ad 100644 --- a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/CellSnsCamSendAndReceiveIT.java +++ b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/CellSnsCamSendAndReceiveIT.java @@ -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) - (120 messages not sendable due to capacity limit) messages from veh_1 = 32 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: 273.*"); } @Test @@ -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.*", 8); // 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.*", 8); // 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.*", 15); // adhoc // test pattern no interference with ad hoc rsus @@ -211,7 +211,7 @@ public void roundTripMessageTakesRightAmountOfTime() throws Exception { 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 delayVehDownload = 57 * TIME.MILLI_SECOND; //TODO check those values, are those random? if so, than its not ideal for a test + long delayVehDownload = 67 * TIME.MILLI_SECOND; //TODO check those values, are those random? if so, than its not ideal for a test long timeFromTmcToVeh = delayTmcUpload + delayVehDownload; long timeFromVehToTmc = delayVehUpload + delayTmcDownload; diff --git a/test/scenarios/cell-sns-cam-send-and-receive/cell/cell_config.json b/test/scenarios/cell-sns-cam-send-and-receive/cell/cell_config.json index ff729782a..920100c68 100644 --- a/test/scenarios/cell-sns-cam-send-and-receive/cell/cell_config.json +++ b/test/scenarios/cell-sns-cam-send-and-receive/cell/cell_config.json @@ -1,4 +1,11 @@ { "networkConfigurationFile": "network.json", - "regionConfigurationFile": "regions.json" + "regionConfigurationFile": "regions.json", + "headerLengths": { + "udpHeader": "8 Bytes", + "tcpHeader": "20 Bytes", + "ipHeader": "20 Bytes", + "cellularHeader": "18 Bytes", + "ethernetHeader": "18 Bytes" + } } \ No newline at end of file