[omnetpp] How to know the MAC address in INET Fw

658 views
Skip to first unread message

antoni...@inov.pt

unread,
Apr 22, 2008, 7:48:51 PM4/22/08
to OMNeT++ Discussion List
Dear all

I'm building an application that works directly on top of the IEEE
802.11 MAC. The application needs to know the MAC address of the NIC.
What is the best way to get that info from the application? Thanks in
advance.

Kind regards,
Antonio Grilo

_______________________________________________
OMNeT++ Mailing List
options: http://lists.omnetpp.org/mailman/listinfo/omnetpp-l
archive: http://www.omnetpp.org/listarchive/index.php

Alfonso Ariza

unread,
Apr 23, 2008, 12:56:04 PM4/23/08
to OMNeT++ Discussion List
#include "InterfaceTableAccess.h"
#include "InterfaceTableAccess.h"


InterfaceTable *inet_ift;
inet_ift = InterfaceTableAccess ().get();
MACAddress mac;
for (int i = 0; i < inet_ift->numInterfaces(); i++)
{
mac = inet_ift->interfaceAt(i)->macAddress();
if (mac.equals(MACAddress ("00-00-00-00-00-01"))
break;
}


--------------------------------------------------
From: <antoni...@inov.pt>
Sent: Wednesday, April 23, 2008 1:48 AM
To: "OMNeT++ Discussion List" <omne...@omnetpp.org>
Subject: [omnetpp] How to know the MAC address in INET Fw

antoni...@inov.pt

unread,
Apr 24, 2008, 7:50:20 AM4/24/08
to omne...@omnetpp.org
Dear Alfonso

What if I don't have an interface table? I mean, I'm not using any
module related with IP Routing. Just the application on top of the MAC.

Regards,
Antonio

Alfonso Ariza

unread,
Apr 24, 2008, 9:33:56 AM4/24/08
to OMNeT++ Discussion List
The interface table module is similar to the notificationBoard and it don't
need the ip layer. You only need to include in your node module a
InterfaceTable module


for example

module RadioHost
parameters:
gates:
in: radioIn;
submodules:
notificationBoard: NotificationBoard;
display: "p=60,70;i=block/control";
interfaceTable: InterfaceTable;
display: "p=60,150;i=block/table";
App: AppType;
display: "p=163,67;i=block/app";
wlan: Ieee80211;
display: "p=248,349;q=queue;i=block/ifcard";
mobility: mobilityType like BasicMobility;
display: "p=149,307;i=block/cogwheel";
connections nocheck:
App.tcpOut --> wlan.uppergateIn
App.In <-- wlan.uppergateOut;

wlan.uppergateOut --> networkLayer.ifIn[0];
wlan.uppergateIn <-- networkLayer.ifOut[0];

// connections to network outside
radioIn --> wlan.radioIn;
endmodule


If you see the Ieee80211Mac::initialize this method call to the
Ieee80211Mac::registerInterface method, and this method register the
interface inside for the InterfaceTable module


--------------------------------------------------
From: <antoni...@inov.pt>
Sent: Thursday, April 24, 2008 1:50 PM
To: <omne...@omnetpp.org>
Subject: Re: [omnetpp] How to know the MAC address in INET Fw

antoni...@inov.pt

unread,
Apr 24, 2008, 10:47:23 AM4/24/08
to omne...@omnetpp.org
What about the "networklayer" that appears in the gate connectivity
definition?

antoni...@inov.pt

unread,
Apr 24, 2008, 11:55:44 AM4/24/08
to OMNeT++ Discussion List
Dear Alfonso,

It gives an error in my application:

"Error in module (Ieee802Mac) throughput.cliHost[0].wlan.mac: User
error: addInterface(): interface must be connected to network layer's
ifIn[]/ifOut[] gates of the same index."


Antonio


> Sorry I forget to eliminate. :)
>
> This is only an example where the application layer sends the packets to the
> mac layer. It doesn't use the Arp or ip. The app must send the destination
> mac address to the mac layer. The routing must be in the app layer. But the
> question that is interest to you is where it's defined the InterfaceTable
> module.


>
>
> module RadioHost
> parameters:
> gates:
> in: radioIn;
> submodules:
> notificationBoard: NotificationBoard;
> display: "p=60,70;i=block/control";
> interfaceTable: InterfaceTable;
> display: "p=60,150;i=block/table";
> App: AppType;
> display: "p=163,67;i=block/app";
> wlan: Ieee80211;
> display: "p=248,349;q=queue;i=block/ifcard";
> mobility: mobilityType like BasicMobility;
> display: "p=149,307;i=block/cogwheel";
> connections nocheck:
> App.tcpOut --> wlan.uppergateIn
> App.In <-- wlan.uppergateOut;

> // connections to network outside
> radioIn --> wlan.radioIn;
> endmodule
>

Alfonso Ariza

unread,
Apr 24, 2008, 12:05:58 PM4/24/08
to OMNeT++ Discussion List

Ok, :)

to avoid this check edit the InterfaceTable.cc file

void InterfaceTable::addInterface(InterfaceEntry *entry, cModule *ifmod)
{
// check name is unique
if (interfaceByName(entry->name())!=NULL)
opp_error("addInterface(): interface '%s' already registered",
entry->name());

// insert
entry->_interfaceId = interfaces.size();
interfaces.push_back(entry);

// fill in networkLayerGateIndex, nodeOutputGateId, nodeInputGateId
if (ifmod)
discoverConnectingGates(entry, ifmod);
}


void InterfaceTable::addInterface(InterfaceEntry *entry, cModule *ifmod)
{
// check name is unique
if (interfaceByName(entry->name())!=NULL)
opp_error("addInterface(): interface '%s' already registered",
entry->name());

// insert
entry->_interfaceId = interfaces.size();
interfaces.push_back(entry);

// fill in networkLayerGateIndex, nodeOutputGateId, nodeInputGateId
// if (ifmod)
// discoverConnectingGates(entry, ifmod);

entry->setNetworkLayerGateIndex(0);
}


--------------------------------------------------
From: <antoni...@inov.pt>
Sent: Thursday, April 24, 2008 5:55 PM


To: "OMNeT++ Discussion List" <omne...@omnetpp.org>

Subject: Re: [omnetpp] How to know the MAC address in INET Fw

> Dear Alfonso,

Alfonso Ariza

unread,
Apr 24, 2008, 11:45:02 AM4/24/08
to OMNeT++ Discussion List
Sorry I forget to eliminate. :)

This is only an example where the application layer sends the packets to the
mac layer. It doesn't use the Arp or ip. The app must send the destination
mac address to the mac layer. The routing must be in the app layer. But the
question that is interest to you is where it's defined the InterfaceTable
module.

module RadioHost
parameters:
gates:
in: radioIn;
submodules:
notificationBoard: NotificationBoard;
display: "p=60,70;i=block/control";
interfaceTable: InterfaceTable;
display: "p=60,150;i=block/table";
App: AppType;
display: "p=163,67;i=block/app";
wlan: Ieee80211;
display: "p=248,349;q=queue;i=block/ifcard";
mobility: mobilityType like BasicMobility;
display: "p=149,307;i=block/cogwheel";
connections nocheck:
App.tcpOut --> wlan.uppergateIn
App.In <-- wlan.uppergateOut;

// connections to network outside
radioIn --> wlan.radioIn;
endmodule


>>
--------------------------------------------------
From: <antoni...@inov.pt>
Sent: Thursday, April 24, 2008 4:47 PM

Alfonso Ariza

unread,
Apr 24, 2008, 12:02:03 PM4/24/08
to OMNeT++ Discussion List
Sorry, I don't send the ned code with the idea that you use directely. I
send only who a example to indicate were is defined the InterfaceLayer.

--------------------------------------------------
From: <antoni...@inov.pt>
Sent: Thursday, April 24, 2008 5:55 PM


To: "OMNeT++ Discussion List" <omne...@omnetpp.org>

Subject: Re: [omnetpp] How to know the MAC address in INET Fw

> Dear Alfonso,

Reply all
Reply to author
Forward
0 new messages