Skip to content

Commit

Permalink
Add infrastructure network support for omnet Java part
Browse files Browse the repository at this point in the history
  • Loading branch information
vladamatena committed Mar 13, 2015
1 parent cd5a8d1 commit 9bae84f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
import cz.cuni.mff.d3s.deeco.runtime.DEECoContainer;
import cz.cuni.mff.d3s.jdeeco.network.address.Address;
import cz.cuni.mff.d3s.jdeeco.network.address.IPAddress;
import cz.cuni.mff.d3s.jdeeco.network.l1.ReceivedInfo;

public class OMNeTInfrastructureDevice extends OMNeTDevice {
public OMNeTInfrastructureDevice(/* , address, virtual lan, ... */) {
}

@Override
public String getId() {
throw new UnsupportedOperationException();
return String.valueOf(host.id);
}

@Override
public int getMTU() {
throw new UnsupportedOperationException();
// TODO: Get this from OMNeT
return 1500;
}

@Override
Expand All @@ -25,17 +27,21 @@ public boolean canSend(Address address) {

@Override
public void send(byte[] data, Address address) {
throw new UnsupportedOperationException();
if(!(address instanceof IPAddress)) {
throw new UnsupportedOperationException();
}
System.out.println("Sending ip packet, from host " + host.getId() + " to host " + address);
host.sendInfrastructurePacket(data, (IPAddress) address);
}

@Override
public void init(DEECoContainer container) {
super.init(container);

throw new UnsupportedOperationException();
host.setInfrastructureDevice(this);
}

public void receivePacket(byte[] data) {
System.out.println("Received infrastructure packet");
network.getL1().processL0Packet(data, this, new ReceivedInfo(new IPAddress("UNKNOWN")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import cz.cuni.mff.d3s.deeco.simulation.omnet.OMNeTNativeListener;
import cz.cuni.mff.d3s.deeco.timer.SimulationTimer;
import cz.cuni.mff.d3s.deeco.timer.TimerEventListener;
import cz.cuni.mff.d3s.jdeeco.network.address.Address;
import cz.cuni.mff.d3s.jdeeco.network.address.IPAddress;

public class OMNeTSimulation implements DEECoPlugin {
class OMNeTTimerProvider implements SimulationTimer {
Expand Down Expand Up @@ -65,8 +65,8 @@ public void setInfrastructureDevice(OMNeTInfrastructureDevice device) {
infrastructureDevice = device;
}

public void sendInfrastructurePacket(byte[] packet, Address address) {
throw new UnsupportedOperationException();
public void sendInfrastructurePacket(byte[] packet, IPAddress address) {
OMNeTNative.nativeSendPacket(id, packet, address.ipAddress);
}

public void sendBroadcastPacket(byte[] packet) {
Expand Down

0 comments on commit 9bae84f

Please sign in to comment.