Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
iproute2
Commits
ebfd0f31
Commit
ebfd0f31
authored
Jun 15, 2006
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added stats utility from netem
parent
8f8a3648
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
2 deletions
+82
-2
netem/Makefile
netem/Makefile
+3
-0
netem/maketable.c
netem/maketable.c
+2
-2
netem/stats.c
netem/stats.c
+77
-0
No files found.
netem/Makefile
View file @
ebfd0f31
...
...
@@ -15,6 +15,9 @@ $(DISTGEN):
experimental.dist
:
maketable experimental.dat
./maketable experimental.dat
>
experimental.dist
stats
:
stats.c
$(HOSTCC)
$(CCOPTS)
-I
../include
-o
$@
$@
.c
-lm
install
:
all
mkdir
-p
$(DESTDIR)
/usr/lib/tc
for
i
in
$(DISTDATA)
;
\
...
...
netem/maketable.c
View file @
ebfd0f31
/*
* Experimental data distribution table generator
* Taken from the uncopyrighted NISTnet code.
* Taken from the uncopyrighted NISTnet code
(public domain)
.
*
* R
r
ead in a series of "random" data values, either
* Read in a series of "random" data values, either
* experimentally or generated from some probability distribution.
* From this, create the inverse distribution table used to approximate
* the distribution.
...
...
netem/stats.c
0 → 100644
View file @
ebfd0f31
/*
* Experimental data distribution table generator
* Taken from the uncopyrighted NISTnet code (public domain).
*
* Rread in a series of "random" data values, either
* experimentally or generated from some probability distribution.
* From this, report statistics.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
void
stats
(
FILE
*
fp
)
{
struct
stat
info
;
double
*
x
;
int
limit
;
int
n
=
0
,
i
;
double
mu
=
0
.
0
,
sigma
=
0
.
0
,
sumsquare
=
0
.
0
,
sum
=
0
.
0
,
top
=
0
.
0
,
rho
=
0
.
0
;
double
sigma2
=
0
.
0
;
fstat
(
fileno
(
fp
),
&
info
);
if
(
info
.
st_size
>
0
)
{
limit
=
2
*
info
.
st_size
/
sizeof
(
double
);
/* @@ approximate */
}
else
{
limit
=
10000
;
}
x
=
(
double
*
)
malloc
(
limit
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
limit
;
++
i
){
fscanf
(
fp
,
"%lf"
,
&
x
[
i
]);
if
(
feof
(
fp
))
break
;
sumsquare
+=
x
[
i
]
*
x
[
i
];
sum
+=
x
[
i
];
++
n
;
}
mu
=
sum
/
(
double
)
n
;
sigma
=
sqrt
((
sumsquare
-
(
double
)
n
*
mu
*
mu
)
/
(
double
)(
n
-
1
));
for
(
i
=
1
;
i
<
n
;
++
i
){
top
+=
((
double
)
x
[
i
]
-
mu
)
*
((
double
)
x
[
i
-
1
]
-
mu
);
sigma2
+=
((
double
)
x
[
i
-
1
]
-
mu
)
*
((
double
)
x
[
i
-
1
]
-
mu
);
}
rho
=
top
/
sigma2
;
printf
(
"mu = %12.6f
\n
"
,
mu
);
printf
(
"sigma = %12.6f
\n
"
,
sigma
);
printf
(
"rho = %12.6f
\n
"
,
rho
);
/*printf("sigma2 = %10.4f\n", sqrt(sigma2/(double)(n-1)));*/
/*printf("correlation rho = %10.6f\n", top/((double)(n-1)*sigma*sigma));*/
}
int
main
(
int
argc
,
char
**
argv
)
{
FILE
*
fp
;
if
(
argc
>
1
)
{
fp
=
fopen
(
argv
[
1
],
"r"
);
if
(
!
fp
)
{
perror
(
argv
[
1
]);
exit
(
1
);
}
}
else
{
fp
=
stdin
;
}
stats
(
fp
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment