Skip to content

Commit

Permalink
Add support for configuring wireless interfaces
Browse files Browse the repository at this point in the history
In Base Station module
  • Loading branch information
n-jay committed Feb 22, 2024
1 parent 2a7da92 commit 8dcc7d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
13 changes: 7 additions & 6 deletions src/inet/routing/leach/LeachBS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ void LeachBS::initialize(int stage) {

//reads from omnetpp.ini
if (stage == INITSTAGE_LOCAL) {
sequencenumber = 0;
host = getContainingNode(this);
interfaceTable.reference(this, "interfaceTableModule", true);
interfaces = par("interfaces");

bsPktReceived = 0;

Expand All @@ -54,20 +54,21 @@ void LeachBS::stop() {
}

void LeachBS::configureInterfaces() {
cPatternMatcher interfaceMatcher(interfaces, false, true, false);
int numInterfaces = interfaceTable->getNumInterfaces();
for (int i = 0; i < numInterfaces; i++) {
NetworkInterface *networkInterface = interfaceTable->getInterface(i);
// Only single wireless interface is required
if (networkInterface->isWireless()) {
interface80211ptr = networkInterface;
break;
if (networkInterface->isMulticast()
&& interfaceMatcher.matches(
networkInterface->getInterfaceName())) {
wirelessInterface = networkInterface;
}
}
}

void LeachBS::handleMessageWhenUp(cMessage *msg) {
Ipv4Address nodeAddr =
(interface80211ptr->getProtocolData<Ipv4InterfaceData>()->getIPAddress());
(wirelessInterface->getProtocolData<Ipv4InterfaceData>()->getIPAddress());
// if node is sending message
if (msg->isSelfMessage()) {
delete msg;
Expand Down
5 changes: 2 additions & 3 deletions src/inet/routing/leach/LeachBS.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ class INET_API LeachBS: public RoutingProtocolBase {
virtual ~LeachBS();

int interfaceId = -1;
NetworkInterface *interface80211ptr = nullptr;
IInterfaceTable *ift = nullptr;
unsigned int sequencenumber = 0;
NetworkInterface *wirelessInterface = nullptr;
cModule *host = nullptr;
ModuleRefByPar<IInterfaceTable> interfaceTable;
const char *interfaces = nullptr;

protected:
virtual int numInitStages() const override {
Expand Down
7 changes: 5 additions & 2 deletions src/inet/routing/leach/LeachBS.ned
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ simple LeachBS like IManetRouting
// properties
@class("leach::LeachBS");
@display("i=block/routing");

// context parameters
string interfaceTableModule;
string interfaceTableModule;

// Leach base station parameter group
string interfaces = default("*"); // Only single wireless interface is required
gates:
input ipIn;
output ipOut;
Expand Down

0 comments on commit 8dcc7d5

Please sign in to comment.