Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
dcf74a87
Commit
dcf74a87
authored
Aug 12, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take into account header sizes; allow 0-byte udp packets
parent
4dfa1d39
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
benchmarks/udp-perf.c
benchmarks/udp-perf.c
+8
-2
No files found.
benchmarks/udp-perf.c
View file @
dcf74a87
...
...
@@ -16,6 +16,7 @@
#include <errno.h>
#include <fcntl.h>
#define HDR_SIZE (14 + 20 + 8)
/* eth + ip + udp headers */
static
uint64_t
current_time
(
void
);
static
void
fatal
(
const
char
*
func
,
const
char
*
detailed
)
{
...
...
@@ -42,6 +43,10 @@ static void run_client(const char *to_ip, unsigned to_port, unsigned pkt_size) {
struct
sockaddr_in
addr
,
to
;
void
*
buffer
;
if
(
pkt_size
<
HDR_SIZE
)
fatal
(
NULL
,
"Cannot send packets that small."
);
pkt_size
-=
HDR_SIZE
;
buffer
=
malloc
(
pkt_size
);
if
(
!
buffer
)
fatal
(
"malloc"
,
NULL
);
...
...
@@ -147,7 +152,7 @@ static void run_server(int port, uint64_t max_time, uint64_t max_pkts,
int
fd
,
cfd
,
serverfd
,
status
;
uint64_t
now
,
last_ts
,
last_seq
,
preceived
,
breceived
,
errors
;
uint64_t
start
,
tot_delay
,
max_delay
,
min_delay
,
last_delay
;
ssize_t
pkt_size
=
0
,
buffer_sz
=
1
<<
17
;
/* should be enough */
ssize_t
pkt_size
=
-
1
,
buffer_sz
=
1
<<
17
;
/* should be enough */
void
*
buffer
;
uint64_t
magic
=
0xdeadbeef
;
...
...
@@ -204,7 +209,7 @@ static void run_server(int port, uint64_t max_time, uint64_t max_pkts,
if
(
received
>=
8
)
seq
=
((
uint64_t
*
)
buffer
)[
1
];
if
(
!
pkt_size
)
{
if
(
pkt_size
==
-
1
)
{
/* init */
pkt_size
=
received
;
last_ts
=
ts
;
...
...
@@ -218,6 +223,7 @@ static void run_server(int port, uint64_t max_time, uint64_t max_pkts,
}
else
{
preceived
++
;
breceived
+=
received
;
breceived
+=
HDR_SIZE
;
if
(
ts
)
{
last_delay
=
now
-
ts
;
tot_delay
+=
last_delay
;
...
...
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