Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
U
udpdk
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
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
ywj
udpdk
Commits
1bee1fb2
Commit
1bee1fb2
authored
Feb 25, 2021
by
Leonardo Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved logging reliability
parent
cedd81a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
apps/pingpong/main.c
apps/pingpong/main.c
+13
-5
No files found.
apps/pingpong/main.c
View file @
1bee1fb2
...
...
@@ -22,6 +22,7 @@
#define PORT_PING 10000
#define PORT_PONG 10001
#define IP_PONG "172.31.100.1"
#define MAX_SAMPLES 100000
typedef
enum
{
PING
,
PONG
}
app_mode
;
...
...
@@ -31,6 +32,8 @@ static int log_enabled = 0;
static
char
*
log_file
;
static
FILE
*
log
;
static
unsigned
delay
=
1000000
;
static
unsigned
samples
[
MAX_SAMPLES
];
static
unsigned
n_samples
=
0
;
static
const
char
*
progname
;
static
void
signal_handler
(
int
signum
)
...
...
@@ -73,10 +76,10 @@ static void ping_body(void)
}
while
(
app_alive
)
{
printf
((
"Application loop
\n
"
));
// Send ping
printf
(
"Sending ping
\n
"
);
if
(
!
log_enabled
)
printf
(
"Sending ping
\n
"
);
destaddr
.
sin_family
=
AF_INET
;
destaddr
.
sin_addr
.
s_addr
=
inet_addr
(
IP_PONG
);
destaddr
.
sin_port
=
htons
(
PORT_PONG
);
...
...
@@ -94,9 +97,10 @@ static void ping_body(void)
ts
.
tv_nsec
+=
1000000000
;
ts
.
tv_sec
--
;
}
printf
(
"Received pong; delta = %d.%09d seconds
\n
"
,
(
int
)
ts
.
tv_sec
,
(
int
)
ts
.
tv_nsec
);
if
(
log_file
)
{
fprintf
(
log
,
" %d%09d
\n
"
,
(
int
)
ts
.
tv_sec
,
(
int
)
ts
.
tv_nsec
);
if
(
log_enabled
)
{
samples
[
n_samples
++
]
=
(
int
)
ts
.
tv_sec
*
1000000000
+
(
int
)
ts
.
tv_nsec
;
}
else
{
printf
(
"Received pong; delta = %d.%09d seconds
\n
"
,
(
int
)
ts
.
tv_sec
,
(
int
)
ts
.
tv_nsec
);
}
}
...
...
@@ -222,6 +226,10 @@ int main(int argc, char *argv[])
pingpong_end:
if
(
log_enabled
)
{
printf
(
"Dumping %d samples to log...
\n
"
,
n_samples
);
for
(
unsigned
i
=
0
;
i
<
n_samples
;
++
i
)
fprintf
(
log
,
"%d
\n
"
,
samples
[
i
]);
printf
(
"Closing log...
\n
"
);
fclose
(
log
);
}
udpdk_interrupt
(
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