From 883fb1e67f8a1adb56f14ff9dc8327fde532550e Mon Sep 17 00:00:00 2001 From: Deniz Cakiroglu Date: Sat, 11 Nov 2023 23:18:04 -0500 Subject: [PATCH 1/4] add lower layers to ExtLowerEthernetInterface --- .../ethernet/ExtLowerEthernetInterface.ned | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned b/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned index cfe85fc4f64..3ef1511b513 100644 --- a/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned +++ b/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned @@ -10,6 +10,9 @@ package inet.emulation.linklayer.ethernet; import inet.emulation.common.ExtInterface; import inet.linklayer.contract.IEthernetInterface; +import inet.linklayer.ethernet.contract.IEthernetMacLayer; +import inet.physicallayer.wired.ethernet.IEthernetPhyLayer; + // // This module provides an Ethernet network interface suitable for emulation. // The lower part of the network interface is realized in the real world using @@ -29,7 +32,18 @@ module ExtLowerEthernetInterface extends ExtInterface like IEthernetInterface parameters: @display("p=300,200"); } + macLayer: like IEthernetMacLayer { + parameters: + @display("p=400,400"); + } + phyLayer: like IEthernetPhyLayer { + parameters: + transmitter.clockModule = default(""); + @display("p=400,500"); + } connections allowunconnected: - upperLayerIn --> { @display("m=n"); } --> socket.upperLayerIn; + phys$i --> { @display("m=s"); } --> phyLayer.lowerLayerIn; + phyLayer.upperLayerOut --> macLayer.lowerLayerIn; + macLayer.upperLayerOut --> { @display("m=n"); } --> socket.upperLayerIn; upperLayerOut <-- { @display("m=n"); } <-- socket.upperLayerOut; } From d13e9e967a3dbf73777467df6f895e93221d54cb Mon Sep 17 00:00:00 2001 From: Deniz Cakiroglu Date: Sat, 11 Nov 2023 23:37:03 -0500 Subject: [PATCH 2/4] add bitrate --- .../emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned | 1 + 1 file changed, 1 insertion(+) diff --git a/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned b/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned index 3ef1511b513..235a2b444c2 100644 --- a/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned +++ b/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned @@ -23,6 +23,7 @@ module ExtLowerEthernetInterface extends ExtInterface like IEthernetInterface parameters: string protocol = default("ethernetmac"); double bitrate @unit(bps) = default(nan bps); + *.bitrate = default(this.bitrate); gates: input cutthroughIn @loose; output cutthroughOut @loose; From fe151ef8b36b42fe8fd57b17bcc1d254b5884cfe Mon Sep 17 00:00:00 2001 From: Deniz Cakiroglu Date: Tue, 14 Nov 2023 22:16:42 -0500 Subject: [PATCH 3/4] fix writing to interface by only getting packet data --- .../emulation/linklayer/ethernet/ExtEthernetSocket.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/inet/emulation/linklayer/ethernet/ExtEthernetSocket.cc b/src/inet/emulation/linklayer/ethernet/ExtEthernetSocket.cc index e610cbd1e09..892a1731fef 100644 --- a/src/inet/emulation/linklayer/ethernet/ExtEthernetSocket.cc +++ b/src/inet/emulation/linklayer/ethernet/ExtEthernetSocket.cc @@ -66,12 +66,9 @@ void ExtEthernetSocket::handleMessage(cMessage *message) socket_address.sll_addr[4] = macAddress.getAddressByte(4); socket_address.sll_addr[5] = macAddress.getAddressByte(5); - uint8_t buffer[packet->getByteLength()]; - auto bytesChunk = packet->peekAllAsBytes(); - size_t packetLength = bytesChunk->copyToBuffer(buffer, sizeof(buffer)); - ASSERT(packetLength == (size_t)packet->getByteLength()); - - int sent = sendto(fd, buffer, packetLength, 0, (struct sockaddr *)&socket_address, sizeof(socket_address)); + auto bytes = packet->peekDataAsBytes()->getBytes(); + auto packetLength = bytes.size(); + int sent = sendto(fd, bytes.data(), packetLength, 0, (struct sockaddr *)&socket_address, sizeof(socket_address)); if ((size_t)sent == packetLength) EV_INFO << "Sent " << packetLength << " packet to '" << device << "' device.\n"; else From 8e92c2bcf092705dcb8736bfeb5e1173359763ca Mon Sep 17 00:00:00 2001 From: Deniz Cakiroglu Date: Sun, 17 Mar 2024 00:26:34 -0400 Subject: [PATCH 4/4] remove maclayer --- .../linklayer/ethernet/ExtLowerEthernetInterface.ned | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned b/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned index 235a2b444c2..5eccbc2e3ef 100644 --- a/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned +++ b/src/inet/emulation/linklayer/ethernet/ExtLowerEthernetInterface.ned @@ -10,7 +10,6 @@ package inet.emulation.linklayer.ethernet; import inet.emulation.common.ExtInterface; import inet.linklayer.contract.IEthernetInterface; -import inet.linklayer.ethernet.contract.IEthernetMacLayer; import inet.physicallayer.wired.ethernet.IEthernetPhyLayer; // @@ -33,10 +32,6 @@ module ExtLowerEthernetInterface extends ExtInterface like IEthernetInterface parameters: @display("p=300,200"); } - macLayer: like IEthernetMacLayer { - parameters: - @display("p=400,400"); - } phyLayer: like IEthernetPhyLayer { parameters: transmitter.clockModule = default(""); @@ -44,7 +39,6 @@ module ExtLowerEthernetInterface extends ExtInterface like IEthernetInterface } connections allowunconnected: phys$i --> { @display("m=s"); } --> phyLayer.lowerLayerIn; - phyLayer.upperLayerOut --> macLayer.lowerLayerIn; - macLayer.upperLayerOut --> { @display("m=n"); } --> socket.upperLayerIn; + phyLayer.upperLayerOut --> socket.upperLayerIn; upperLayerOut <-- { @display("m=n"); } <-- socket.upperLayerOut; }