Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
a75fd3e6
Commit
a75fd3e6
authored
Sep 03, 2013
by
Baptiste Jonglez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a cost to neighbours, computed from the RTT
parent
b295f15f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
3 deletions
+34
-3
interface.c
interface.c
+3
-0
interface.h
interface.h
+4
-0
neighbour.c
neighbour.c
+26
-3
neighbour.h
neighbour.h
+1
-0
No files found.
interface.c
View file @
a75fd3e6
...
@@ -79,6 +79,9 @@ add_interface(char *ifname, struct interface_conf *if_conf)
...
@@ -79,6 +79,9 @@ add_interface(char *ifname, struct interface_conf *if_conf)
ifp
->
bucket_time
=
now
.
tv_sec
;
ifp
->
bucket_time
=
now
.
tv_sec
;
ifp
->
bucket
=
BUCKET_TOKENS_MAX
;
ifp
->
bucket
=
BUCKET_TOKENS_MAX
;
ifp
->
hello_seqno
=
(
random
()
&
0xFFFF
);
ifp
->
hello_seqno
=
(
random
()
&
0xFFFF
);
ifp
->
rtt_min
=
10000
;
ifp
->
rtt_max
=
120000
;
ifp
->
max_rtt_penalty
=
150
;
if
(
interfaces
==
NULL
)
if
(
interfaces
==
NULL
)
interfaces
=
ifp
;
interfaces
=
ifp
;
...
...
interface.h
View file @
a75fd3e6
...
@@ -91,6 +91,10 @@ struct interface {
...
@@ -91,6 +91,10 @@ struct interface {
unsigned
short
hello_seqno
;
unsigned
short
hello_seqno
;
unsigned
hello_interval
;
unsigned
hello_interval
;
unsigned
update_interval
;
unsigned
update_interval
;
/* Parameters for computing the cost associated to RTT. */
unsigned
int
rtt_min
;
unsigned
int
rtt_max
;
unsigned
int
max_rtt_penalty
;
};
};
#define IF_CONF(_ifp, _field) \
#define IF_CONF(_ifp, _field) \
...
...
neighbour.c
View file @
a75fd3e6
...
@@ -297,10 +297,29 @@ neighbour_rxcost(struct neighbour *neigh)
...
@@ -297,10 +297,29 @@ neighbour_rxcost(struct neighbour *neigh)
}
}
}
}
unsigned
neighbour_rttcost
(
struct
neighbour
*
neigh
)
{
struct
interface
*
ifp
=
neigh
->
ifp
;
if
(
!
ifp
->
max_rtt_penalty
||
!
valid_rtt
(
neigh
))
return
0
;
/* Function: linear behaviour between rtt_min and rtt_max. */
if
(
neigh
->
rtt
<=
ifp
->
rtt_min
)
{
return
0
;
}
else
if
(
neigh
->
rtt
<=
ifp
->
rtt_max
)
{
return
(
ifp
->
max_rtt_penalty
*
(
neigh
->
rtt
-
ifp
->
rtt_min
)
/
(
ifp
->
rtt_max
-
ifp
->
rtt_min
));
}
else
{
return
ifp
->
max_rtt_penalty
;
}
}
unsigned
unsigned
neighbour_cost
(
struct
neighbour
*
neigh
)
neighbour_cost
(
struct
neighbour
*
neigh
)
{
{
unsigned
a
,
b
;
unsigned
a
,
b
,
cost
;
if
(
!
if_up
(
neigh
->
ifp
))
if
(
!
if_up
(
neigh
->
ifp
))
return
INFINITY
;
return
INFINITY
;
...
@@ -315,7 +334,7 @@ neighbour_cost(struct neighbour *neigh)
...
@@ -315,7 +334,7 @@ neighbour_cost(struct neighbour *neigh)
return
INFINITY
;
return
INFINITY
;
if
(
!
(
neigh
->
ifp
->
flags
&
IF_LQ
)
||
(
a
<
256
&&
b
<
256
))
{
if
(
!
(
neigh
->
ifp
->
flags
&
IF_LQ
)
||
(
a
<
256
&&
b
<
256
))
{
return
a
;
cost
=
a
;
}
else
{
}
else
{
/* a = 256/alpha, b = 256/beta, where alpha and beta are the expected
/* a = 256/alpha, b = 256/beta, where alpha and beta are the expected
probabilities of a packet getting through in the direct and reverse
probabilities of a packet getting through in the direct and reverse
...
@@ -324,8 +343,12 @@ neighbour_cost(struct neighbour *neigh)
...
@@ -324,8 +343,12 @@ neighbour_cost(struct neighbour *neigh)
b
=
MAX
(
b
,
256
);
b
=
MAX
(
b
,
256
);
/* 1/(alpha * beta), which is just plain ETX. */
/* 1/(alpha * beta), which is just plain ETX. */
/* Since a and b are capped to 16 bits, overflow is impossible. */
/* Since a and b are capped to 16 bits, overflow is impossible. */
return
MIN
((
a
*
b
+
128
)
>>
8
,
INFINITY
)
;
cost
=
(
a
*
b
+
128
)
>>
8
;
}
}
cost
+=
neighbour_rttcost
(
neigh
);
return
MIN
(
cost
,
INFINITY
);
}
}
int
int
...
...
neighbour.h
View file @
a75fd3e6
...
@@ -54,5 +54,6 @@ int update_neighbour(struct neighbour *neigh, int hello, int hello_interval);
...
@@ -54,5 +54,6 @@ int update_neighbour(struct neighbour *neigh, int hello, int hello_interval);
unsigned
check_neighbours
(
void
);
unsigned
check_neighbours
(
void
);
unsigned
neighbour_txcost
(
struct
neighbour
*
neigh
);
unsigned
neighbour_txcost
(
struct
neighbour
*
neigh
);
unsigned
neighbour_rxcost
(
struct
neighbour
*
neigh
);
unsigned
neighbour_rxcost
(
struct
neighbour
*
neigh
);
unsigned
neighbour_rttcost
(
struct
neighbour
*
neigh
);
unsigned
neighbour_cost
(
struct
neighbour
*
neigh
);
unsigned
neighbour_cost
(
struct
neighbour
*
neigh
);
int
valid_rtt
(
struct
neighbour
*
neigh
);
int
valid_rtt
(
struct
neighbour
*
neigh
);
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