This library works with a series of TBXcast groups and the network topology.
Once the topology is known (either given or calculated through OSPF) and a TBXcast group created packages can be sent to this group from the local machine.
An example of the code to create a group, add members and send a package to them follows :
As an example of a topology we are going to use :
+---+ a::0 a::1 +---+ b::1 b::2 +---+
| 0 |---------------| 1 |----------------| 2 |
+---+ +---+ +---+
|c::0 |d::1
| |
| |d::3
| c::3 +---+ +---+
+-----------------| 3 |----------------| 4 |
+---+ e::3 e::4 +---+
We are going to send a package from the node 2 to nodes 0 and 4
int main()
{
TBXcastInitTopology();
struct q_o_s qos; qos.bandwidth = 1;
TBXcastAddRoute(0, 1, _mk_in6_addr("a::1"), qos);
TBXcastAddRoute(1, 0, _mk_in6_addr("a::0"), qos);
TBXcastAddRoute(1, 2, _mk_in6_addr("b::2"), qos);
TBXcastAddRoute(2, 1, _mk_in6_addr("b::1"), qos);
TBXcastAddRoute(0, 3, _mk_in6_addr("c::3"), qos);
TBXcastAddRoute(3, 0, _mk_in6_addr("c::0"), qos);
TBXcastAddRoute(1, 3, _mk_in6_addr("d::3"), qos);
TBXcastAddRoute(3, 1, _mk_in6_addr("d::1"), qos);
TBXcastAddRoute(3, 4, _mk_in6_addr("e::4"), qos);
TBXcastAddRoute(4, 3, _mk_in6_addr("e::3"), qos);
TBXcastCreateRoutingMatrix(NO_QOS);
gid = TBXcastCreateGroup(0, NULL, 0);
TBXcastAddMember(_mk_in6_addr("a::0"), gid);
TBXcastAddMember(_mk_in6_addr("e::4"), gid);
struct tbxcast6_node* rtree;
TBXcastCreateTree(_mk_in6_addr("b::2"), gid, &rtree, 0);
int hlim = 32; // hop limit
TBXcastSetSockOpt(gid, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hlim, sizeof(int));
TBXcastAddTree(gid, grtree);
TBXcastSend(gid, (char*)data, datalen); }
1.5.5