Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cell): model header sizes for messages transmitted by cell #369

Merged
merged 9 commits into from
Feb 16, 2024
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": "18 Bytes",
"ethernetHeader": "18 Bytes"
}
}
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": "18 Bytes",
"ethernetHeader": "18 Bytes"
}
rprotzmann marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
*
Expand Down Expand Up @@ -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.<br>
* 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)
*/
rprotzmann marked this conversation as resolved.
Show resolved Hide resolved
@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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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 \"{}\" "
Expand Down Expand Up @@ -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 {}"
Expand Down Expand Up @@ -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 {}"
Expand Down Expand Up @@ -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 \"{}\" "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
rprotzmann marked this conversation as resolved.
Show resolved Hide resolved
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
rprotzmann marked this conversation as resolved.
Show resolved Hide resolved
linkLayerHeader = headerLengths.ethernetHeader;
} else {
linkLayerHeader = headerLengths.cellularHeader;
}
switch (msg.getRouting().getDestination().getProtocolType()) {
rprotzmann marked this conversation as resolved.
Show resolved Hide resolved
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;
}
}

/**
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
Loading
Loading