capturing a certain member of an INET node, SNR specifically in omnetpp - c++

I have defined a network topology in omnet++ along with host parameters.
here is the NED code:
network Basic
{
parameters:
string hostType = default("AODVRouter");
string mediumType = default("APSKScalarRadioMedium");
submodules:
visualizer: <default("IntegratedCanvasVisualizer")> like IIntegratedVisualizer if hasVisualizer() {
#display("p=919.664,62.247997");
}
configurator: IPv4NetworkConfigurator {
#display("p=755.008,62.247997");
}
radioMedium: <mediumType> like IRadioMedium {
#display("p=558.224,62.247997");
}
hostA: <hostType> like INetworkNode {
#display("p=104.416,427.70398");
}
hostB: <hostType> like INetworkNode {
#display("p=664.648,267.064");
}
}
I want to create a module which records the SNR/SINR of each station every time it sends/receives a message.
After a few hours of searching (both googling and manual searching in the INET library implementations).
I did not find how to access it so far from another module (I do not know where the field is actually present not how to access it from another module).
Thanks in advance.

Related

Can someone please explain the proper usage of Timers and Triggers in Apache Beam?

I'm looking for some examples of usage of Triggers and Timers in Apache beam, I wanted to use Processing-time timers for listening my data from pub sub in every 5 minutes and using Processing time triggers processing the above data collected in an hour altogether in python.
Please take a look at the following resources: Stateful processing with Apache Beam and Timely (and Stateful) Processing with Apache Beam
The first blog post is more general in how to handle states for context, and the second has some examples on buffering and triggering after a certain period of time, which seems similar to what you are trying to do.
A full example was requested. Here is what I was able to come up with:
PCollection<String> records =
pipeline.apply(
"ReadPubsub",
PubsubIO.readStrings()
.fromSubscription(
"projects/{project}/subscriptions/{subscription}"));
TupleTag<Iterable<String>> every5MinTag = new TupleTag<>();
TupleTag<Iterable<String>> everyHourTag = new TupleTag<>();
PCollectionTuple timersTuple =
records
.apply("WithKeys", WithKeys.of(1)) // A KV<> is required to use state. Keying by data is more appropriate than hardcode.
.apply(
"Batch",
ParDo.of(
new DoFn<KV<Integer, String>, Iterable<String>>() {
#StateId("buffer5Min")
private final StateSpec<BagState<String>> bufferedEvents5Min =
StateSpecs.bag();
#StateId("count5Min")
private final StateSpec<ValueState<Integer>> countState5Min =
StateSpecs.value();
#TimerId("every5Min")
private final TimerSpec every5MinSpec =
TimerSpecs.timer(TimeDomain.PROCESSING_TIME);
#StateId("bufferHour")
private final StateSpec<BagState<String>> bufferedEventsHour =
StateSpecs.bag();
#StateId("countHour")
private final StateSpec<ValueState<Integer>> countStateHour =
StateSpecs.value();
#TimerId("everyHour")
private final TimerSpec everyHourSpec =
TimerSpecs.timer(TimeDomain.PROCESSING_TIME);
#ProcessElement
public void process(
#Element KV<Integer, String> record,
#StateId("count5Min") ValueState<Integer> count5MinState,
#StateId("countHour") ValueState<Integer> countHourState,
#StateId("buffer5Min") BagState<String> buffer5Min,
#StateId("bufferHour") BagState<String> bufferHour,
#TimerId("every5Min") Timer every5MinTimer,
#TimerId("everyHour") Timer everyHourTimer) {
if (Objects.firstNonNull(count5MinState.read(), 0) == 0) {
every5MinTimer
.offset(Duration.standardMinutes(1))
.align(Duration.standardMinutes(1))
.setRelative();
}
buffer5Min.add(record.getValue());
if (Objects.firstNonNull(countHourState.read(), 0) == 0) {
everyHourTimer
.offset(Duration.standardMinutes(60))
.align(Duration.standardMinutes(60))
.setRelative();
}
bufferHour.add(record.getValue());
}
#OnTimer("every5Min")
public void onTimerEvery5Min(
OnTimerContext context,
#StateId("buffer5Min") BagState<String> bufferState,
#StateId("count5Min") ValueState<Integer> countState) {
if (!bufferState.isEmpty().read()) {
context.output(every5MinTag, bufferState.read());
bufferState.clear();
countState.clear();
}
}
#OnTimer("everyHour")
public void onTimerEveryHour(
OnTimerContext context,
#StateId("bufferHour") BagState<String> bufferState,
#StateId("countHour") ValueState<Integer> countState) {
if (!bufferState.isEmpty().read()) {
context.output(everyHourTag, bufferState.read());
bufferState.clear();
countState.clear();
}
}
})
.withOutputTags(every5MinTag, TupleTagList.of(everyHourTag)));
timersTuple
.get(every5MinTag)
.setCoder(IterableCoder.of(StringUtf8Coder.of()))
.apply(<<do something every 5 min>>);
timersTuple
.get(everyHourTag)
.setCoder(IterableCoder.of(StringUtf8Coder.of()))
.apply(<< do something every hour>>);
pipeline.run().waitUntilFinish();

gem5: Use xbar stat in BaseCPU

I have created a new stat of type Formula in the xbar.cc/hh files. There I aggregate all the different transDist types. I'd like to use this newly created stat to compute another stat in the BaseCPU object. What is the best way to have access to it (i.e., allTransactions stat) from BaseCPU? Is there any way to make it globally accessible?
I ended up having a direct line of comminication between the xbar and the CPU objects.
I implemented a function in the Xbar object that returns the statistic that I want, called getAllTrans(). From the CPU object, I call that function and get the value of the statistic. The communication is implemented using the code below.
// Research (Memory Boundedness)
void
BaseCPU::getAllTrans() {
allTrans = 0;
Cache *dCache = dynamic_cast<Cache*>
(this->getPort("dcache_port", 0).getPeer().getOwner());
if (dCache) {
Cache *l2Cache = dynamic_cast<Cache*>
(dCache->getPort("mem_side", 0).getPeer().getOwner()->
getPort("mem_side_ports", 0).getPeer().getOwner());
if (l2Cache) {
CoherentXBar *membus = dynamic_cast<CoherentXBar*>
(l2Cache->getPort("mem_side", 0).getPeer().getOwner());
if (membus) {
allTrans = membus->getAllTrans();
}
}
else {
CoherentXBar *membus = dynamic_cast<CoherentXBar*>
(l2Cache->getPort("mem_side", 0).getPeer().getOwner());
if (membus) {
allTrans = membus->getAllTrans();
}
}
}
}
The code above assumes that the dcache exists.
Cache *dCache = dynamic_cast<Cache*>
(this->getPort("dcache_port", 0).getPeer().getOwner());
The code above points to the dcache object from the cpu. The hops are like this:
CPU -> CPU port to dCache -> Peer of that port (i.e., dCache port to the CPU) -> Owner of that port (i.e., the dCache itself).
I build on top of every object connecting the CPU to the Xbar until I reach the XBar. This isn't the most elegant solution but I haven't found a better one for getting information from one gem5 object to another one.

Module not found on path for interface table module

I am getting the following error
Module not found on path 'GPSSim.satellite[0].interfaceTable' defined by par 'GPSSim.satellite[0].wlan[0].interfaceTableModule' -- in module (inet::InterfaceEntry) GPSSim.satellite[0].wlan[0] (id=51), during network initialization
There are a lot of code but i will show the ones that i believe is important. If more code is required do let me know, thanks!
GPSSIM.ned This file is the network file
network GPSSim
{
parameters:
int numOfSats; // Number of satellites
submodules:
satellite[numOfSats]: GPSSatellite {
parameters:
#display("p=505.835,100.085;r=10,,#707070;i=device/satellite_l");
}
}
GPSSatellite.ned
module GPSSatellite extends StandardSatellite
{
submodules:
gpsApp[numGpsApps]: <default("GPSApp")> like IGPSApp { //default("UdpApp")
parameters:
#display("p=100,284,row,60");
}
}
StandardSatellite.ned
module StandardSatellite extends Satellite
{
parameters:
#node; //because of MobilityBase initialization'
#networkNode();
int numRadios = default(1);
**.interfaceTableModule = default(absPath(".interfaceTable"));
//wlan[*].mgmt.typename = default("Ieee80211MgmtAp");
//wlan[*].interfaceTableModule = default(absPath(".interfaceEntry"));
//wlan[*].mgmtType = default("Ieee80211MgmtAdhoc"); // use adhoc management
submodules:
interfaceTable: InterfaceTable {
parameters:
#display("p=407,69");
}
routingTable: Ipv4RoutingTable {
parameters:
#display("p=45,178");
//IPForward = IPForward;
//forwardMulticast = forwardMulticast;
routingFile = routingFile;
}
wlan[numRadios]: <default("Ieee80211Interface")> like IWirelessInterface {
parameters:
#display("p=301.35,379.05;q=queue");
}
ext[numExtInterfaces]: <default("ExtInterface")> like IExternalInterface {
parameters:
#display("p=217,421,row,10;q=txQueue;i=block/ifcard");
}
networkLayer: NetworkLayerNodeBase {
parameters:
#display("p=226.8,198.45;q=queue");
}
lo0: LoopbackInterface {
#display("p=78,406");
}
App: <default("UdpBasicBurst")> like IApp {
#display("p=469.35,198.45");
}
connections allowunconnected:
wlan[0].upperLayerOut --> networkLayer.radioIn[0];
//ext[0].upperLayerOut --> networkLayer.radioIn[0];
//lo0.upperLayerOut --> networkLayer.radioIn[0];
}
When i put the interface table module in the top level network (GPSSim) instead, i don't get this error but instead i get another error where the interface is already registered which the cause is precisely because i did that, since im telling each instance of satellite to use the same interface table.
I dont' know where to go from here. Any help would be greatly appreciated! Thanks in advance.
Try change the line
**.interfaceTableModule = default(absPath(".interfaceTable"));
into:
interfaceTableModule = default("interfaceTable");
Parameter interfaceTableModule should point to the interface table in that node.

Extracting requierement properties from Capella

I would like to extract the requirements data in capella using m2doc, requirements (SystemFunctionalRequirement) are located in a "RequirementsPkg" package in System analysis, thanks to the "m:RequirementsPkg.eContents().summary" command I managed to retrieve the summary of all requirements but I would like to retrieve the name and the summary of a specific requirement.
Can you help me ?
Thanks in advance
This mechanism is deprecated. You should use the requirement extension.
Starting from the root element, you can use something like:
{ m:system.ownedArchitectures->filter(la::LogicalArchitecture).ownedRequirementPkgs.ownedRequirements.name }
With the requirement extension the easiest way is to create a service:
public List<Requirement> getRequirements(ExtensibleElement element) {
List<Requirement> res = new ArrayList<>();
for (ElementExtension extension : element.getOwnedExtensions()) {
if (extension instanceof Requirement) {
res.add((Requirement) extension);
break;
} else if (extension instanceof CapellaOutgoingRelation) {
res.add(((CapellaOutgoingRelation) extension).getTarget());
}
}
return res;
}
and call it, for instance on a diagram:
{ m:for req | '[LAB] IFE System - All Components, CEs'.representationByName().eAllContents(viewpoint::DRepresentationElement).semanticElements->filter(emde::ExtensibleElement).getRequirements() }
{ m:req.ReqIFLongName }
{ m:endfor }

List device-names available for video capture from ksvideosrc in gstreamer 1.0

I am trying to query a list of available video capture devices (webcams) on windows using gstreamer 1.0 in c++.
I am using ksvideosrc as source and i am able to capture the video input but i can't query a list of available devices (and their caps).
On gstreamer 0.10 it has been possible through GstPropertyProbe which is removed in gstreamer 1.0. The documentation suggests using GstDeviceMonitor. But i have no luck using that either.
Has anyone succeeded in acquiring a list of device names? Or can you suggests another way of retrieving the available device names and their caps?
You can use GstDeviceMonitor and gst_device_monitor_get_devices () function.
First initialize GstDeviceMonitor by gst_device_monitor_new().
Second start the monitor by gst_device_monitor_start(pMonitor).
Third, get devices list by gst_device_monitor_get_devices(pMonitor).
Code would be like this:
GstDeviceMonitor* monitor= gst_device_monitor_new();
if(!gst_device_monitor_start(monitor)){
printf("WARNING: Monitor couldn't started!!\n");
}
GList* devices = gst_device_monitor_get_devices(monitor);
My references:
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstDeviceMonitor.html#gst-device-monitor-get-devices
Although I haven't figured out how to enumerate the device names, I've come up with a workaround to at least get the available ksvideosrc device indexes. Below is the code in Python, but you should be able to port it to C++ fairly easily, thanks to the GObject introspection bindings.
from gi.repository import Gst
def get_ksvideosrc_device_indexes():
device_index = 0
video_src = Gst.ElementFactory.make('ksvideosrc')
state_change_code = None
while True:
video_src.set_state(Gst.State.NULL)
video_src.set_property('device-index', device_index)
state_change_code = video_src.set_state(Gst.State.READY)
if state_change_code != Gst.StateChangeReturn.SUCCESS:
video_src.set_state(Gst.State.NULL)
break
device_index += 1
return range(device_index)
if __name__ == '__main__':
Gst.init()
print get_ksvideosrc_device_indexes()
Note that the video source device-name property is None as of GStreamer version 1.4.5.0 on Windows for the ksvideosrc.
It's very late, but for the future...
The Gst.DeviceMonitor can be used to enumerate devices, and register an addition or removal of a device.
Here's how to get device names in C# with GStreamer 1.14
static class Devices
{
public static void Run(string[] args)
{
Application.Init(ref args);
GtkSharp.GstreamerSharp.ObjectManager.Initialize();
var devmon = new DeviceMonitor();
// to show only cameras
// var caps = new Caps("video/x-raw");
// var filtId = devmon.AddFilter("Video/Source", caps);
var bus = devmon.Bus;
bus.AddWatch(OnBusMessage);
if (!devmon.Start())
{
"Device monitor cannot start".PrintErr();
return;
}
Console.WriteLine("Video devices count = " + devmon.Devices.Length);
foreach (var dev in devmon.Devices)
DumpDevice(dev);
var loop = new GLib.MainLoop();
loop.Run();
}
static void DumpDevice(Device d)
{
Console.WriteLine($"{d.DeviceClass} : {d.DisplayName} : {d.Name} ");
}
static bool OnBusMessage(Bus bus, Message message)
{
switch (message.Type)
{
case MessageType.DeviceAdded:
{
var dev = message.ParseDeviceAdded();
Console.WriteLine("Device added: ");
DumpDevice(dev);
break;
}
case MessageType.DeviceRemoved:
{
var dev = message.ParseDeviceRemoved();
Console.WriteLine("Device removed: ");
DumpDevice(dev);
break;
}
}
return true;
}
}