Calculate throughput in NS2 using AWK - networking

My senario in NS 2.29 has 5 nodes which each node has 2 interfaces to expect node 0 and node 4 and node 0 wants to send packet to node 4. The protocol I've used is AODV and type of nodes is wireless
I want to calculate
receive packet / send packet
and also throughput in different simulation time and I want to do all with AWK language.
I dont know how to share output file to undrestand what I said.
output file :
s -t 0.100000000 -Hs 0 -Hd -2 -Ni 0 -Nx 0.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl AGT -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 0.0 -Id 4.0 -It cbr -Il 1000 -If 1 -Ii 0 -Iv 32 -Pn cbr -Pi 0 -Pf 0 -Po 0
r -t 0.100000000 -Hs 0 -Hd -2 -Ni 0 -Nx 0.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 0.0 -Id 4.0 -It cbr -Il 1000 -If 1 -Ii 0 -Iv 32 -Pn cbr -Pi 0 -Pf 0 -Po 0
s 0.100000000 _0_ RTR --- 0 AODV 48 [0 0 0 0] ------- [0:255 -1:255 30 0] [0x2 1 1 [4 0] [0 4]] (REQUEST)
s -t 0.100295000 -Hs 0 -Hd -2 -Ni 0 -Nx 0.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md ffffffff -Ms 0 -Mt 800 -Is 0.255 -Id -1.255 -It AODV -Il 100 -If 0 -Ii 0 -Iv 30 -P aodv -Pt 0x2 -Ph 1 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
r -t 0.101095133 -Hs 1 -Hd -2 -Ni 1 -Nx 40.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md ffffffff -Ms 0 -Mt 800 -Is 0.255 -Id -1.255 -It AODV -Il 48 -If 0 -Ii 0 -Iv 30 -P aodv -Pt 0x2 -Ph 1 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
r -t 0.101120133 -Hs 1 -Hd -2 -Ni 1 -Nx 40.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw --- -Ma 0 -Md ffffffff -Ms 0 -Mt 800 -Is 0.255 -Id -1.255 -It AODV -Il 48 -If 0 -Ii 0 -Iv 30 -P aodv -Pt 0x2 -Ph 1 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
s 0.102001360 _1_ RTR --- 0 AODV 48 [0 ffffffff 0 800] ------- [1:255 -1:255 29 0] [0x2 2 1 [4 0] [0 4]] (REQUEST)
s -t 0.102476360 -Hs 1 -Hd -2 -Ni 1 -Nx 40.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md ffffffff -Ms 1 -Mt 800 -Is 1.255 -Id -1.255 -It AODV -Il 100 -If 0 -Ii 0 -Iv 29 -P aodv -Pt 0x2 -Ph 2 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
r -t 0.103276493 -Hs 0 -Hd -2 -Ni 0 -Nx 0.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md ffffffff -Ms 1 -Mt 800 -Is 1.255 -Id -1.255 -It AODV -Il 48 -If 0 -Ii 0 -Iv 29 -P aodv -Pt 0x2 -Ph 2 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
r -t 0.103301493 -Hs 0 -Hd -2 -Ni 0 -Nx 0.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw --- -Ma 0 -Md ffffffff -Ms 1 -Mt 800 -Is 1.255 -Id -1.255 -It AODV -Il 48 -If 0 -Ii 0 -Iv 29 -P aodv -Pt 0x2 -Ph 2 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
s 0.105531867 _1_ RTR --- 0 AODV 48 [0 ffffffff 0 800] ------- [1:255 -1:255 29 0] [0x2 2 1 [4 0] [0 4]] (REQUEST)
s -t 0.105786867 -Hs 1 -Hd -2 -Ni 1 -Nx 40.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md ffffffff -Ms 2 -Mt 800 -Is 1.255 -Id -1.255 -It AODV -Il 100 -If 0 -Ii 0 -Iv 29 -P aodv -Pt 0x2 -Ph 2 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
r -t 0.106587000 -Hs 2 -Hd -2 -Ni 2 -Nx 80.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md ffffffff -Ms 2 -Mt 800 -Is 1.255 -Id -1.255 -It AODV -Il 48 -If 0 -Ii 0 -Iv 29 -P aodv -Pt 0x2 -Ph 2 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
r -t 0.106612000 -Hs 2 -Hd -2 -Ni 2 -Nx 80.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw --- -Ma 0 -Md ffffffff -Ms 2 -Mt 800 -Is 1.255 -Id -1.255 -It AODV -Il 48 -If 0 -Ii 0 -Iv 29 -P aodv -Pt 0x2 -Ph 2 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
s 0.109702791 _2_ RTR --- 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 28 0] [0x2 3 1 [4 0] [0 4]] (REQUEST)
s -t 0.110077791 -Hs 2 -Hd -2 -Ni 2 -Nx 80.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md ffffffff -Ms 4 -Mt 800 -Is 2.255 -Id -1.255 -It AODV -Il 100 -If 0 -Ii 0 -Iv 28 -P aodv -Pt 0x2 -Ph 3 -Pb 1 -Pd 4 -Pds 0 -Ps 0 -Pss 4 -Pc REQUEST
....
to be continue
Can anybody explain how can I do this?
Any answer will be very helpfull.
Thanks

Let's say you have the following two data lines which consist of a timestamp and a number of bytes sent during the time interval ending with that timestamp:
s 1341227109 10010
r 1341227111 19115
s 1341227118 12345
r 1341227122 16773
This snippet would calculate the throughput during the time interval between the two events:
awk '! sprev && $1 == "s" {sprev = $2; next} $1 == "s" {sinterval = $2 - sprev; sthroughput = $2 / sinterval; print sthroughput, "sent bytes/second"}' inputfile
add similar blocks for received data. You can use arrays to track node to node communication separately if needed.
Issues to be addressed:
Do you want to output throughput for each interval? Probably not. Is it good enough to use the first and last event only? Do you want to do some sort of moving calculation taking some number of events or larger segements of time?
Are there different types of events that need to be accounted separately?
Is there data to be ignored or used in setup?
It looks to me that the more natural choice for processing NS2 data might be TCL since it appears to be used within the package and there may be APIs that you can take advantage of. However, AWK is perfectly suited for processing tabular data.

Related

Dump heap in SBCL

My program execution was aborted with the following diagnostics:
Heap exhausted during garbage collection: 0 bytes available, 16 requested.
Gen Boxed Code Raw LgBox LgCode LgRaw Pin Alloc Waste Trig WP GCs Mem-age
3 21843 1 47 0 0 0 59 716955392 368896 2000000 21891 0 1.0481
4 0 0 0 0 0 0 0 0 0 2000000 0 0 0.0000
5 0 0 0 0 0 0 0 0 0 2000000 0 0 0.0000
6 491 2 223 55 0 10 0 24917312 674496 2000000 781 0 0.0000
7 10080 0 15 0 0 0 0 330663696 129264 2000000 10095 0 0.0000
Total bytes allocated = 1072536400
Dynamic-space-size bytes = 1073741824
GC control variables:
*GC-INHIBIT* = true
*GC-PENDING* = true
*STOP-FOR-GC-PENDING* = false
fatal error encountered in SBCL pid 88102(tid 0x7fff9e07c380):
Heap exhausted, game over.
Welcome to LDB, a low-level debugger for the Lisp runtime environment.
ldb>
Is there a way to find where all of the memory was consumed?
The program itself is here: https://github.com/hemml/gridgen2
SBCL's (room t) will give you quite a bit more information if you can do it before you run out of heap. I'm unfamiliar with LDB and whether or not it can execute room. However you could wrap a call to (room t) with something that redirects its output to file, and add the function to the *after-gc-hooks* list so you can see the (extremely verbose) growth patterns.

jfrog cli error "wrong number of arguments" when running jfrog rt config

I'm using the following command in a CI pipeline that builds a Docker container:
RUN curl -fL https://getcli.jfrog.io | sh \
&& mv jfrog /usr/local/bin/jfrog \
&& jfrog rt config --interactive false --url https://artifactory.myorg.com/artifactory
which is failing with error: [Error] Wrong number of arguments.:
Step 8/11 : RUN curl -fL https://getcli.jfrog.io | sh && mv jfrog /usr/local/bin/jfrog && jfrog rt config --interactive false --url https://artifactory.myorg.com/artifactory
---> Running in 975540bce561
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 178 100 178 0 0 329 0 --:--:-- --:--:-- --:--:-- 330
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 985 100 985 0 0 782 0 0:00:01 0:00:01 --:--:-- 3634
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
83 19.2M 83 16.0M 0 0 10.6M 0 0:00:01 0:00:01 --:--:-- 10.6M
100 19.2M 100 19.2M 0 0 11.4M 0 0:00:01 0:00:01 --:--:-- 19.9M
[Error] Wrong number of arguments. You can read the documentation at https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
I've run the same commands on my local machine and gotten the same behaviour.
This is a command that we run in a CI pipeline and the last time that that CI pipeline ran was on 2018-04-19 (about 3 weeks ago) and I can see that on that occasion it succeeded:
Step 8/11 : RUN curl -fL https://getcli.jfrog.io | sh && mv jfrog /usr/local/bin/jfrog && jfrog rt config --interactive false --url https://artifactory.myorg.com/artifactory
---> Using cache
---> 1b0de0d85655
Step 9/11 : etc...
I can only infer that something in the jfrog CLI has changed in the interim. According to the documentation the command we're issuing:
jfrog rt config --interactive false --url https://artifactory.myorg.com/artifactory
is ok.
Hoping someone here can tell me what is wrong with this command,
Turns out this is a breaking change in the latest version of the CLI. Details here: https://github.com/JFrogDev/jfrog-cli-go/issues/165

Proces group id with ps command

I tried ps with different kinds of switches e.g. -A, aux, ef, and so forth but I cannot seem to find the right combination of switches that will tell me the Process ID (PID), Parent Process ID (PPID), Process Group ID (PGID), and the Session ID (SID) of a process in the same output.
Here you go:
$ ps xao pid,ppid,pgid,sid | head
PID PPID PGID SID
1 0 1 1
2 0 0 0
3 2 0 0
6 2 0 0
7 2 0 0
21 2 0 0
22 2 0 0
23 2 0 0
24 2 0 0
If you want to see the process' name as well, use this:
$ ps xao pid,ppid,pgid,sid,comm | head
PID PPID PGID SID COMMAND
1 0 1 1 init
2 0 0 0 kthreadd
3 2 0 0 ksoftirqd/0
6 2 0 0 migration/0
7 2 0 0 watchdog/0
21 2 0 0 cpuset
22 2 0 0 khelper
23 2 0 0 kdevtmpfs
24 2 0 0 netns

Calculating sum of all numbers in a line and printing the output to a separate file

I would like to calculate the sum of all the numbers in a line from a text file and print the output including the numbers and the sum of each line to a separate file.
The input.txt:
input.txt
5S_rRNA 0 0 44 44 1 7
7SK 0 0 44 43 2 4
A1BG 0 0 0 0 0 0
ABCA9.AS1 0 0 0 0 0 0
ABCB1 0 0 1 0 0 0
output.txt
5S_rRNA 0 0 44 44 1 7 96
7SK 0 0 44 43 2 4 93
A1BG 0 0 0 0 0 0 0
ABCA9.AS1 0 0 0 0 0 0 0
ABCB1 0 0 1 0 0 0 1
I have tried:
while read x2 x3 x4 x5 x6 x7
do
x=$((x2+x3+x4+x5+x6+x7))
echo $x
done < input.txt > output.txt
but I get this error message: test_sum.sh: Illegal number: 5S_rRNA
I have also tried
awk '$2+$3+$4+$5+$6+$7 {print $0}' input.txt > output.txt
but I get a load of 0 and 1's.
Any suggestions would be brilliant.
Thanks,
Harriet
You were almost there:
$ awk '{print $0,$2+$3+$4+$5+$6+$7}' file
5S_rRNA 0 0 44 44 1 7 96
7SK 0 0 44 43 2 4 93
A1BG 0 0 0 0 0 0 0
ABCA9.AS1 0 0 0 0 0 0 0
ABCB1 0 0 1 0 0 0 1
In your case,
awk '{print $0,$2+$3+$4+$5+$6+$7}' input.txt > output.txt
5S_rRNA 0 0 44 44 1 7
For a line that looks like the above, the problem in your script is here:
while read x2 x3 x4 x5 x6 x7
#7 items to read, you are using 6 variables.
The above is exactly the reason why you are getting Illegal number: 5S_rRNA
Change that to:
while read x1 x2 x3 x4 x5 x6 x7
# Add the last 6 items as you are doing.
Here's a tricky bash way:
while read -a words; do
echo "${words[#]}" $(IFS=+; echo "${words[*]:1}" | bc)
done < input.txt > output.txt
column -t output.txt
5S_rRNA 0 0 44 44 1 7 96
7SK 0 0 44 43 2 4 93
A1BG 0 0 0 0 0 0 0
ABCA9.AS1 0 0 0 0 0 0 0
ABCB1 0 0 1 0 0 0 1

this is the input and i want to print the output as follows: which command or how can we do that?

this is the input
iws 3211296 3178534 0 Jan 19 - 0:00 iws_trs 000 0 1 2
iws 3539162 3526750 0 Jan 19 - 0:00 iws_trs 000 0 1 2 4
iws 3584214 3535080 0 Jan 19 - 0:00 iws_trs 000 0 1 2 3
iws 3928194 3952828 0 Jan 19 - 0:00 iws_trs 000 0 1 1 4
iws 3928195 3952828 0 Jan 19 - 0:00 iws_trs 000 0 1 3 5
output: which contains 4 at the end
iws 3539162 3526750 0 Jan 19 - 0:00 iws_trs 000 0 1 2 4
iws 3928194 3952828 0 Jan 19 - 0:00 iws_trs 000 0 1 1 4
Which UNIX command can I use or how can we do that?
You can grep for 4$ (the $ means end-of-line).
$ grep '4$' foo.txt
iws 3539162 3526750 0 Jan 19 - 0:00 iws_trs 000 0 1 2 4
iws 3928194 3952828 0 Jan 19 - 0:00 iws_trs 000 0 1 1 4
Assuming that the input is coming in from a file, you can use fgrep for this.
Read more here http://nixdoc.net/man-pages/FreeBSD/man1/fgrep.1.html

Resources