In Omnet++ 5.5.1 with INET 4 framework, from MAC layer, I am trying to check if the physical channel is idle.
Would anyone please suggest me the code for that?
UPDATE
I'm using the following interface.
# wireless interface
**.wlan[*].typename = "WirelessInterface"
**.wlan[*].radio.typename = "ApskScalarRadio"
Thanking you.
Usually radios implement the IRadio interface, and the medium state can be queried through various methods on that interface. Check the CsmaCaMac.cc file for examples. Here is the actual implementation you are looking for:
https://github.com/inet-framework/inet/blob/master/src/inet/linklayer/csmaca/CsmaCaMac.cc#L593
Related
I am new to Omnetpp, and I am trying to send messages from one node to another wirelessly.
Basically, I would like to do something as in the tictoc example of Omnetpp (https://docs.omnetpp.org/tutorials/tictoc/) but then wirelessly.
I have installed INET already, and I have seen the wireless example, which uses the UdpBasicAPP. However, I do not know how to change the data of the message send while using the UdPBasicAPP. In my case, what I am sending (i.e. the data) is very important because it is part of a bigger project. Eventually, the idea is to use the 802.11p standard (which exists in VEINS) and multiple nodes, but I thought this was a good place to start.
I hope someone can help me out.
Kind regards
just to be aware: 802.11p is also supported directly in INET. Just set the opMode parameter on the network interface.
You will need to create your own application module. Take a look/copy UdpBasicApp and modify it according to your needs. Check the sendPacket() function which creates an ApplicationPacket. ApplicationPacket contains only a single sequence number, but you can create your own application level data structure and use that for sending.
I've recently started playing with esp32. I was searching for various WiFi.mode() options available for esp32 but I couldn't find it anywhere. Can anyone help point out the source for that information?
Thanks
The code for the ESP32 Arduino SDK WiFi class is located at
https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi/src
WiFi.h doesn't define a method for mode() but it does inherit from WiFiGeneric.h which does have methods for mode() and getMode(). You can find the code for those methods in WiFiGeneric.cpp.
The mode is represented using type wifi_mode_t, which is defined in WiFiType.h. The available options are WIFI_MODE_OFF, WIFI_MODE_STA, WIFI_MODE_AP, and WIFI_MODE_APSTA.
There is some resonable but partial doc on the Espressif pages: Espressif Wifi doc
This doc explains some of the different wifi modes of the esp32 that can be found in WiFiType.h.
WIFI_MODE_NULL : The null mode or the WIFI_MODE_OFF which is the OFF mode
WIFI_MODE_STA : The Station mode, which is the standard client mode
WIFI_MODE_AP : The Access Point mode where clients can connect to the ESP32
WIFI_MODE_APSTA : The hybrid mode where the ESP connect to an AP as a client and recieve connections from client as an AP.
WIFI_MODE_MAX : The MAX mode has no explaination on what it is supposed to do. But it dose not seems to be implemented anyway.
The WiFi mode types come from an enumerated list. WIFI_MODE_MAX is the last entry in the list (and I guess that's why it's MAX). An odd convention as WIFI_MODE_UNKNOWN or similar would be more intuitive.
I'm trying to put together a cross-platform application that interfaces with Insteon automation hardware. In the .Net based examples I've found, the System.IO.Ports.SerialPort class is used to read data from both an RS-232 Serial Port based device and a USB Serial Modem. On a Windows platform, the Serial Modems generally get mapped to a virtual COM Port and it's not to difficult to run down a list, passing in new COM addresses and attempting to figure out which one the USB or Serial device is attached to.
Unfortunately on the Mac, I'm totally out of my element. MonoMac allows me to program in a more comfortable language, but something as low level as talking to hardware is a bit beyond my reach. My initialization code is as follows:
private void OpenSerialConnection(string comPort)
{
_serialPort = new System.IO.Ports.SerialPort("/dev/ttys1", 19200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
_serialPort.Encoding = System.Text.Encoding.Default;
_serialPort.WriteTimeout = 1000;
_serialPort.DataReceived += OnDataReceived;
_serialPort.Open();
}
The "/dev/ttsy1" value which is in place of where the "comPort" variable would go is part of some examples I found that suggest the address might be in the form of /dev/ttys*. After some searching, I discovered that a usb device would likely register as "/dev/tty.usbserial*", but I'm wondering if there's a more elegant way if detecting what this value is that I can leverage in Mono rather than instructing a user to go into Terminal and type "ls /dev/tty.*" and type it themselves?
I don't have any personal experience with Mono on the Mac, but I think it's possible to include and use Objective-C classes in your Mono projects. Assuming that's the case, take a look at ORSSerialPort. ORSSerialPortManager's -availablePorts method will give you an array of all the serial ports available on the system. You can also sign up to receive notifications when ports are added/removed, and the library also makes it easy to open a port, configure it, and send and receive data.
Without something like this, you have to use IOKit to discover ports on the system, and the POSIX APIs for opening, configuring, reading from, and writing to serial ports. IOKit and the POSIX serial port APIs are low(ish) level C APIs.
I need to modify a kernel module(s) to count number of packets that the machine has sent / received over my wireless adapter for the linux 2.6 kernel. Please let me know which modules should I modify. Any references would also be helpful.
I am not very sure about wireless adapter, but I think it is similar to a wired one. For wired and wireless NIC, you can use ifconfig eth0 command, then in the output, you will see one or two lines telling you the number of packets sent(TX) or received(RX).
To get the same information from the kernel module, one way is to modify the device driver for the network card. One tutorial about rtl8139 (wired one) is here: http://linuxgazette.net/156/jangir.html
Also, I think there are some standard kernel interface that you can use to get the same info. For example, tp->stats.tx_packets mentioned in the above link.
If you're interested in IP packets you should consider creating a kernel module that uses netfilter hooks. It's very simple, here take a look at this:
http://www.netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-3.html
Netfilter is primarily intended for firewalling, but it can do what you want and you don't need to mess with other kernel modules. Hope it helps.
cat /proc/net/dev
is probably not what you want, but then explain why.
I'm trying to understand a wireless linux device driver.
So after netdev_open is called...
what happens?
I know packets are being transmitted through an xmit function, but how does the code get there?
The dev->hard_start_xmit() function for the netdev is called out of the networking core - see net/core/dev.c (in particular dev_hard_start_xmit() and dev_queue_xmit()). These functions are in turn called out from the protocol handlers - see for example ip_queue_xmit() in net/ipv4/ip_output.c.