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

extLowerInterface emulation fix #926

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/inet/emulation/linklayer/ethernet/ExtEthernetSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ package inet.emulation.linklayer.ethernet;
import inet.emulation.common.ExtInterface;
import inet.linklayer.contract.IEthernetInterface;

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
Expand All @@ -20,6 +22,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;
Expand All @@ -29,7 +32,13 @@ module ExtLowerEthernetInterface extends ExtInterface like IEthernetInterface
parameters:
@display("p=300,200");
}
phyLayer: <default("EthernetPhyLayer")> 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 --> socket.upperLayerIn;
upperLayerOut <-- { @display("m=n"); } <-- socket.upperLayerOut;
}