omnetpp.ini File Explanation - ini

# ping app (host[0] pinged by others)
*.host[0].numPingApps = 0
*.host[*].numPingApps = 2
*.host[*].pingApp[*].destAddr = "host[0]"
**.pingApp[0].startTime = uniform(1s,5s)
**.pingApp[1].startTime = 5s+uniform(1s,5s)
**.pingApp[*].printPing = true
The above is a snippet of an omnetpp.ini file for initializing simulations (Currently I'm trying to simulate a WSN "Wireless Sensor Network". Hosts represent sensor nodes. I want to know exactly what does these two lines mean:
*.host[0].numPingApps = 0
*.host[*].numPingApps = 2
Does it mean that host[0] does not ping any of the others, and all the other hosts ping host[0] twice? Can someone please explain.
What if I want a packet (or cMessage) to travel from host[0] to host[n]? Is there any packages from INET I can use? (like using pingApp does the pinging to a certain host)

The meaning of wildcard symbol in omnetpp.ini is explained in OMNeT++ Manual.
There is a rule that:
if a parameter name matches several wildcard-patterns, the first
matching occurrence is used.
The two lines you are asking means: host[0] does not have any pingApp, all other hosts have 2 pingApp's.
As far as the second question is concerned: to generate a traffic from one host to another you can use any of TCPApp, or UDPApp, for example UDPBasicApp.

Related

Script is dropping colon from drive letter

I am attempting to write a script that will identify if one of multiple USB drives are connected in order to create a variable that can be used in a script so I don't have to change variables every time I copy a script to one of these flash drives.
$USBlibrary = #("Test1","Test2")
$USBcurrent = (GWmi Win32_LogicalDisk | Where-Object {$_.VolumeName -in $USBlibrary} | % {$_.DeviceID})
$mydrive = $($USBcurrent[0])
Write-Host "$mydrive"
When indexing the $USBcurrent variable, if multiple drives are connected, it outputs correctly as "D:" or "E:", however if only one drive is connected (which would be the norm) then they system drops the colon from the variable. My understanding is that the system is attempting to read the colon as defining scope, but I have been unable to find a solution to keep this from happening.
That's because $USBCurrent is a single string, not an array. Change (GWmi ...) to #(GWmi ...) to force array output - Mathias R. Jessen

does this regex combination match to an ipv4 address [duplicate]

This question already has answers here:
Extracing IP addresses as whole words with POSIX BRE/ERE regex
(2 answers)
Closed 1 year ago.
im having a hard time trying to create and find a good ipv4 regex match but all i can find is this:
(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})
does this regex combination match to something like xxx.xxx.xxx.xxx or xx.xxx.x.x etc? I'm trying to make a connection to a web server by pinging via domain name to get the ip but when i try it, the code returns that there is not match. here is the ping command btw:
PING google.com (172.217.1.14): 56 data bytes
256.1.1.1 9.900.0.0 etc. are not valid, this parses those out w/o back-tracking (to prevent RE-DoS):
egrep '^((0|1[0-9]{0,2}|2([0-4][0-9]{0,1}|5[0-5]{0,1}|[6-9]){0,1}|[3-9][0-9]{0,1})\.){3}(0|1[0-9]{0,2}|2([0-4][0-9]{0,1}|5[0-5]{0,1}|[6-9]){0,1}|[3-9][0-9]{0,1})$'

Process two strings per line, data and process in single bash script

I have a working solution already with a while read IFS processing a csv file, but I'd like to have it all in a single bash script as the input data never changes.
The data is a list of ip addresses and names;
10.0.0.1,server1
10.0.0.2,server2
172.16.0.1,server3
192.168.0.1,server4
The process itself will run a ping/curl/wget as required, all the while echoing out which server and test it is doing.
I can run the IP list on its own in the same file using a list function and reading the items, but then I don't get the server friendly name echoed out. So my question is, how should I approach this? I was thinking create the data array then parse in to a read somehow and split the tokens, but not sure how. Thought about writing the data out to a temp file then reading it in again and deleting the tmp file afterwards, but this seems messy. Any pointers appreciated.
In terms of a working solution (if someone wanted to provide instead of just advising), the output of the above data could just be echoed out like this;
Testing: $server, IP address: $ip, test 1.
Then I will just sub the tests as required.
Thanks
If you want to include your data directly in a script instead of reading it from a separate file, and you're already using a loop to read the existing data, the easiest way is probably just copy and pasting the data file's contents into a heredoc that the loop reads instead:
#!/usr/bin/env bash
declare -i testno=1 # Make testno an integer variable that uses arithmetic expansion
while IFS=, read -r ip server; do
echo "Testing: $server, IP address: $ip, test $testno"
testno+=1
done <<EOF
10.0.0.1,server1
10.0.0.2,server2
172.16.0.1,server3
192.168.0.1,server4
EOF
which will display
Testing: server1, IP address: 10.0.0.1, test 1
Testing: server2, IP address: 10.0.0.2, test 2
Testing: server3, IP address: 172.16.0.1, test 3
Testing: server4, IP address: 192.168.0.1, test 4

Explain relation between asound.conf file with HFP and A2DP commands

Here i am looking for Testing A2DP and HFP (Hands free) Profiles.
So here in HFP i am using dbus command for sending message over dbus and execute service address of bluez. for connecting and disconnecting.
here i am using below command for audio playing in HFP.
aplay -D hw:0,1 -c 2 -f S16_LE file_name &
can you explain me what is the meaning of hw:0,1 .
HFP supports only 8000 Hz sampling rate wav files.
IN Advanced Audio Distribution Profile (A2DP) defines how the high quality audio can be streamed from one device to another over Bluetooth connection.
here i am using this command , but before this command i have to update asound.conf file.
aplay -Dplug:bluetooth file_name > /dev/null > /dev/null &
and in both case i am using same asound.conf file. which is given below.
pcm.!bluetooth {
type bluetooth
device "BD_ADDR" //bluetooth address of hands free device.
}
pcm.!default {
type plug
slave.pcm "bluetooth"
}
So i want to know the relation of this asound.conf file with HFP command and A2DP command.
Please Help me to sort out this confusion.
can you explain me what is the meaning of hw:0,1 .
The numbers after hw: stand for the sound card number and the device number. A third number can be added (hw:0,0,0) for the sub-device number, but it defaults to the next sub-device avaliable. The numbers start from zero, so, for example, to access the first device on the second sound card, you would use hw:1,0.
So i want to know the relation of this asound.conf file with HFP command and A2DP command.
asound.conf is configuration file for your PulsAudio server, normally you do not need it at all but in some cases you can setup there some specific options or behavior for your hardware. HFP and A2DP are just Bluetooth profiles which are used to communicate with your headset. You can use asound.conf to link sound from your PulsAudio server with Bluetooth device which you are pair. Which means that for example you can set default output/input to this particular BT device, that all applications in your system will use it to play and record sound.
But as I mention before normally all those things happen automatically and you do not need to do anything to make it work.
More about how to use asoundrc/asound.config you can find here: http://alsa.opensrc.org/.asoundrc

Unix : script as proxy to a file

Hi : Is there a way to create a file which, when read, is generated dynamically ?
I wanted to create 3 versions of the same file (one with 10 lines, one with 100 lines, one with all of the lines). Thus, I don't see any need for these to be static, but rather, it would be best if they were proxies from a head/tail/cat command.
The purpose of this is for unit testing - I want a unit test to run on a small portion of the full input file used in production. However, since the code only runs on full files (its actually a hadoop map/reduce application), I want to provide a truncated version of the whole data set without duplicating information.
UPDATE: An Example
more myActualFile.txt
1
2
3
4
5
more myProxyFile2.txt
1
2
more myProxyFile4.txt
1
2
3
4
etc.... So the proxy files are DIFFERENT named files with content that is dynamically provided by simply getting the first n lines of the main file.
This is hacky, but... One way is to use named pipes, and a looping shell script to generate the content (one per named pipe). This script would look like:
while true; do
(
for $(seq linenr); do echo something; done
) >thenamedpipe;
done
Your script would then read from that named pipe.
Another solution, if you are ready to dig into low level stuff, is FUSE.

Resources