diff --git a/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherServerApp.java b/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherServerApp.java index e7c80c4bc..6fd80de93 100644 --- a/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherServerApp.java +++ b/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherServerApp.java @@ -22,9 +22,7 @@ import org.eclipse.mosaic.fed.application.app.api.CommunicationApplication; import org.eclipse.mosaic.fed.application.app.api.os.ServerOperatingSystem; import org.eclipse.mosaic.interactions.communication.V2xMessageTransmission; -import org.eclipse.mosaic.lib.enums.SensorType; import org.eclipse.mosaic.lib.geo.GeoCircle; -import org.eclipse.mosaic.lib.geo.GeoPoint; import org.eclipse.mosaic.lib.objects.v2x.MessageRouting; import org.eclipse.mosaic.lib.objects.v2x.V2xMessage; import org.eclipse.mosaic.lib.objects.v2x.etsi.Denm; @@ -110,7 +108,7 @@ private void sample() { */ private Denm constructDenm() { final GeoCircle geoCircle = new GeoCircle(lastReceivedMessage.getEventLocation(), 3000.0D); - final MessageRouting routing = getOs().getCellModule().createMessageRouting().geoBroadcastBasedOnUnicast(geoCircle); + final MessageRouting routing = getOs().getCellModule().createMessageRouting().broadcast().geographical(geoCircle).build(); return new Denm(routing, new DenmContent( lastReceivedMessage.getTime(), diff --git a/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherWarningApp.java b/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherWarningApp.java index a4625a28c..ba209f1a6 100644 --- a/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherWarningApp.java +++ b/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherWarningApp.java @@ -206,7 +206,7 @@ private void reactOnEnvironmentData(SensorType type, int strength) { * with a builder and build a geoBroadCast for the circle area defined in dest. */ if (useCellNetwork()) { - mr = getOs().getCellModule().createMessageRouting().topoCast("server_0"); + mr = getOs().getCellModule().createMessageRouting().destination("server_0").topological().build(); } else { mr = getOs().getAdHocModule().createMessageRouting().broadcast().geographical(dest).build(); } diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/CellModule.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/CellModule.java index 0a55b687f..32509cc2a 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/CellModule.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/CellModule.java @@ -126,7 +126,7 @@ public Integer sendCam() { } private Integer sendCamViaTopocast(CellModuleConfiguration.CellCamConfiguration camConfiguration) { - return super.sendCam(createMessageRouting().topoCast(camConfiguration.getTopocastReceiver())); + return super.sendCam(createMessageRouting().destination(camConfiguration.getTopocastReceiver()).topological().build()); } private Integer sendCamViaGeoBroadcast(CellModuleConfiguration.CellCamConfiguration camConfiguration) { @@ -134,7 +134,7 @@ private Integer sendCamViaGeoBroadcast(CellModuleConfiguration.CellCamConfigurat throw new UnsupportedOperationException("Cannot send CAM for entities without a location."); } final GeoCircle destination = new GeoCircle(locatable.getPosition(), camConfiguration.getGeoRadius()); - return super.sendCam(createMessageRouting().geoBroadcastBasedOnUnicast(destination)); + return super.sendCam(createMessageRouting().broadcast().geographical(destination).build()); } private Integer sendCamViaGeoBroadcastMbms(CellModuleConfiguration.CellCamConfiguration camConfiguration) { @@ -142,7 +142,7 @@ private Integer sendCamViaGeoBroadcastMbms(CellModuleConfiguration.CellCamConfig throw new UnsupportedOperationException("Cannot send CAM for entities without a location."); } final GeoCircle destination = new GeoCircle(locatable.getPosition(), camConfiguration.getGeoRadius()); - return super.sendCam(createMessageRouting().geoBroadcastMbms(destination)); + return super.sendCam(createMessageRouting().broadcast().geographical(destination).mbs().build()); } /** diff --git a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/chain/ChainManagerTest.java b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/chain/ChainManagerTest.java index 89b149e68..0e4549e62 100644 --- a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/chain/ChainManagerTest.java +++ b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/chain/ChainManagerTest.java @@ -112,7 +112,10 @@ public void addEvent(@Nonnull Event event) { @Test public void testStartEvent_cellRouting() { //SETUP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); V2xMessageTransmission sendV2xMsg = new V2xMessageTransmission(12 * TIME.SECOND, v2XMessage); @@ -127,7 +130,7 @@ public void testStartEvent_cellRouting() { @Test public void testStartEvent_adhocRouting() { //SETUP - routing.set(new AdHocMessageRoutingBuilder("veh_0", null).singlehop().broadcast().topological().build()); + routing.set(new AdHocMessageRoutingBuilder("veh_0", null).broadcast().topological().build()); V2xMessageTransmission sendV2xMsg = new V2xMessageTransmission(12 * TIME.SECOND, v2XMessage); diff --git a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/DownstreamModuleStreamingTest.java b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/DownstreamModuleStreamingTest.java index a58b7ac6b..7cc517975 100644 --- a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/DownstreamModuleStreamingTest.java +++ b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/DownstreamModuleStreamingTest.java @@ -172,8 +172,7 @@ public void testProcessMessage_regularMessageMulticast() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); final Multimap receiverMap = ArrayListMultimap.create(); @@ -211,8 +210,7 @@ public void testProcessMessage_regularMessageMulticast_NodeLimited() throws Exce routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); final Multimap receiverMap = ArrayListMultimap.create(); @@ -252,7 +250,7 @@ public void testProcessMessage_regularMessageMulticast_NodeLimitedRegionLimited( routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); final Multimap receiverMap = ArrayListMultimap.create(); @@ -289,8 +287,7 @@ public void testProcessMessage_regularMessageMulticast_MultipleRegions() throws routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); final Multimap receiverMap = ArrayListMultimap.create(); @@ -353,9 +350,8 @@ public void testProcessMessage_regularMessageNodeLimited() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - )) - ; + .destination(new byte[]{1, 2, 3, 4}).topological().build() + ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); @@ -381,8 +377,7 @@ public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() thro routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; @@ -411,8 +406,7 @@ public void testProcessMessage_regularMessageNodeLimitedRegionMoreLimited() thro routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; @@ -441,8 +435,7 @@ public void testProcessMessage_regularMessageNodeUnlimited_plusFreeBandwidth() t routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; @@ -485,8 +478,7 @@ public void testProcessMessage_regularMessageNodeUnlimitedRegionLimited() throws routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; @@ -513,7 +505,7 @@ public void testProcessMessage_TransmissionAfterPacketLossTcp() throws Exception new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); @@ -551,8 +543,7 @@ public void testProcessMessage_packetLossUdp() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); @@ -589,8 +580,7 @@ public void testProcessMessage_nodeCapacityExceededRegionUnlimited() throws Exce new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; @@ -622,8 +612,7 @@ public void testProcessMessage_nodeCapacityExceededRegionLimited() throws Except new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; @@ -657,8 +646,7 @@ public void testProcessMessage_channelCapacityExceededTcp() throws Exception { new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; @@ -689,8 +677,7 @@ public void testProcessMessage_channelNodeCapacityExceeded() throws Exception { new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; @@ -724,8 +711,7 @@ public void testProcessMessage_nodeDeactivatedTcp() throws Exception { new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); String receiverName = "veh_0"; @@ -756,8 +742,7 @@ public void testProcessMessage_nodeDeactivatedUdp() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5); String receiverName = "veh_0"; @@ -782,8 +767,7 @@ public void testProcessMessage_nodeNotRegisteredTcp() throws Exception { new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5); Event event = createEvent("rsu_4", sampleV2XMessage); @@ -809,8 +793,7 @@ public void testProcessMessage_nodeNotRegisteredUdp() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); Event event = createEvent("rsu_4", sampleV2XMessage); @@ -835,8 +818,7 @@ public void testFreeBandwidth_regularMessage() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EVENT_BANDWIDTH) - .topoCast(new byte[]{1, 2, 3, 4} - ) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); StreamResult streamResult = 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 a2950c2f4..ce7d55a52 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 @@ -162,7 +162,10 @@ public void finishEvent(CellModuleMessage cellModuleMessage) { public void testProcessMessage_regularMessageMulticast() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); final Multimap receiverMap = ArrayListMultimap.create(); String[] receivers = {"veh_0", "veh_1", "veh_2"}; @@ -199,7 +202,10 @@ public void testProcessMessage_regularMessageMulticast() throws Exception { public void testProcessMessage_regularMessageMulticast_NodeLimited() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); final Multimap receiverMap = ArrayListMultimap.create(); String[] receivers = {"veh_0", "veh_1", "veh_2"}; @@ -236,7 +242,10 @@ public void testProcessMessage_regularMessageMulticast_NodeLimitedRegionLimited( 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})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); final Multimap receiverMap = ArrayListMultimap.create(); String[] receivers = {"veh_0", "veh_1", "veh_2"}; @@ -277,7 +286,10 @@ public void testProcessMessage_regularMessageMulticast_MultipleRegions() throws 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})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); final Multimap receiverMap = ArrayListMultimap.create(); String[] receivers = {"veh_0", "veh_1", "veh_2"}; @@ -335,7 +347,10 @@ public void testProcessMessage_regularMessageMulticast_MultipleRegions() throws public void testProcessMessage_regularMessageNodeLimited() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); @@ -362,7 +377,10 @@ public void testProcessMessage_regularMessageNodeLimited() throws Exception { public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); @@ -391,7 +409,10 @@ public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() thro public void testProcessMessage_regularMessageNodeLimitedRegionMoreLimited() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); @@ -423,7 +444,7 @@ public void testProcessMessage_regularMessageNodeLimitedRegionBlocked() throws E routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); String receiverName = "veh_0"; @@ -452,7 +473,7 @@ public void testProcessMessage_regularMessageNodeLimitedRegionBlocked() throws E public void testProcessMessage_regularMessageNodeUnlimited_plusFreeBandwidth() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null).destination(new byte[]{1, 2, 3, 4}).topological().build()); long messageLength = 10 * DATA.BYTE; SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), messageLength); String receiverName = "veh_0"; @@ -501,7 +522,10 @@ public void testProcessMessage_regularMessageNodeUnlimited_plusFreeBandwidth() t public void testProcessMessage_regularMessageNodeUnlimitedRegionLimited() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); long messageLength = 10 * DATA.BYTE; SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), messageLength); String receiverName = "veh_0"; @@ -538,7 +562,7 @@ public void testProcessMessage_packetLossTcp() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); long messageLength = 10 * DATA.BYTE; SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), messageLength); @@ -576,7 +600,7 @@ public void testProcessMessage_packetLossTcp() throws Exception { public void testProcessMessage_packetLossUdp() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null).destination(new byte[]{1, 2, 3, 4}).topological().build()); long messageLength = 10 * DATA.BYTE; SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), messageLength); String receiverName = "veh_0"; @@ -612,7 +636,7 @@ public void testProcessMessage_nodeCapacityExceededRegionUnlimited() throws Exce routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); long messageLength = 10 * DATA.BYTE; SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), messageLength); @@ -644,7 +668,7 @@ public void testProcessMessage_nodeCapacityExceededRegionLimited() throws Except routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); String receiverName = "veh_0"; @@ -677,7 +701,7 @@ public void testProcessMessage_channelCapacityExceededTcp() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); String receiverName = "veh_0"; @@ -707,7 +731,7 @@ public void testProcessMessage_channelNodeCapacityExceeded() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); String receiverName = "veh_0"; @@ -741,7 +765,7 @@ public void testProcessMessage_nodeDeactivatedTcp() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); String receiverName = "veh_0"; @@ -769,7 +793,7 @@ public void testProcessMessage_nodeDeactivatedTcp() throws Exception { public void testProcessMessage_nodeDeactivatedUdp() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null).destination(new byte[]{1, 2, 3, 4}).topological().build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); String receiverName = "veh_0"; Event event = createEvent(receiverName, sampleV2XMessage); @@ -792,7 +816,7 @@ public void testProcessMessage_nodeNotRegisteredTcp() throws Exception { routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{1, 2, 3, 4}) + .destination(new byte[]{1, 2, 3, 4}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); Event event = createEvent("rsu_4", sampleV2XMessage); @@ -815,7 +839,7 @@ public void testProcessMessage_nodeNotRegisteredTcp() throws Exception { public void testProcessMessage_nodeNotRegisteredUdp() throws Exception { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null).destination(new byte[]{1, 2, 3, 4}).topological().build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); Event event = createEvent("rsu_4", sampleV2XMessage); @@ -835,7 +859,7 @@ public void testFreeBandwidth_regularMessage() throws Exception { NodeCapacityUtility.consumeCapacityDown(cellConfiguration, 200 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode(receiverName, cellConfiguration); ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.downlink.capacity = (42000 - 200) * DATA.BIT; - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null).destination(new byte[]{1, 2, 3, 4}).topological().build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); StreamResult streamResult = new StreamResult(GLOBAL_NETWORK_ID, 200 * DATA.BIT, TransmissionMode.DownlinkUnicast, receiverName, sampleV2XMessage); diff --git a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/GeocasterModuleTest.java b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/GeocasterModuleTest.java index 3906dce0f..f07f1c72d 100644 --- a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/GeocasterModuleTest.java +++ b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/GeocasterModuleTest.java @@ -19,8 +19,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.when; import org.eclipse.mosaic.fed.cell.chain.ChainManager; import org.eclipse.mosaic.fed.cell.chain.SampleV2xMessage; @@ -34,7 +32,6 @@ import org.eclipse.mosaic.fed.cell.message.GeocasterResult; import org.eclipse.mosaic.fed.cell.message.StreamResult; import org.eclipse.mosaic.fed.cell.utility.RegionUtility; -import org.eclipse.mosaic.lib.enums.ProtocolType; import org.eclipse.mosaic.lib.geo.GeoPoint; import org.eclipse.mosaic.lib.geo.GeoRectangle; import org.eclipse.mosaic.lib.geo.UtmPoint; @@ -44,18 +41,12 @@ import org.eclipse.mosaic.lib.math.DefaultRandomNumberGenerator; import org.eclipse.mosaic.lib.math.RandomNumberGenerator; import org.eclipse.mosaic.lib.objects.addressing.CellMessageRoutingBuilder; -import org.eclipse.mosaic.lib.objects.addressing.DestinationAddressContainer; import org.eclipse.mosaic.lib.objects.addressing.IpResolver; -import org.eclipse.mosaic.lib.objects.addressing.SourceAddressContainer; import org.eclipse.mosaic.lib.objects.communication.CellConfiguration; import org.eclipse.mosaic.lib.objects.v2x.MessageRouting; -import org.eclipse.mosaic.lib.objects.v2x.V2xMessage; import org.eclipse.mosaic.lib.util.scheduling.Event; import org.eclipse.mosaic.rti.DATA; import org.eclipse.mosaic.rti.TIME; -import org.eclipse.mosaic.rti.api.IllegalValueException; -import org.eclipse.mosaic.rti.api.Interaction; -import org.eclipse.mosaic.rti.api.InternalFederateException; import org.eclipse.mosaic.rti.api.RtiAmbassador; import org.eclipse.mosaic.rti.api.parameters.AmbassadorParameter; @@ -65,7 +56,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.RuleChain; -import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; @@ -141,7 +131,10 @@ public void testCellTopocast() { SimulationData.INSTANCE.setCellConfigurationOfNode("veh_2", cellModuleConfiguration); IpResolver.getSingleton().registerHost("veh_2"); - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 0, 0, 2})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{10, 0, 0, 2}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); StreamResult streamResult = new StreamResult(GLOBAL_NETWORK_ID, 200 * DATA.BIT, TransmissionMode.UplinkUnicast, "rsu_0", sampleV2XMessage); @@ -175,7 +168,7 @@ public void testCellGeoUnicast() { GeoPoint nw = GeoPoint.lonLat(13.333625793457031, 52.51563064800963); GeoPoint se = GeoPoint.lonLat(13.421859741210938, 52.5053554452214); GeoRectangle geoRectangle = new GeoRectangle(nw, se); - routing.set(new CellMessageRoutingBuilder("veh_0", null).geoBroadcastBasedOnUnicast(geoRectangle)); + routing.set(new CellMessageRoutingBuilder("veh_0", null).broadcast().geographical(geoRectangle).build()); GeoPoint inRectangleKreuzberg = GeoPoint.lonLat(13.404693603515625, 52.50838549553871); GeoPoint inRectangleGrosserStern = GeoPoint.lonLat(13.349933624267578, 52.51388868388495); GeoPoint offRectangleKreuzberg = GeoPoint.lonLat(13.404006958007812, 52.498111211481216); @@ -230,7 +223,7 @@ public void testCellGeoBroadcastMbms() { GeoPoint nw = GeoPoint.lonLat(13.333625793457031, 52.51563064800963); GeoPoint se = GeoPoint.lonLat(13.421859741210938, 52.5053554452214); GeoRectangle geoRectangle = new GeoRectangle(nw, se); - routing.set(new CellMessageRoutingBuilder("veh_0", null).geoBroadcastMbms(geoRectangle)); + routing.set(new CellMessageRoutingBuilder("veh_0", null).broadcast().mbs().geographical(geoRectangle).build()); GeoPoint inRectangleKreuzberg = GeoPoint.lonLat(13.404693603515625, 52.50838549553871); GeoPoint inRectangleGrosserStern = GeoPoint.lonLat(13.349933624267578, 52.51388868388495); GeoPoint offRectangleKreuzberg = GeoPoint.lonLat(13.404006958007812, 52.498111211481216); diff --git a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/UpstreamModuleStreamingTest.java b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/UpstreamModuleStreamingTest.java index 34c1f556d..5ee21acee 100644 --- a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/UpstreamModuleStreamingTest.java +++ b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/module/UpstreamModuleStreamingTest.java @@ -168,7 +168,7 @@ public void testProcessMessage_regularMessageNodeLimited() throws InternalFedera // UDP routing.set(new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EXPECTED_BANDWIDTH) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); @@ -193,7 +193,7 @@ public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() thro // UDP routing.set(new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EXPECTED_BANDWIDTH) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 400L, 400L); @@ -220,7 +220,7 @@ public void testProcessMessage_regularMessageNodeLimitedRegionMoreLimited() thro // UDP routing.set(new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EXPECTED_BANDWIDTH) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 400L, 400L); @@ -252,7 +252,7 @@ public void testProcessMessage_regularMessageNodeLimitedRegionWouldBeBlockedButI new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, 10) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); int smallerStreamSize = 10; @@ -287,7 +287,8 @@ public void testProcessMessage_regularMessageNodeUnlimited_plusFreeBandwidth() t // SETUP // UDP MessageRouting messageRouting = new CellMessageRoutingBuilder("veh_0", null) - .streaming(EVENT_DURATION, EXPECTED_BANDWIDTH).topoCast(new byte[]{10, 2, 0, 0}); + .streaming(EVENT_DURATION, EXPECTED_BANDWIDTH) + .destination(new byte[]{10, 2, 0, 0}).topological().build(); routing.set(messageRouting); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); @@ -331,7 +332,7 @@ public void testProcessMessage_regularMessageNodeUnlimitedRegionLimited() throws routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EXPECTED_BANDWIDTH) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); @@ -362,7 +363,7 @@ public void testProcessMessage_packetLossTcp() throws InternalFederateException new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, 1000) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); @@ -395,7 +396,7 @@ public void testProcessMessage_packetLossUdp() throws InternalFederateException routing.set( new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EXPECTED_BANDWIDTH) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), MESSAGE_SIZE); @@ -430,7 +431,7 @@ public void testProcessMessage_nodeCapacityExceededRegionUnlimited() throws Inte new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, 10) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5); @@ -461,7 +462,7 @@ public void testProcessMessage_nodeCapacityExceededRegionLimited() throws Intern new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, 10) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); CellConfiguration cellConfiguration = SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0"); @@ -494,7 +495,7 @@ public void testProcessMessage_channelCapacityExceededTcp() throws InternalFeder new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, 10) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5); @@ -524,7 +525,7 @@ public void testProcessMessage_channelNodeCapacityExceededTcp() throws InternalF new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, 10) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5); @@ -558,7 +559,7 @@ public void testProcessMessage_nodeDeactivatedTcp() throws InternalFederateExcep new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) .streaming(EVENT_DURATION, 10) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5); @@ -588,7 +589,7 @@ public void testProcessMessage_nodeDeactivatedUdp() throws InternalFederateExcep // UDP routing.set(new CellMessageRoutingBuilder("veh_0", null) .streaming(EVENT_DURATION, EXPECTED_BANDWIDTH) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5); @@ -643,7 +644,7 @@ public void testProcessMessage_nodeNotRegisteredUdp() { IpResolver.getSingleton().registerHost("veh_1"); routing.set(new CellMessageRoutingBuilder("veh_1", null) .streaming(EVENT_DURATION, EXPECTED_BANDWIDTH) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5); 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 bc6b63763..7be1decda 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 @@ -163,7 +163,10 @@ public void finishEvent(CellModuleMessage cellModuleMessage) { public void testProcessMessage_regularMessageNodeLimited() throws InternalFederateException { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 2, 0, 0})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{10, 2, 0, 0}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); Event event = new Event(10 * TIME.SECOND, upstreamModule, sampleV2XMessage); @@ -190,7 +193,10 @@ public void testProcessMessage_regularMessageNodeLimited() throws InternalFedera public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() throws InternalFederateException { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 2, 0, 0})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{10, 2, 0, 0}) + .topological() + .build()); CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 2240 * DATA.BIT, 2240 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode("veh_0", cellConfiguration); @@ -220,7 +226,10 @@ public void testProcessMessage_regularMessageNodeLimitedRegionLessLimited() thro public void testProcessMessage_regularMessageNodeLimitedRegionMoreLimited() throws InternalFederateException { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 2, 0, 0})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{10, 2, 0, 0}) + .topological() + .build()); CellConfiguration cellConfiguration = new CellConfiguration("veh_0", true, 2240 * DATA.BIT, 2240 * DATA.BIT); SimulationData.INSTANCE.setCellConfigurationOfNode("veh_0", cellConfiguration); @@ -253,7 +262,7 @@ public void testProcessMessage_regularMessageNodeLimitedRegionBlocked() throws I routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 10 * DATA.BYTE); @@ -282,7 +291,10 @@ public void testProcessMessage_regularMessageNodeLimitedRegionBlocked() throws I public void testProcessMessage_regularMessageNodeUnlimited_plusFreeBandwidth() throws InternalFederateException { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 2, 0, 0})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{10, 2, 0, 0}) + .topological() + .build()); long messageLength = 10 * DATA.BYTE; SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), messageLength); @@ -326,7 +338,10 @@ public void testProcessMessage_regularMessageNodeUnlimited_plusFreeBandwidth() t public void testProcessMessage_regularMessageNodeUnlimitedRegionLimited() throws InternalFederateException { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 2, 0, 0})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{10, 2, 0, 0}) + .topological() + .build()); long messageLength = 10 * DATA.BYTE; SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), messageLength); @@ -366,7 +381,7 @@ public void testProcessMessage_packetLossTcp() throws InternalFederateException routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); long messageLength = 10 * DATA.BYTE; @@ -404,7 +419,10 @@ public void testProcessMessage_packetLossTcp() throws InternalFederateException public void testProcessMessage_packetLossUdp() throws InternalFederateException { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 2, 0, 0})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{10, 2, 0, 0}) + .topological() + .build()); long messageLength = 10 * DATA.BYTE; SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), messageLength); @@ -441,7 +459,7 @@ public void testProcessMessage_nodeCapacityExceededRegionUnlimited() throws Inte routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); @@ -471,7 +489,7 @@ public void testProcessMessage_nodeCapacityExceededRegionLimited() throws Intern routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); CellConfiguration cellConfiguration = SimulationData.INSTANCE.getCellConfigurationOfNode("veh_0"); @@ -504,7 +522,7 @@ public void testProcessMessage_channelCapacityExceededTcp() throws InternalFeder routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); @@ -533,7 +551,7 @@ public void testProcessMessage_channelNodeCapacityExceeded() throws InternalFede routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); @@ -566,7 +584,7 @@ public void testProcessMessage_nodeDeactivatedTcp() throws InternalFederateExcep routing.set( new CellMessageRoutingBuilder("veh_0", null) .protocol(ProtocolType.TCP) - .topoCast(new byte[]{10, 2, 0, 0}) + .destination(new byte[]{10, 2, 0, 0}).topological().build() ); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); @@ -594,7 +612,10 @@ public void testProcessMessage_nodeDeactivatedTcp() throws InternalFederateExcep public void testProcessMessage_nodeDeactivatedUdp() throws InternalFederateException { // SETUP // UDP - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{10, 2, 0, 0})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{10, 2, 0, 0}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); Event event = new Event(10 * TIME.NANO_SECOND, upstreamModule, sampleV2XMessage); @@ -647,7 +668,10 @@ public void testProcessMessage_nodeNotRegisteredUdp() { // SETUP IpResolver.getSingleton().registerHost("veh_1"); // UDP - routing.set(new CellMessageRoutingBuilder("veh_1", null).topoCast(new byte[]{10, 2, 0, 0})); + routing.set(new CellMessageRoutingBuilder("veh_1", null) + .destination(new byte[]{10, 2, 0, 0}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); Event event = new Event(10 * TIME.NANO_SECOND, upstreamModule, sampleV2XMessage); @@ -668,7 +692,10 @@ public void testFreeBandwidth_regularMessage() { SimulationData.INSTANCE.setCellConfigurationOfNode("veh_0", cellConfiguration); ConfigurationData.INSTANCE.getNetworkConfig().globalNetwork.uplink.capacity = (21000 - 200) * DATA.BIT; - routing.set(new CellMessageRoutingBuilder("veh_0", null).topoCast(new byte[]{1, 2, 3, 4})); + routing.set(new CellMessageRoutingBuilder("veh_0", null) + .destination(new byte[]{1, 2, 3, 4}) + .topological() + .build()); SampleV2xMessage sampleV2XMessage = new SampleV2xMessage(routing.get(), 5 * DATA.BYTE); StreamResult streamResult = new StreamResult( GLOBAL_NETWORK_ID, diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java index 953bb6c71..9589f1ff6 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java @@ -150,7 +150,7 @@ public AdHocMessageRoutingBuilder broadcast() { } /** - * Configures the message to use a topologically scoped routing strategy. + * Configures the message to use a topologically-scoped routing strategy. * @return this builder. */ public AdHocMessageRoutingBuilder topological() { @@ -161,7 +161,7 @@ public AdHocMessageRoutingBuilder topological() { } /** - * Configures the message to use a topologically scoped routing strategy. + * Configures the message to use a geographically-scoped routing strategy. * @param area the area which the message will be transmitted to. * @return this builder. */ diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/CellMessageRoutingBuilder.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/CellMessageRoutingBuilder.java index 976553770..d2da1427d 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/CellMessageRoutingBuilder.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/CellMessageRoutingBuilder.java @@ -18,12 +18,12 @@ import org.eclipse.mosaic.lib.enums.DestinationType; import org.eclipse.mosaic.lib.enums.ProtocolType; import org.eclipse.mosaic.lib.geo.GeoArea; -import org.eclipse.mosaic.lib.geo.GeoCircle; import org.eclipse.mosaic.lib.geo.GeoPoint; -import org.eclipse.mosaic.lib.geo.GeoRectangle; import org.eclipse.mosaic.lib.objects.v2x.MessageRouting; import org.eclipse.mosaic.lib.objects.v2x.MessageStreamRouting; +import org.apache.commons.lang3.Validate; + import java.net.Inet4Address; /** @@ -37,11 +37,20 @@ public class CellMessageRoutingBuilder { private long streamDuration = -1; private long streamBandwidthInBitPs = -1; + private NetworkAddress destination = null; + private DestinationType routing = null; + private GeoArea targetArea = null; + + private boolean destinationChanged = false; + private boolean routingChanged = false; + private boolean mbsChanged = false; + /** * The {@link ProtocolType} for the {@link MessageRouting}, on default this will be * {@link ProtocolType#UDP}. */ private ProtocolType protocolType = ProtocolType.UDP; + private boolean protocolChanged = false; /** * Constructor for {@link CellMessageRoutingBuilder} to set required fields. @@ -62,6 +71,17 @@ public CellMessageRoutingBuilder(String hostName, GeoPoint sourcePosition) { ); } + /** + * Creates the MessageRouting based on the methods called on this builder before. + * @return MessageRouting - The desired routing for a message. + */ + public MessageRouting build() { + checkNecessaryValues(); + return this.build(new DestinationAddressContainer( + routing, destination, null, null, targetArea, protocolType) + ); + } + /** * Defines stream properties for the message to send. * @@ -74,103 +94,148 @@ public CellMessageRoutingBuilder streaming(long streamDuration, long streamBandw return this; } - private MessageRouting build(DestinationAddressContainer dac) { - if (streamDuration < 0) { - return new MessageRouting(dac, sourceAddressContainer); - } else { - return new MessageStreamRouting(dac, sourceAddressContainer, streamDuration, streamBandwidthInBitPs); - } + /** + * Sets the {@link ProtocolType} for the routing. + * + * @param type the {@link ProtocolType} to be used + * @return the {@link CellMessageRoutingBuilder} + */ + public CellMessageRoutingBuilder protocol(ProtocolType type) { + Validate.isTrue(!protocolChanged, "Protocol was already set!"); + protocolType = type; + protocolChanged = true; + return this; } /** - * Creates geo Broadcast (application layer) based on Unicast (network layer) for geo area. + * Sets the {@link ProtocolType} for the routing to {@link ProtocolType#TCP}. * - * @param geoArea destination area as {@link GeoRectangle} or as {@link GeoCircle} - * @return MessageRouting + * @return the {@link CellMessageRoutingBuilder} */ - public MessageRouting geoBroadcastBasedOnUnicast(GeoArea geoArea) { - return build(new DestinationAddressContainer( - DestinationType.CELL_GEOCAST, - new NetworkAddress(NetworkAddress.BROADCAST_ADDRESS.getAddress()), - null, - null, - geoArea, - protocolType - )); + public CellMessageRoutingBuilder tcp() { + return protocol(ProtocolType.TCP); } + /** - * Creates geoBroadCast for destination area using mbms method. + * Sets the {@link ProtocolType} for the routing to {@link ProtocolType#UDP}. * - * @param geoArea destination area as {@link GeoRectangle} or as {@link GeoCircle} - * @return MessageRouting + * @return the {@link CellMessageRoutingBuilder} */ - public MessageRouting geoBroadcastMbms(GeoArea geoArea) { - return build(new DestinationAddressContainer( - DestinationType.CELL_GEOCAST_MBMS, - new NetworkAddress(NetworkAddress.BROADCAST_ADDRESS.getAddress()), - null, - null, - geoArea, - protocolType - )); + public CellMessageRoutingBuilder udp() { + return protocol(ProtocolType.UDP); + } + + public CellMessageRoutingBuilder destination(NetworkAddress networkAddress) { + Validate.isTrue(!destinationChanged, "Destination was already set!"); + this.destination = networkAddress; + this.destinationChanged = true; + return this; } /** - * Creates topoCast to specified ip address. - * - * @param ipAddress recipient's ip address - * @return the {@link MessageRouting} + * Sets the destination of the message being built. + * @param receiverName The string name of the receiving entity. + * @return this builder. */ - public MessageRouting topoCast(byte[] ipAddress) { - return build(new DestinationAddressContainer( - DestinationType.CELL_TOPOCAST, - new NetworkAddress(ipAddress), - null, - null, - null, - protocolType - )); + public CellMessageRoutingBuilder destination(String receiverName) { + return destination(IpResolver.getSingleton().nameToIp(receiverName).getAddress()); } /** - * Creates topological cast to specified host name. - * - * @param name recipient's name - * @return MessageRouting + * Sets the destination of the message being built. + * @param ipAddress The IP address of the target destination as an {@link Inet4Address}. + * @return this builder. */ - public MessageRouting topoCast(String name) { - return topoCast(IpResolver.getSingleton().nameToIp(name).getAddress()); + public CellMessageRoutingBuilder destination(Inet4Address ipAddress) { + return destination(new NetworkAddress(ipAddress)); } /** - * Sets the {@link ProtocolType} for the routing. - * - * @param protocolType the {@link ProtocolType} to be used - * @return the {@link CellMessageRoutingBuilder} + * Sets the destination of the message being built. + * @param ipAddress The IP address of the target destination as an array of bytes. + * @return this builder. */ - public CellMessageRoutingBuilder protocol(ProtocolType protocolType) { - this.protocolType = protocolType; - return this; + public CellMessageRoutingBuilder destination(byte[] ipAddress) { + return destination(new NetworkAddress(ipAddress)); } /** - * Sets the {@link ProtocolType} for the routing to {@link ProtocolType#TCP}. - * - * @return the {@link CellMessageRoutingBuilder} + * A convenience method that sets the destination IP address to the broadcast address. + * @return this builder. */ - public CellMessageRoutingBuilder tcp() { - return protocol(ProtocolType.TCP); + public CellMessageRoutingBuilder broadcast() { + return destination(new NetworkAddress(NetworkAddress.BROADCAST_ADDRESS)); } + /** + * Configures the message to use a Multicast/Broadcast Service for transmission. + * @return this builder. + */ + public CellMessageRoutingBuilder mbs() { + Validate.isTrue(!mbsChanged, "MBS was already chosen!"); + Validate.isTrue(!(routing == DestinationType.CELL_TOPOCAST), "MBS can not be enabled for topological routing!"); + routing = DestinationType.CELL_GEOCAST_MBMS; + mbsChanged = true; + return this; + } /** - * Sets the {@link ProtocolType} for the routing to {@link ProtocolType#UDP}. - * - * @return the {@link CellMessageRoutingBuilder} + * Configures the message to use a topologically-scoped routing strategy. + * @return this builder. */ - public CellMessageRoutingBuilder udp() { - return protocol(ProtocolType.UDP); + public CellMessageRoutingBuilder topological() { + Validate.isTrue(!routingChanged, "Routing was already set!"); + Validate.isTrue(!mbsChanged, "MBS can not be enabled for topological routing!"); + routing = DestinationType.CELL_TOPOCAST; + routingChanged = true; + return this; + } + + /** + * Configures the message to use a geographically-scoped routing strategy. + * @param area the area which the message will be transmitted to. + * @return this builder. + */ + public CellMessageRoutingBuilder geographical(GeoArea area) { + Validate.isTrue(!routingChanged, "Routing was already set!"); + if (!mbsChanged) { + routing = DestinationType.CELL_GEOCAST; + } + targetArea = area; + routingChanged = true; + return this; + } + + private void checkNecessaryValues() { + checkDestination(); + checkRouting(); + checkArea(); + } + + private void checkDestination() { + if (destination == null) { + throw new IllegalArgumentException("No destination address was given! Aborting."); + } + } + + private void checkRouting() { + if (routing == null) { + throw new IllegalArgumentException("No routing protocol was given! Aborting."); + } } + private void checkArea() { + if (routing == DestinationType.CELL_GEOCAST_MBMS && targetArea == null) { + throw new IllegalArgumentException("No target area was given for geographical routing using mbs!" + + "Have you called .geographical(GeoArea)? Aborting."); + } + } + private MessageRouting build(DestinationAddressContainer dac) { + if (streamDuration < 0) { + return new MessageRouting(dac, sourceAddressContainer); + } else { + return new MessageStreamRouting(dac, sourceAddressContainer, streamDuration, streamBandwidthInBitPs); + } + } } diff --git a/lib/mosaic-objects/src/test/java/org/eclipse/mosaic/lib/objects/v2x/CellMessageRoutingBuilderTest.java b/lib/mosaic-objects/src/test/java/org/eclipse/mosaic/lib/objects/v2x/CellMessageRoutingBuilderTest.java index 62ffcc86d..21211a450 100644 --- a/lib/mosaic-objects/src/test/java/org/eclipse/mosaic/lib/objects/v2x/CellMessageRoutingBuilderTest.java +++ b/lib/mosaic-objects/src/test/java/org/eclipse/mosaic/lib/objects/v2x/CellMessageRoutingBuilderTest.java @@ -52,7 +52,7 @@ public void setup() { @Test public void geoBroadcastCircle() { // run - MessageRouting routing = builder.geoBroadcastBasedOnUnicast(geoCircle); + MessageRouting routing = builder.broadcast().geographical(geoCircle).build(); // assert assertEquals(DestinationType.CELL_GEOCAST, routing.getDestination().getType()); @@ -64,7 +64,7 @@ public void geoBroadcastCircle() { @Test public void geoBroadcastRectangle() { // run - MessageRouting routing = builder.geoBroadcastBasedOnUnicast(geoRectangle); + MessageRouting routing = builder.broadcast().geographical(geoRectangle).build(); // assert assertEquals(DestinationType.CELL_GEOCAST, routing.getDestination().getType()); @@ -74,9 +74,9 @@ public void geoBroadcastRectangle() { } @Test - public void geoBroadcastMbmsCircle() { + public void geoBroadcastMbsCircle() { // run - MessageRouting routing = builder.geoBroadcastMbms(geoCircle); + MessageRouting routing = builder.broadcast().mbs().geographical(geoCircle).build(); // assert assertEquals(DestinationType.CELL_GEOCAST_MBMS, routing.getDestination().getType()); @@ -86,9 +86,9 @@ public void geoBroadcastMbmsCircle() { } @Test - public void geoBroadcastMbmsRectangle() { + public void geoBroadcastMbsRectangle() { // run - MessageRouting routing = builder.geoBroadcastMbms(geoRectangle); + MessageRouting routing = builder.broadcast().mbs().geographical(geoRectangle).build(); // assert assertEquals(DestinationType.CELL_GEOCAST_MBMS, routing.getDestination().getType()); @@ -100,7 +100,7 @@ public void geoBroadcastMbmsRectangle() { @Test public void topocast() { // run - MessageRouting routing = builder.topoCast(ipAddress); + MessageRouting routing = builder.destination(ipAddress).topological().build(); // assert assertEquals(DestinationType.CELL_TOPOCAST, routing.getDestination().getType()); diff --git a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/NackReceivingServer.java b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/NackReceivingServer.java index b8f6b35fd..d712419e1 100644 --- a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/NackReceivingServer.java +++ b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/NackReceivingServer.java @@ -65,7 +65,11 @@ public void onAcknowledgementReceived(ReceivedAcknowledgement acknowledgement) { @Override public void processEvent(Event event) { if (event instanceof SendSimpleMessage sendSimpleMessage) { - MessageRouting routing = getOs().getCellModule().createMessageRouting().tcp().topoCast(sendSimpleMessage.receiver); + MessageRouting routing = getOs().getCellModule().createMessageRouting() + .tcp() + .destination(sendSimpleMessage.receiver) + .topological() + .build(); getOs().getCellModule().sendV2xMessage(new GenericV2xMessage(routing, 8)); getLog().infoSimTime(this, "Message sent at time {}", getOs().getSimulationTime()); } diff --git a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/ReceiveAndReturnRoundTripMessage.java b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/ReceiveAndReturnRoundTripMessage.java index 1cc8d4d0f..a83dc7203 100644 --- a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/ReceiveAndReturnRoundTripMessage.java +++ b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/ReceiveAndReturnRoundTripMessage.java @@ -55,7 +55,11 @@ public void onMessageReceived(ReceivedV2xMessage receivedV2xMessage) { receivedV2xMessage.getMessage().getRouting().getDestination().getProtocolType() ); String roundtripReceiver = receivedV2xMessage.getMessage().getRouting().getSource().getSourceName(); - MessageRouting routing = getOs().getCellModule().createMessageRouting().tcp().topoCast(roundtripReceiver); + MessageRouting routing = getOs().getCellModule().createMessageRouting() + .tcp() + .destination(roundtripReceiver) + .topological() + .build(); getOs().getCellModule().sendV2xMessage(new GenericV2xMessage(routing, 8)); getLog().infoSimTime(this, "Send V2xMessage to {} at time {}", roundtripReceiver, getOs().getSimulationTime()); } diff --git a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/SendAndReceiveRoundTripMessage.java b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/SendAndReceiveRoundTripMessage.java index febd8d294..88692a549 100644 --- a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/SendAndReceiveRoundTripMessage.java +++ b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/SendAndReceiveRoundTripMessage.java @@ -101,7 +101,11 @@ public void onShutdown() { @Override public void processEvent(Event event) { if (event instanceof SendRoundTripMessageEvent) { - MessageRouting routing = getOs().getCellModule().createMessageRouting().tcp().topoCast(receiver); + MessageRouting routing = getOs().getCellModule().createMessageRouting() + .tcp() + .destination(receiver) + .topological() + .build(); getOs().getCellModule().sendV2xMessage(new GenericV2xMessage(routing, 8)); getLog().infoSimTime(this, "Message sent at time {}", getOs().getSimulationTime()); } diff --git a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendonshutdown/SendOnShutdownApp.java b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendonshutdown/SendOnShutdownApp.java index d579b343d..21c9b0f78 100644 --- a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendonshutdown/SendOnShutdownApp.java +++ b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendonshutdown/SendOnShutdownApp.java @@ -34,7 +34,7 @@ public void onStartup() { @Override public void onShutdown() { getOs().getCellModule().sendV2xMessage(new ShutdownMessage( - getOs().getCellModule().createMessageRouting().topoCast("server_0") + getOs().getCellModule().createMessageRouting().destination("server_0").topological().build() )); getOs().getAdHocModule().sendV2xMessage(new ShutdownMessage(