mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-20 16:56:17 +00:00
another merge conflict
This commit is contained in:
parent
d49dd2ab89
commit
6471a1ceb2
69
.vscode/settings.json
vendored
69
.vscode/settings.json
vendored
@ -5,72 +5,7 @@
|
|||||||
"files.insertFinalNewline": false,
|
"files.insertFinalNewline": false,
|
||||||
"files.trimFinalNewlines": false,
|
"files.trimFinalNewlines": false,
|
||||||
"cmake.configureOnOpen": false,
|
"cmake.configureOnOpen": false,
|
||||||
"[cpp]": { "editor.defaultFormatter": "trunk.io"
|
"[cpp]": {
|
||||||
<<<<<<< HEAD
|
"editor.defaultFormatter": "trunk.io"
|
||||||
},
|
|
||||||
"[powershell]": {
|
|
||||||
"editor.defaultFormatter": "ms-vscode.powershell"
|
|
||||||
||||||| parent of 2c4217e6 (fixed forwarding of messanges)
|
|
||||||
},
|
|
||||||
"files.associations": {
|
|
||||||
"array": "cpp",
|
|
||||||
"atomic": "cpp",
|
|
||||||
"*.tcc": "cpp",
|
|
||||||
"cctype": "cpp",
|
|
||||||
"chrono": "cpp",
|
|
||||||
"clocale": "cpp",
|
|
||||||
"cmath": "cpp",
|
|
||||||
"condition_variable": "cpp",
|
|
||||||
"csignal": "cpp",
|
|
||||||
"cstdarg": "cpp",
|
|
||||||
"cstddef": "cpp",
|
|
||||||
"cstdint": "cpp",
|
|
||||||
"cstdio": "cpp",
|
|
||||||
"cstdlib": "cpp",
|
|
||||||
"cstring": "cpp",
|
|
||||||
"ctime": "cpp",
|
|
||||||
"cwchar": "cpp",
|
|
||||||
"cwctype": "cpp",
|
|
||||||
"deque": "cpp",
|
|
||||||
"list": "cpp",
|
|
||||||
"unordered_map": "cpp",
|
|
||||||
"unordered_set": "cpp",
|
|
||||||
"vector": "cpp",
|
|
||||||
"exception": "cpp",
|
|
||||||
"algorithm": "cpp",
|
|
||||||
"functional": "cpp",
|
|
||||||
"iterator": "cpp",
|
|
||||||
"map": "cpp",
|
|
||||||
"memory": "cpp",
|
|
||||||
"memory_resource": "cpp",
|
|
||||||
"numeric": "cpp",
|
|
||||||
"optional": "cpp",
|
|
||||||
"random": "cpp",
|
|
||||||
"ratio": "cpp",
|
|
||||||
"set": "cpp",
|
|
||||||
"string": "cpp",
|
|
||||||
"string_view": "cpp",
|
|
||||||
"system_error": "cpp",
|
|
||||||
"tuple": "cpp",
|
|
||||||
"type_traits": "cpp",
|
|
||||||
"utility": "cpp",
|
|
||||||
"fstream": "cpp",
|
|
||||||
"initializer_list": "cpp",
|
|
||||||
"iomanip": "cpp",
|
|
||||||
"iosfwd": "cpp",
|
|
||||||
"iostream": "cpp",
|
|
||||||
"istream": "cpp",
|
|
||||||
"limits": "cpp",
|
|
||||||
"mutex": "cpp",
|
|
||||||
"new": "cpp",
|
|
||||||
"ostream": "cpp",
|
|
||||||
"sstream": "cpp",
|
|
||||||
"stdexcept": "cpp",
|
|
||||||
"streambuf": "cpp",
|
|
||||||
"thread": "cpp",
|
|
||||||
"cinttypes": "cpp",
|
|
||||||
"typeinfo": "cpp"
|
|
||||||
=======
|
|
||||||
>>>>>>> 2c4217e6 (fixed forwarding of messanges)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,9 @@ bool FloodingRouter::isRebroadcaster()
|
|||||||
void FloodingRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
|
void FloodingRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
if (!isToUs(p) && (p->hop_limit > 0) && !isFromUs(p)) {
|
if (!isToUs(p) && (p->hop_limit > 0) && !isFromUs(p)) {
|
||||||
|
if((moduleConfig.has_fish_eye_state_routing && moduleConfig.fish_eye_state_routing.enabled && (config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState)) && (p->decoded.portnum == meshtastic_PortNum_FISHEYESTATEROUTING_APP)){
|
||||||
|
return false; // Don't want to rebroadcast LSP-Packages beyond 0-Hop-Neighborhood
|
||||||
|
}
|
||||||
if (p->id != 0) {
|
if (p->id != 0) {
|
||||||
if (isRebroadcaster()) {
|
if (isRebroadcaster()) {
|
||||||
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
||||||
|
@ -236,7 +236,7 @@ void MeshService::sendToMesh(meshtastic_MeshPacket *p, RxSource src, bool ccToPh
|
|||||||
if(config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.fish_eye_state_routing.enabled){
|
if(config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.fish_eye_state_routing.enabled){
|
||||||
if(p->decoded.dest != 0 && p->decoded.dest != NODENUM_BROADCAST){
|
if(p->decoded.dest != 0 && p->decoded.dest != NODENUM_BROADCAST){
|
||||||
p->to = fishEyeStateRoutingModule->getNextHopForID(p->decoded.dest);
|
p->to = fishEyeStateRoutingModule->getNextHopForID(p->decoded.dest);
|
||||||
}else if ((p->decoded.dest == p->to && p->decoded.dest != 0 && p->decoded.dest != NODENUM_BROADCAST) || (p->decoded.dest == 0 && p->to != 0 && p->to != NODENUM_BROADCAST ))
|
}else if ((p->decoded.dest == 0) && (p->to != 0) && (p->to != NODENUM_BROADCAST ))
|
||||||
{
|
{
|
||||||
p->decoded.dest = p->to;
|
p->decoded.dest = p->to;
|
||||||
p->to = fishEyeStateRoutingModule->getNextHopForID(p->decoded.dest);
|
p->to = fishEyeStateRoutingModule->getNextHopForID(p->decoded.dest);
|
||||||
|
@ -658,6 +658,9 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
|||||||
copy->decoded = p->decoded;
|
copy->decoded = p->decoded;
|
||||||
copy->to = fishEyeStateRoutingModule->getNextHopForID(copy->decoded.dest);
|
copy->to = fishEyeStateRoutingModule->getNextHopForID(copy->decoded.dest);
|
||||||
copy->from = nodeDB->getNodeNum();
|
copy->from = nodeDB->getNodeNum();
|
||||||
|
char * logout;
|
||||||
|
sprintf(logout, "Forwarding Package to Node %u to Next-Hop %u",p->decoded.dest,copy->to);
|
||||||
|
LOG_DEBUG(logout);
|
||||||
service->sendToMesh(copy);
|
service->sendToMesh(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,89 +17,14 @@ FishEyeStateRoutingModule::FishEyeStateRoutingModule()
|
|||||||
: ProtobufModule("fishEyeStateRouting", meshtastic_PortNum_FISHEYESTATEROUTING_APP, &meshtastic_FishEyeStateRouting_msg),
|
: ProtobufModule("fishEyeStateRouting", meshtastic_PortNum_FISHEYESTATEROUTING_APP, &meshtastic_FishEyeStateRouting_msg),
|
||||||
concurrency::OSThread("FishEyeStateRoutingModule")
|
concurrency::OSThread("FishEyeStateRoutingModule")
|
||||||
{
|
{
|
||||||
LOG_DEBUG("start FSR");
|
|
||||||
std::fflush(NULL);
|
if(!(moduleConfig.fish_eye_state_routing.enabled && config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.has_neighbor_info && moduleConfig.neighbor_info.enabled)){
|
||||||
if(moduleConfig.fish_eye_state_routing.enabled && config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.has_neighbor_info == true && moduleConfig.neighbor_info.enabled == true){
|
|
||||||
setIntervalFromNow(Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval,
|
|
||||||
default_telemetry_broadcast_interval_secs));
|
|
||||||
}else{
|
|
||||||
LOG_DEBUG("FishEyeStateRouting Module is disabled");
|
LOG_DEBUG("FishEyeStateRouting Module is disabled");
|
||||||
std::fflush(NULL);
|
|
||||||
disable();
|
disable();
|
||||||
|
nextLSPPckg = UINT32_MAX;
|
||||||
|
}else {
|
||||||
|
nextLSPPckg = getTime() + moduleConfig.neighbor_info.update_interval;
|
||||||
}
|
}
|
||||||
LOG_DEBUG("End FSR");
|
|
||||||
std::fflush(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gets called from the NeighborInfo-Module if a new NeighborInfo Package arrives
|
|
||||||
*/
|
|
||||||
bool FishEyeStateRoutingModule::addNeighborInfo(meshtastic_NeighborInfo Ninfo){
|
|
||||||
LOG_DEBUG("FSR: addNeighborInfoStart");
|
|
||||||
std::fflush(NULL);
|
|
||||||
auto it = LSPDB.find(Ninfo.node_id);
|
|
||||||
if(it != LSPDB.end()){ //Node already in LSPDB
|
|
||||||
|
|
||||||
if(it->second.LSP.creation < Ninfo.creation){ // Package newer that our Version?
|
|
||||||
bool diff = false; // check if it's any different
|
|
||||||
for(int i = 0; i < min(Ninfo.neighbors_count,it->second.LSP.neighbors_count); i++){
|
|
||||||
if((Ninfo.neighbors[i].node_id) != (it->second.LSP.neighbors[i].node_id)){
|
|
||||||
diff = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff = diff || (it->second.LSP.traveledHops != 1) || (it->second.LSP.neighbors_count != Ninfo.neighbors_count);
|
|
||||||
|
|
||||||
LSPDBEntry entry; //Copy it into Database
|
|
||||||
NinfoToLSPDBEntry(&Ninfo,&entry);
|
|
||||||
if(it->second.forwarded == false){
|
|
||||||
entry.timeout = min(it->second.timeout,entry.timeout);
|
|
||||||
}
|
|
||||||
it->second = entry;
|
|
||||||
|
|
||||||
if(diff && moduleConfig.fish_eye_state_routing.enabled){
|
|
||||||
calcNextHop();
|
|
||||||
LOG_DEBUG("FSR: addNeighborInfoEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{ //Node not in LSPDB
|
|
||||||
LSPDBEntry entry; //new entry
|
|
||||||
NinfoToLSPDBEntry(&Ninfo,&entry);
|
|
||||||
LSPDB.insert(std::make_pair(entry.LSP.node_id,entry)); //insert into DB
|
|
||||||
if(moduleConfig.fish_eye_state_routing.enabled){
|
|
||||||
calcNextHop();
|
|
||||||
}
|
|
||||||
LOG_DEBUG("FSR: addNeighborInfoEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
LOG_DEBUG("FSR: addNeighborInfoEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* convert a meshtastic_NeighborInfo Struct into an LSPDBEntry Struct
|
|
||||||
*/
|
|
||||||
void FishEyeStateRoutingModule::NinfoToLSPDBEntry(meshtastic_NeighborInfo *Ninfo, LSPDBEntry *fsr){
|
|
||||||
LOG_DEBUG("FSR: NinfoToLSPDBEntryStart");
|
|
||||||
std::fflush(NULL);
|
|
||||||
|
|
||||||
fsr->LSP.node_id = Ninfo->node_id;
|
|
||||||
fsr->LSP.traveledHops = 1;
|
|
||||||
fsr->LSP.neighbors_count = Ninfo->neighbors_count;
|
|
||||||
for(int i = 0; i < Ninfo->neighbors_count; i++){
|
|
||||||
fsr->LSP.neighbors[i] = Ninfo->neighbors[i];
|
|
||||||
}
|
|
||||||
fsr->LSP.creation = Ninfo->creation;
|
|
||||||
fsr->timeout = (uint32_t) (getTime() + moduleConfig.neighbor_info.update_interval * std::pow(fsr->LSP.traveledHops, alpha));
|
|
||||||
fsr->forwarded = false;
|
|
||||||
LOG_DEBUG("FSR: NinfoToLSPDBEntryEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -107,8 +32,6 @@ void FishEyeStateRoutingModule::NinfoToLSPDBEntry(meshtastic_NeighborInfo *Ninfo
|
|||||||
* Criteria: Neighbor cout, Node ID, neighbors list (only by ID)
|
* Criteria: Neighbor cout, Node ID, neighbors list (only by ID)
|
||||||
*/
|
*/
|
||||||
bool FishEyeStateRoutingModule::isequal(const meshtastic_FishEyeStateRouting &s1, const meshtastic_FishEyeStateRouting &s2){
|
bool FishEyeStateRoutingModule::isequal(const meshtastic_FishEyeStateRouting &s1, const meshtastic_FishEyeStateRouting &s2){
|
||||||
LOG_DEBUG("FSR: isequalStart");
|
|
||||||
std::fflush(NULL);
|
|
||||||
if((s1.neighbors_count == s2.neighbors_count) && (s1.node_id == s2.node_id)){
|
if((s1.neighbors_count == s2.neighbors_count) && (s1.node_id == s2.node_id)){
|
||||||
bool diff = false;
|
bool diff = false;
|
||||||
for(int i = 0; i < s1.neighbors_count; i++){
|
for(int i = 0; i < s1.neighbors_count; i++){
|
||||||
@ -117,12 +40,8 @@ bool FishEyeStateRoutingModule::isequal(const meshtastic_FishEyeStateRouting &s1
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG_DEBUG("FSR: isequalEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return !diff;
|
return !diff;
|
||||||
}
|
}
|
||||||
LOG_DEBUG("FSR: isequalEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,20 +50,12 @@ bool FishEyeStateRoutingModule::isequal(const meshtastic_FishEyeStateRouting &s1
|
|||||||
* returns next-Hop for a Message to a given NodeID, if Node is unknwon BroadcastID is returned
|
* returns next-Hop for a Message to a given NodeID, if Node is unknwon BroadcastID is returned
|
||||||
*/
|
*/
|
||||||
uint32_t FishEyeStateRoutingModule::getNextHopForID(uint32_t dest){
|
uint32_t FishEyeStateRoutingModule::getNextHopForID(uint32_t dest){
|
||||||
LOG_DEBUG("FSR: getNextHopForIDStart");
|
|
||||||
std::fflush(NULL);
|
|
||||||
if (dest == nodeDB->getNodeNum()){
|
if (dest == nodeDB->getNodeNum()){
|
||||||
LOG_DEBUG("FSR: getNextHopForIDEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return dest;}
|
return dest;}
|
||||||
auto it = NextHopTable.find(dest);
|
auto it = NextHopTable.find(dest);
|
||||||
if(it == NextHopTable.end()){
|
if(it == NextHopTable.end()){
|
||||||
LOG_DEBUG("FSR: getNextHopForIDEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return NODENUM_BROADCAST;
|
return NODENUM_BROADCAST;
|
||||||
}else{
|
}else{
|
||||||
LOG_DEBUG("FSR: getNextHopForIDEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,8 +65,7 @@ uint32_t FishEyeStateRoutingModule::getNextHopForID(uint32_t dest){
|
|||||||
*/
|
*/
|
||||||
bool FishEyeStateRoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_FishEyeStateRouting *lsp)
|
bool FishEyeStateRoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_FishEyeStateRouting *lsp)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("FSR: handleReceivedStart");
|
if(lsp->node_id == nodeDB->getNodeNum()){return true;} // Don't calculate Path to us
|
||||||
std::fflush(NULL);
|
|
||||||
auto it = LSPDB.find(lsp->node_id);
|
auto it = LSPDB.find(lsp->node_id);
|
||||||
if(it != LSPDB.end()){ //Node already in LSPDB
|
if(it != LSPDB.end()){ //Node already in LSPDB
|
||||||
if(it->second.LSP.creation < lsp->creation){
|
if(it->second.LSP.creation < lsp->creation){
|
||||||
@ -165,9 +75,9 @@ bool FishEyeStateRoutingModule::handleReceivedProtobuf(const meshtastic_MeshPack
|
|||||||
it->second.LSP.traveledHops += 1;
|
it->second.LSP.traveledHops += 1;
|
||||||
if(it->second.forwarded){ //calculate Timeout
|
if(it->second.forwarded){ //calculate Timeout
|
||||||
it->second.forwarded = false;
|
it->second.forwarded = false;
|
||||||
it->second.timeout = (uint32_t) (getTime() + moduleConfig.neighbor_info.update_interval * pow(it->second.LSP.traveledHops,alpha));
|
it->second.timeout = (uint32_t) (((int64_t) getTime()) + (((int64_t) moduleConfig.neighbor_info.update_interval) *((int64_t) std::pow((int64_t) it->second.LSP.traveledHops, alpha))));
|
||||||
}else{
|
}else{
|
||||||
it->second.timeout = min(it->second.timeout, (uint32_t) (getTime() + moduleConfig.neighbor_info.update_interval * pow(it->second.LSP.traveledHops,alpha)));
|
it->second.timeout = min(it->second.timeout, (uint32_t) (((int64_t) getTime()) + (((int64_t) moduleConfig.neighbor_info.update_interval) *((int64_t) std::pow((int64_t) it->second.LSP.traveledHops, alpha)))));
|
||||||
}
|
}
|
||||||
if(!diff && moduleConfig.fish_eye_state_routing.enabled){calcNextHop();}
|
if(!diff && moduleConfig.fish_eye_state_routing.enabled){calcNextHop();}
|
||||||
}
|
}
|
||||||
@ -178,48 +88,97 @@ bool FishEyeStateRoutingModule::handleReceivedProtobuf(const meshtastic_MeshPack
|
|||||||
entry.forwarded = false;
|
entry.forwarded = false;
|
||||||
entry.LSP = *lsp;
|
entry.LSP = *lsp;
|
||||||
entry.LSP.traveledHops += 1;
|
entry.LSP.traveledHops += 1;
|
||||||
entry.timeout = (uint32_t) (getTime() + moduleConfig.neighbor_info.update_interval * pow(entry.LSP.traveledHops,alpha));
|
entry.timeout = (uint32_t) (((int64_t) getTime()) + (((int64_t) moduleConfig.neighbor_info.update_interval) *((int64_t) std::pow((int64_t) entry.LSP.traveledHops, alpha))));
|
||||||
LSPDB.insert(std::make_pair(entry.LSP.node_id,entry));
|
LSPDB.insert(std::make_pair(entry.LSP.node_id,entry));
|
||||||
if(moduleConfig.fish_eye_state_routing.enabled){calcNextHop();}
|
if(moduleConfig.fish_eye_state_routing.enabled){calcNextHop();}
|
||||||
}
|
}
|
||||||
LOG_DEBUG("FSR: handleReceivedEnd");
|
char * logout;
|
||||||
std::fflush(NULL);
|
sprintf(logout, "Received LSP-Pckg of Node %u: ",lsp->node_id);
|
||||||
|
for(int i = 0; i< lsp->neighbors_count; i++){
|
||||||
|
sprintf(logout,"%u, ", lsp->neighbors[i].node_id);
|
||||||
|
}
|
||||||
|
LOG_DEBUG(logout);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sends the initial LSP-Package
|
||||||
|
*/
|
||||||
|
void FishEyeStateRoutingModule::sendInitialLSP(){
|
||||||
|
LOG_DEBUG("Sending own Neighborhood ...");
|
||||||
|
meshtastic_FishEyeStateRouting LSPInfo;
|
||||||
|
LSPInfo.creation = getTime();
|
||||||
|
LSPInfo.node_id = nodeDB->getNodeNum();
|
||||||
|
LSPInfo.traveledHops = 0;
|
||||||
|
LSPInfo.neighbors_count = neighborhood.size();
|
||||||
|
for(int i = 0; i < neighborhood.size(); i++){
|
||||||
|
meshtastic_Neighbor entry;
|
||||||
|
entry.node_id = neighborhood[i].node_id;
|
||||||
|
LSPInfo.neighbors[i] = entry;
|
||||||
|
}
|
||||||
|
meshtastic_MeshPacket *p = allocDataProtobuf(LSPInfo);
|
||||||
|
p->to = NODENUM_BROADCAST;
|
||||||
|
p->decoded.want_response = false;
|
||||||
|
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
|
||||||
|
p->decoded.portnum = meshtastic_PortNum_FISHEYESTATEROUTING_APP;
|
||||||
|
service->sendToMesh(p,RX_SRC_LOCAL,true);
|
||||||
|
nextLSPPckg = getTime() + moduleConfig.neighbor_info.update_interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prints the Entrys of the LSP-Database
|
||||||
|
*/
|
||||||
|
void FishEyeStateRoutingModule::printLSPDB(){
|
||||||
|
printf("LSPDB:\n");
|
||||||
|
for(auto etr : LSPDB){
|
||||||
|
printf("Node: %u, Neighbors: %u: ", etr.first -16,etr.second.LSP.neighbors_count);
|
||||||
|
for(int i = 0; i< etr.second.LSP.neighbors_count;i++){
|
||||||
|
printf("%u, ", etr.second.LSP.neighbors[i].node_id -16);
|
||||||
|
}
|
||||||
|
printf(" Timeout: %u, forwarded: %u\n",((int64_t) etr.second.timeout) - ((int64_t) getTime()),etr.second.forwarded);
|
||||||
|
}
|
||||||
|
printf("Total: %i\n",LSPDB.size());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* broadcast all Packages, that weren't broadcastet and whose timeout is expired
|
* broadcast all Packages, that weren't broadcastet and whose timeout is expired
|
||||||
*/
|
*/
|
||||||
int32_t FishEyeStateRoutingModule::runOnce(){
|
int32_t FishEyeStateRoutingModule::runOnce(){
|
||||||
LOG_DEBUG("FSR: runOnceStart");
|
if(((int64_t) getTime()) > ((int64_t) nextLSPPckg)){
|
||||||
std::fflush(NULL);
|
sendInitialLSP();
|
||||||
|
}
|
||||||
|
//printLSPDB();
|
||||||
|
|
||||||
auto it = LSPDB.begin();
|
auto it = LSPDB.begin();
|
||||||
uint32_t min = UINT32_MAX;
|
uint32_t min = UINT32_MAX;
|
||||||
while (it != LSPDB.end()) //iterate over every Entry
|
while (it != LSPDB.end()) //iterate over every Entry
|
||||||
{
|
{
|
||||||
|
if(((((int64_t) getTime())-((int64_t) it->second.timeout)) >= 0) && (!(it->second.forwarded))){ //Timeout expired?
|
||||||
if((getTime() > it->second.timeout) && (!it->second.forwarded )){ //Timeout expired?
|
|
||||||
meshtastic_MeshPacket *p = allocDataProtobuf(it->second.LSP);
|
meshtastic_MeshPacket *p = allocDataProtobuf(it->second.LSP);
|
||||||
p->to = NODENUM_BROADCAST;
|
p->to = NODENUM_BROADCAST;
|
||||||
p->decoded.want_response = false;
|
p->decoded.want_response = false;
|
||||||
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
|
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
|
||||||
|
p->decoded.portnum = meshtastic_PortNum_FISHEYESTATEROUTING_APP;
|
||||||
service->sendToMesh(p,RX_SRC_LOCAL,true);
|
service->sendToMesh(p,RX_SRC_LOCAL,true);
|
||||||
it->second.forwarded = true;
|
it->second.forwarded = true;
|
||||||
|
char * logout;
|
||||||
|
sprintf(logout,"Forwarded LSP-Package of Node %u", it->second.LSP.node_id);
|
||||||
|
LOG_DEBUG(logout);
|
||||||
|
|
||||||
}else if((getTime() < it->second.timeout) && (!it->second.forwarded) && (it->second.timeout < min)){
|
}else if((getTime() < it->second.timeout) && (!(it->second.forwarded)) && (it->second.timeout < min)){
|
||||||
min = it->second.timeout;
|
min = it->second.timeout;
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
|
|
||||||
}
|
}
|
||||||
LOG_DEBUG("FSR: runOnceEnd");
|
|
||||||
std::fflush(NULL);
|
if (min != UINT32_MAX){
|
||||||
return min + 1;
|
return ((int32_t) (((int64_t) min) - ((int64_t) getTime()))) * 1000; // We need seconds here
|
||||||
|
}
|
||||||
|
return{300000};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FishEyeStateRoutingModule::setOwnNeighborhood(meshtastic_NeighborInfo Ninfo){
|
bool FishEyeStateRoutingModule::setOwnNeighborhood(meshtastic_NeighborInfo Ninfo){
|
||||||
LOG_DEBUG("FSR: setOwnNeighborhoodStart");
|
|
||||||
std::fflush(NULL);
|
|
||||||
bool diff = false;
|
bool diff = false;
|
||||||
for(int i = 0; i<min((uint32_t) Ninfo.neighbors_count,(uint32_t) neighborhood.size()); i++){
|
for(int i = 0; i<min((uint32_t) Ninfo.neighbors_count,(uint32_t) neighborhood.size()); i++){
|
||||||
if(neighborhood[i].node_id != Ninfo.neighbors[i].node_id){diff = true;}
|
if(neighborhood[i].node_id != Ninfo.neighbors[i].node_id){diff = true;}
|
||||||
@ -232,14 +191,10 @@ bool FishEyeStateRoutingModule::setOwnNeighborhood(meshtastic_NeighborInfo Ninfo
|
|||||||
if(diff && moduleConfig.fish_eye_state_routing.enabled){
|
if(diff && moduleConfig.fish_eye_state_routing.enabled){
|
||||||
calcNextHop();
|
calcNextHop();
|
||||||
}
|
}
|
||||||
LOG_DEBUG("FSR: setOwnNeighborhoodEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FishEyeStateRoutingModule::setOwnNeighborhood(std::vector<meshtastic_Neighbor> n){
|
bool FishEyeStateRoutingModule::setOwnNeighborhood(std::vector<meshtastic_Neighbor> n){
|
||||||
LOG_DEBUG("FSR: setOwnNeighborhood2Start");
|
|
||||||
std::fflush(NULL);
|
|
||||||
bool diff = false;
|
bool diff = false;
|
||||||
for(int i = 0; i<min((uint32_t) n.size(), (uint32_t) neighborhood.size()); i++){
|
for(int i = 0; i<min((uint32_t) n.size(), (uint32_t) neighborhood.size()); i++){
|
||||||
if(neighborhood[i].node_id != n[i].node_id){diff = true;}
|
if(neighborhood[i].node_id != n[i].node_id){diff = true;}
|
||||||
@ -252,18 +207,14 @@ bool FishEyeStateRoutingModule::setOwnNeighborhood(std::vector<meshtastic_Neighb
|
|||||||
if(diff && moduleConfig.fish_eye_state_routing.enabled){
|
if(diff && moduleConfig.fish_eye_state_routing.enabled){
|
||||||
calcNextHop();
|
calcNextHop();
|
||||||
}
|
}
|
||||||
LOG_DEBUG("FSR: setOwnNeighborhood2End");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculates and Next-Hops
|
* Calculates the Next-Hops
|
||||||
*/
|
*/
|
||||||
bool FishEyeStateRoutingModule::calcNextHop(){
|
bool FishEyeStateRoutingModule::calcNextHop(){
|
||||||
LOG_DEBUG("FSR: calcNextHopStart");
|
|
||||||
std::fflush(NULL);
|
|
||||||
struct nodeIDwithPrev{
|
struct nodeIDwithPrev{
|
||||||
uint32_t nodeID;
|
uint32_t nodeID;
|
||||||
uint32_t prev;
|
uint32_t prev;
|
||||||
@ -280,43 +231,46 @@ bool FishEyeStateRoutingModule::calcNextHop(){
|
|||||||
}
|
}
|
||||||
alreadyProcessed.insert(ownID);
|
alreadyProcessed.insert(ownID);
|
||||||
|
|
||||||
|
|
||||||
while(waitingqueue.size() != 0){
|
while(waitingqueue.size() != 0){
|
||||||
|
|
||||||
nodeIDwithPrev n = waitingqueue.front();
|
nodeIDwithPrev n = waitingqueue.front();
|
||||||
uint32_t nextHopForN; //calculate NextHop
|
if(alreadyProcessed.find(n.nodeID) == alreadyProcessed.end()){
|
||||||
if(n.prev == ownID){
|
uint32_t nextHopForN; //calculate NextHop
|
||||||
nextHopForN = n.nodeID;
|
if(n.prev == ownID){
|
||||||
}else{
|
nextHopForN = n.nodeID;
|
||||||
auto it = NextHopTable.find(n.prev);
|
|
||||||
if(it == NextHopTable.end()){
|
|
||||||
nextHopForN = NODENUM_BROADCAST;
|
|
||||||
}else{
|
}else{
|
||||||
nextHopForN = it->second;
|
auto it = NextHopTable.find(n.prev);
|
||||||
|
if(it == NextHopTable.end()){
|
||||||
|
nextHopForN = NODENUM_BROADCAST;
|
||||||
|
}else{
|
||||||
|
nextHopForN = it->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
alreadyProcessed.insert(n.nodeID); //Node we just Handeled ist now Porcessed
|
||||||
alreadyProcessed.insert(n.nodeID); //Node we just Handeled ist now Porcessed
|
|
||||||
|
|
||||||
if(NextHopTable.find(n.nodeID) == NextHopTable.end()){ //insert NextHop in Storage
|
if(NextHopTable.find(n.nodeID) == NextHopTable.end()){ //insert NextHop in Storage
|
||||||
NextHopTable.insert(std::make_pair(n.nodeID,nextHopForN));
|
NextHopTable.insert(std::make_pair(n.nodeID,nextHopForN));
|
||||||
}else{
|
}else{
|
||||||
NextHopTable.find(n.nodeID)->second = nextHopForN;
|
NextHopTable.find(n.nodeID)->second = nextHopForN;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = LSPDB.find(n.nodeID); //discover new Nodes and push them in waitingqueue, if we haven't processed them yet (e.g. they aren't in the alreadyProcessed-Set)
|
|
||||||
if(it != LSPDB.end()){
|
auto it = LSPDB.find(n.nodeID); //discover new Nodes and push them in waitingqueue, if we haven't processed them yet (e.g. they aren't in the alreadyProcessed-Set)
|
||||||
for(int i = 0; i < (it->second.LSP.neighbors_count); i++){
|
if(it != LSPDB.end()){
|
||||||
if(alreadyProcessed.find(it->second.LSP.neighbors[i].node_id) == alreadyProcessed.end()){
|
for(int i = 0; i < (it->second.LSP.neighbors_count); i++){
|
||||||
nodeIDwithPrev entry;
|
if(alreadyProcessed.find(it->second.LSP.neighbors[i].node_id) == alreadyProcessed.end()){
|
||||||
entry.nodeID = it->second.LSP.neighbors[i].node_id;
|
nodeIDwithPrev entry;
|
||||||
entry.prev = n.nodeID;
|
entry.nodeID = it->second.LSP.neighbors[i].node_id;
|
||||||
waitingqueue.push(entry);
|
entry.prev = n.nodeID;
|
||||||
|
waitingqueue.push(entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
waitingqueue.pop();
|
waitingqueue.pop();
|
||||||
|
|
||||||
}
|
}
|
||||||
LOG_DEBUG("FSR: calcNextHopEnd");
|
|
||||||
std::fflush(NULL);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
@ -14,11 +14,6 @@ class FishEyeStateRoutingModule : public ProtobufModule<meshtastic_FishEyeStateR
|
|||||||
*/
|
*/
|
||||||
FishEyeStateRoutingModule();
|
FishEyeStateRoutingModule();
|
||||||
|
|
||||||
/*
|
|
||||||
* Get Information of direct Neighbors from the NeighborInfoModule and process it
|
|
||||||
*/
|
|
||||||
bool addNeighborInfo(meshtastic_NeighborInfo Ninfo);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get Next-Hop for Package to dest
|
* Get Next-Hop for Package to dest
|
||||||
*/
|
*/
|
||||||
@ -46,7 +41,8 @@ class FishEyeStateRoutingModule : public ProtobufModule<meshtastic_FishEyeStateR
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
float alpha = 2; // Factor that determins the strenght of blurring towards far nodes
|
float alpha = 1.4; // Factor that determines the strenght of blurring towards outer nodes
|
||||||
|
uint32_t nextLSPPckg = 0;
|
||||||
std::vector<meshtastic_Neighbor> neighborhood; // own Neighborhood as Basis for NextHop Calculation
|
std::vector<meshtastic_Neighbor> neighborhood; // own Neighborhood as Basis for NextHop Calculation
|
||||||
std::unordered_map<uint32_t,uint32_t> NextHopTable; // saves for every reachable known Node the optimal (SSSP) NextHop
|
std::unordered_map<uint32_t,uint32_t> NextHopTable; // saves for every reachable known Node the optimal (SSSP) NextHop
|
||||||
|
|
||||||
@ -72,9 +68,14 @@ class FishEyeStateRoutingModule : public ProtobufModule<meshtastic_FishEyeStateR
|
|||||||
bool calcNextHop();
|
bool calcNextHop();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* converts NeighborInfo Struct into LSPDBEntry-Struct
|
* Send own NeighborInfo to 0-Hop Neighborhood
|
||||||
*/
|
*/
|
||||||
void NinfoToLSPDBEntry(meshtastic_NeighborInfo *Ninfo, LSPDBEntry *fsr);
|
void sendInitialLSP();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* prints the Contents of the LSP-Database
|
||||||
|
*/
|
||||||
|
void printLSPDB();
|
||||||
|
|
||||||
};
|
};
|
||||||
extern FishEyeStateRoutingModule *fishEyeStateRoutingModule;
|
extern FishEyeStateRoutingModule *fishEyeStateRoutingModule;
|
@ -79,9 +79,7 @@ uint32_t NeighborInfoModule::collectNeighborInfo(meshtastic_NeighborInfo *neighb
|
|||||||
}
|
}
|
||||||
printNodeDBNeighbors();
|
printNodeDBNeighbors();
|
||||||
if(config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.fish_eye_state_routing.enabled == true){
|
if(config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.fish_eye_state_routing.enabled == true){
|
||||||
LOG_DEBUG("FSR: IN");
|
|
||||||
fishEyeStateRoutingModule->setOwnNeighborhood(*neighborInfo);
|
fishEyeStateRoutingModule->setOwnNeighborhood(*neighborInfo);
|
||||||
LOG_DEBUG("FSR: OUT");
|
|
||||||
}
|
}
|
||||||
return neighborInfo->neighbors_count;
|
return neighborInfo->neighbors_count;
|
||||||
}
|
}
|
||||||
@ -151,17 +149,8 @@ bool NeighborInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
|
|||||||
// If the hopLimit is the same as hopStart, then it is a neighbor
|
// If the hopLimit is the same as hopStart, then it is a neighbor
|
||||||
getOrCreateNeighbor(mp.from, mp.from, 0, mp.rx_snr); // Set the broadcast interval to 0, as we don't know it
|
getOrCreateNeighbor(mp.from, mp.from, 0, mp.rx_snr); // Set the broadcast interval to 0, as we don't know it
|
||||||
}
|
}
|
||||||
// Note: np can be a Nullptr at this point
|
|
||||||
if(np && moduleConfig.has_fish_eye_state_routing && moduleConfig.fish_eye_state_routing.enabled && (config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState)){
|
|
||||||
//meshtastic_NeighborInfo help = *np;
|
|
||||||
LOG_DEBUG("FSR: go IN");
|
|
||||||
std::fflush(NULL);
|
|
||||||
fishEyeStateRoutingModule->addNeighborInfo(*np);
|
|
||||||
LOG_DEBUG("FSR: return");
|
|
||||||
std::fflush(NULL);
|
|
||||||
}
|
|
||||||
// Allow others to handle this packet
|
// Allow others to handle this packet
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -229,7 +218,7 @@ meshtastic_Neighbor *NeighborInfoModule::getOrCreateNeighbor(NodeNum originalSen
|
|||||||
neighbors.erase(neighbors.begin());
|
neighbors.erase(neighbors.begin());
|
||||||
neighbors.push_back(new_nbr);
|
neighbors.push_back(new_nbr);
|
||||||
}
|
}
|
||||||
if(config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.fish_eye_state_routing.enabled == true){
|
if(config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.fish_eye_state_routing.enabled){
|
||||||
fishEyeStateRoutingModule->setOwnNeighborhood(neighbors);
|
fishEyeStateRoutingModule->setOwnNeighborhood(neighbors);
|
||||||
}
|
}
|
||||||
return &neighbors.back();
|
return &neighbors.back();
|
||||||
|
@ -11,7 +11,6 @@ class NeighborInfoModule : public ProtobufModule<meshtastic_NeighborInfo>, priva
|
|||||||
CallbackObserver<NeighborInfoModule, const meshtastic::Status *>(this, &NeighborInfoModule::handleStatusUpdate);
|
CallbackObserver<NeighborInfoModule, const meshtastic::Status *>(this, &NeighborInfoModule::handleStatusUpdate);
|
||||||
|
|
||||||
std::vector<meshtastic_Neighbor> neighbors;
|
std::vector<meshtastic_Neighbor> neighbors;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
* Expose the constructor
|
* Expose the constructor
|
||||||
|
Loading…
Reference in New Issue
Block a user