Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

InterfaceTable: find connected network layer (NL) by NL's gates that …

…need to be called ifIn/ifOut

The code committed in this patch was the solution before 2012-04-12,
when it was changed to check upperLayerIn/upperLayerOut gates of the
NIC module; however that's not so so good because we need to store
the gate index of the gate of the *network layer*.

This patch reverts to original behaviour; allows NICs not connected to
a network layer; and provides better diagnistics.

ASSUMPTIONS:
 1. The NIC module (ifmod) may or may not be connected to a network layer module (e.g. IPv4NetworkLayer or MPLS)
 2. If it *is* connected to a network layer (or a relay unit), the network layer module's gates must be called
    ifIn[] and ifOut[], and NIC must be connected to identical gate indices in both vectors.
 3. If the NIC module is not connected to another modules ifIn[] and ifOut[] gates, we assume
    that it is NOT connected to a network layer, and leave networkLayerGateIndex
    in InterfaceEntry unfilled.
 4. The NIC may or may not connect to gates of the containing host compound module.
  • Loading branch information...
commit 384357d0660ca13a75a009b6eae411eb00974b2d 1 parent 125a60a
@avarga avarga authored
View
11 WHATSNEW
@@ -84,9 +84,16 @@ New features:
Bare EtherMAC modules have been replaced with EthernetInterface, so that
external queues can be used (useful for e.g. QoS).
+8. InterfaceTable, NIC, NetworkLayer:
+
+ Revert to earlier behavior of determining networkLayerGateIndex.
+ Now the module connected to a NIC *must* have gate vectors called ifIn and ifOut.
+ If it doesn't, the code decides that the NIC is *not* directly connected to
+ a network layer, and leaves networkLayerGateIndex unfilled.
+
Other, smaller changes:
-- MANET protocols have been synchonized with the INETMANET project
+- MANET protocols have been synchronized with the INETMANET project
- NodeBase: added optional battery (off by default)
@@ -100,7 +107,7 @@ Other, smaller changes:
- IPv4NetworkConfigurator: added @groups to <interface> (ie. multicast groups
can now be also specified in the <interface> element, not only in a separate
- <multicast-group> element)
+ <multicast-group> element)
- in many simulation examples, .irt files were replaced by IPv4NetworkConfigurator XML.
View
8 src/linklayer/IMACRelayUnit.ned
@@ -53,8 +53,8 @@ moduleinterface IMACRelayUnit
// (when it expires, entry is removed from the table)
@display("i=block/switch");
gates:
- input lowerLayerIn[] @labels(EtherFrame);
- output lowerLayerOut[] @labels(EtherFrame);
+ input ifIn[] @labels(EtherFrame);
+ output ifOut[] @labels(EtherFrame);
}
simple MACRelayUnit_None like IMACRelayUnit
@@ -66,7 +66,7 @@ simple MACRelayUnit_None like IMACRelayUnit
@display("i=old/x_noentry");
@class("UnimplementedModule");
gates:
- input lowerLayerIn[] @labels(EtherFrame);
- output lowerLayerOut[] @labels(EtherFrame);
+ input ifIn[] @labels(EtherFrame);
+ output ifOut[] @labels(EtherFrame);
}
View
13 src/linklayer/ethernet/switch/MACRelayUnitBase.cc
@@ -72,9 +72,9 @@ void MACRelayUnitBase::initialize(int stage)
if (stage == 0)
{
// number of ports
- numPorts = gate("lowerLayerOut", 0)->size();
- if (gate("lowerLayerIn", 0)->size()!=numPorts)
- error("the sizes of the lowerLayerIn[] and lowerLayerOut[] gate vectors must be the same");
+ numPorts = gate("ifOut", 0)->size();
+ if (gate("ifIn", 0)->size()!=numPorts)
+ error("the sizes of the ifIn[] and ifOut[] gate vectors must be the same");
// other parameters
addressTableSize = par("addressTableSize");
@@ -135,7 +135,7 @@ void MACRelayUnitBase::handleAndDispatchFrame(EtherFrame *frame, int inputport)
if (outputport >= 0)
{
EV << "Sending frame " << frame << " with dest address " << frame->getDest() << " to port " << outputport << endl;
- send(frame, "lowerLayerOut", outputport);
+ send(frame, "ifOut", outputport);
}
else
{
@@ -148,7 +148,7 @@ void MACRelayUnitBase::broadcastFrame(EtherFrame *frame, int inputport)
{
for (int i=0; i<numPorts; ++i)
if (i != inputport)
- send((EtherFrame*)frame->dup(), "lowerLayerOut", i);
+ send((EtherFrame*)frame->dup(), "ifOut", i);
delete frame;
}
@@ -312,6 +312,7 @@ void MACRelayUnitBase::sendPauseFrame(int portno, int pauseUnits)
IInterfaceTable *ift = InterfaceTableAccess().get();
InterfaceEntry *ie = ift->getInterfaceByNetworkLayerGateIndex(portno);
+ ASSERT(ie);
if (ie->isUp())
{
@@ -324,7 +325,7 @@ void MACRelayUnitBase::sendPauseFrame(int portno, int pauseUnits)
frame->setByteLength(ETHER_PAUSE_COMMAND_PADDED_BYTES);
- send(frame, "lowerLayerOut", portno);
+ send(frame, "ifOut", portno);
pauseFinished[portno] = simTime() + ((double)PAUSE_UNIT_BITS) * pauseUnits / ie->getDatarate();
}
else //disconnected or disabled
View
4 src/linklayer/ethernet/switch/MACRelayUnitNP.ned
@@ -51,7 +51,7 @@ simple MACRelayUnitNP like IMACRelayUnit
@statistic[processedBytes](title="Processed bytes"; record=count,sum,vector);
@statistic[droppedBytes](title="Dropped bytes"; record=count,sum,vector);
gates:
- input lowerLayerIn[] @labels(EtherFrame);
- output lowerLayerOut[] @labels(EtherFrame);
+ input ifIn[] @labels(EtherFrame);
+ output ifOut[] @labels(EtherFrame);
}
View
4 src/linklayer/ethernet/switch/MACRelayUnitPP.ned
@@ -49,7 +49,7 @@ simple MACRelayUnitPP like IMACRelayUnit
@statistic[droppedBytes](title="Processed bytes"; record=sum,count,vector);
@statistic[usedBufferBytes](title="used buffer bytes"; record=max,timeavg,vector; unit=B; interpolationmode=none);
gates:
- input lowerLayerIn[] @labels(EtherFrame);
- output lowerLayerOut[] @labels(EtherFrame);
+ input ifIn[] @labels(EtherFrame);
+ output ifOut[] @labels(EtherFrame);
}
View
18 src/networklayer/common/ChangeLog
@@ -1,5 +1,23 @@
2013-08-22 ------ inet-2.2.0 released ------
+2013-08-23 Andras Varga
+
+ InterfaceTable: revert to earlier behavior of determining networkLayerGateIndex.
+ Now the module connected to a NIC *must* have gate vectors called ifIn and ifOut.
+ If they don't, the code decides that the NIC is *not* directly connected to
+ a network layer, and leaves networkLayerGateIndex unfilled.
+
+ ASSUMPTIONS:
+ 1. The NIC module (ifmod) may or may not be connected to a network layer
+ module (e.g. IPv4NetworkLayer or MPLS)
+ 2. If it *is* connected to a network layer (or a relay unit), the network
+ layer module's gates must be called ifIn[] and ifOut[], and NIC must be
+ connected to identical gate indices in both vectors.
+ 3. If the NIC module is not connected to another modules ifIn[] and ifOut[]
+ gates, we assume that it is NOT connected to a network layer, and leave
+ networkLayerGateIndex in InterfaceEntry unfilled.
+ 4. The NIC may or may not connect to gates of the containing host compound module.
+
2013-07-05 Zoltan Bojthe
InterfaceTable: remove explicit registration of a loopback interface;
View
34 src/networklayer/common/InterfaceTable.cc
@@ -179,8 +179,18 @@ void InterfaceTable::discoverConnectingGates(InterfaceEntry *entry)
if (!ifmod)
throw cRuntimeError("addInterface(): specified module is not in this host/router");
+ // ASSUMPTIONS:
+ // 1. The NIC module (ifmod) may or may not be connected to a network layer module (e.g. IPv4NetworkLayer or MPLS)
+ // 2. If it *is* connected to a network layer, the network layer module's gates must be called
+ // ifIn[] and ifOut[], and NIC must be connected to identical gate indices in both vectors.
+ // 3. If the NIC module is not connected to another modules ifIn[] and ifOut[] gates, we assume
+ // that it is NOT connected to a network layer, and leave networkLayerGateIndex
+ // in InterfaceEntry unfilled.
+ // 4. The NIC may or may not connect to gates of the containing host compound module.
+ //
+
// find gates connected to host / network layer
- cGate *nwlayerInGate = NULL, *nwlayerOutGate = NULL;
+ cGate *nwlayerInGate = NULL, *nwlayerOutGate = NULL; // ifIn[] and ifOut[] gates in the network layer
for (GateIterator i(ifmod); !i.end(); i++)
{
cGate *g = i();
@@ -193,21 +203,27 @@ void InterfaceTable::discoverConnectingGates(InterfaceEntry *entry)
entry->setNodeInputGateId(g->getPreviousGate()->getId());
// find the gate index of networkLayer/networkLayer6/mpls that connects to this interface
- if (g->getType()==cGate::OUTPUT && g->getNextGate() && g->isName("upperLayerOut"))
+ if (g->getType()==cGate::OUTPUT && g->getNextGate() && g->getNextGate()->isName("ifIn")) // connected to ifIn in networkLayer?
nwlayerInGate = g->getNextGate();
- if (g->getType()==cGate::INPUT && g->getPreviousGate() && g->isName("upperLayerIn"))
+ if (g->getType()==cGate::INPUT && g->getPreviousGate() && g->getPreviousGate()->isName("ifOut")) // connected to ifOut in networkLayer?
nwlayerOutGate = g->getPreviousGate();
}
- // consistency checks
+ // consistency checks and setting networkLayerGateIndex:
+
// note: we don't check nodeOutputGateId/nodeInputGateId, because wireless interfaces
// are not connected to the host
- if (!nwlayerInGate && !nwlayerOutGate) // Accesspoint does not have a network layer so the NIC is not connected
- return;
- if (!nwlayerInGate || !nwlayerOutGate || nwlayerInGate->getOwnerModule()!=nwlayerOutGate->getOwnerModule() || nwlayerInGate->getIndex()!=nwlayerOutGate->getIndex())
- throw cRuntimeError("addInterface(): interface must be connected to network layer's in/out gates using the same gate index");
- entry->setNetworkLayerGateIndex(nwlayerInGate->getIndex());
+ if (nwlayerInGate || nwlayerOutGate) // connected to a network layer (i.e. to another module's inIn/ifOut gates)
+ {
+ if (!nwlayerInGate || !nwlayerOutGate)
+ throw cRuntimeError("addInterface(): interface module '%s' is connected only to an 'ifOut' or an 'ifIn' gate, must connect to either both or neither", ifmod->getFullPath().c_str());
+ if (nwlayerInGate->getOwnerModule() != nwlayerOutGate->getOwnerModule())
+ throw cRuntimeError("addInterface(): interface module '%s' is connected to 'ifOut' and 'ifIn' gates in different modules", ifmod->getFullPath().c_str());
+ if (nwlayerInGate->getIndex() != nwlayerOutGate->getIndex()) // if both are scalar, that's OK too (index==0)
+ throw cRuntimeError("addInterface(): gate index mismatch: interface module '%s' is connected to different indices in 'ifOut[']/'ifIn[]' gates of the network layer module", ifmod->getFullPath().c_str());
+ entry->setNetworkLayerGateIndex(nwlayerInGate->getIndex());
+ }
}
void InterfaceTable::deleteInterface(InterfaceEntry *entry)
View
4 src/nodes/ethernet/EtherSwitch.ned
@@ -73,8 +73,8 @@ module EtherSwitch
}
connections:
for i=0..sizeof(ethg)-1 {
- eth[i].upperLayerIn <-- relayUnit.lowerLayerOut++;
- eth[i].upperLayerOut --> relayUnit.lowerLayerIn++;
+ eth[i].upperLayerIn <-- relayUnit.ifOut++;
+ eth[i].upperLayerOut --> relayUnit.ifIn++;
eth[i].phys <--> ethg[i];
}
}
View
8 src/nodes/wireless/AccessPoint.ned
@@ -89,13 +89,13 @@ module AccessPoint
// because broadcasts must be handled differently for wireless IFs by the relayUnit
for i=0..numRadios-1 {
radioIn[i] --> wlan[i].radioIn;
- wlan[i].upperLayerOut --> relayUnit.lowerLayerIn++ if sizeof(ethg)+numRadios>1;
- wlan[i].upperLayerIn <-- relayUnit.lowerLayerOut++ if sizeof(ethg)+numRadios>1;
+ wlan[i].upperLayerOut --> relayUnit.ifIn++ if sizeof(ethg)+numRadios>1;
+ wlan[i].upperLayerIn <-- relayUnit.ifOut++ if sizeof(ethg)+numRadios>1;
}
// ethernet must be connected only AFTER wireless ports
for i=0..sizeof(ethg)-1 {
eth[i].phys <--> ethg[i];
- eth[i].upperLayerIn <-- relayUnit.lowerLayerOut++ if sizeof(ethg)+numRadios>1;
- eth[i].upperLayerOut --> relayUnit.lowerLayerIn++ if sizeof(ethg)+numRadios>1;
+ eth[i].upperLayerIn <-- relayUnit.ifOut++ if sizeof(ethg)+numRadios>1;
+ eth[i].upperLayerOut --> relayUnit.ifIn++ if sizeof(ethg)+numRadios>1;
}
}

0 comments on commit 384357d

Please sign in to comment.
Something went wrong with that request. Please try again.