From: Eduardo Ramos Testillano Date: Mon, 13 Jul 2015 11:49:22 +0000 (+0200) Subject: Fix retransmission issues (order, tracing, etc.) X-Git-Tag: REFACTORING_TESTING_LIBRARY~125 X-Git-Url: https://git.teslayout.com/public/public/public/?a=commitdiff_plain;h=84c30c372cf2926a138a6d51a52d56f3b2a63804;p=anna.git Fix retransmission issues (order, tracing, etc.) --- diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index 05422f4..afb8a96 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -1096,6 +1096,7 @@ std::string Launcher::help() const throw() { result += "\n has been logged)"; result += "\n [recvfe-ans-unknown] Reception from entity of an unknown answer (probably former [req2e-expired]"; result += "\n has been logged)"; + result += "\n [retry] Request retransmission"; result += "\n"; result += "\n-------------------------------------------------------------------------------------------- Load tests"; result += "\n"; @@ -1314,9 +1315,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(!entity) throw anna::RuntimeException("No entity configured to send the message", ANNA_FILE_LOCATION); anna::diameter::comm::Message *msg = createCommMessage(); -//xxxxxxxxxxxxx - msg->setRetries(4); - msg->setOnExpiry(anna::diameter::comm::Message::OnExpiry::Retransmit); + //msg->setRetries(4); + //msg->setOnExpiry(anna::diameter::comm::Message::OnExpiry::Retransmit); if((opType == "sendxml") || (opType == "sendxml2e")) { codecMsg.loadXML(param1); diff --git a/example/diameter/launcher/MyDiameterEntity.cpp b/example/diameter/launcher/MyDiameterEntity.cpp index ae4a3db..d16974b 100644 --- a/example/diameter/launcher/MyDiameterEntity.cpp +++ b/example/diameter/launcher/MyDiameterEntity.cpp @@ -17,6 +17,34 @@ #include "Launcher.hpp" +void MyDiameterEntity::eventRequestRetransmission(const anna::diameter::comm::ClientSession* clientSession, anna::diameter::comm::Message *request) throw() { + + LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventRequestRetransmission", ANNA_FILE_LOCATION)); + + // Base class: + Entity::eventRequestRetransmission(clientSession, request); // warning trace + + // Performance stats: + Launcher& my_app = static_cast (anna::app::functions::getApp()); + CommandLine& cl(anna::CommandLine::instantiate()); + // CommandId: + anna::diameter::CommandId cid = anna::diameter::codec::functions::getCommandId(request->getBody()); + LOGDEBUG + ( + std::string msg = "Request retransmitted: "; + msg += anna::diameter::functions::commandIdAsPairString(cid); + msg += " | DiameterServer: "; + msg += anna::functions::socketLiteralAsString(clientSession->getAddress(), clientSession->getPort()); + msg += " | EventTime: "; + msg += anna::time::functions::currentTimeAsString(); + anna::Logger::debug(msg, ANNA_FILE_LOCATION); + ); + + // Write retransmission + if(my_app.logEnabled()) my_app.writeLogFile(request->getBody(), "retry", clientSession->asString(), a_codecEngine); +} + + void MyDiameterEntity::eventRequest(anna::diameter::comm::ClientSession *clientSession, const anna::DataBlock &message) throw(anna::RuntimeException) { LOGMETHOD(anna::TraceMethod tm("launcher::MyDiameterEntity", "eventRequest", ANNA_FILE_LOCATION)); diff --git a/example/diameter/launcher/MyDiameterEntity.hpp b/example/diameter/launcher/MyDiameterEntity.hpp index e60fdfc..9453d64 100644 --- a/example/diameter/launcher/MyDiameterEntity.hpp +++ b/example/diameter/launcher/MyDiameterEntity.hpp @@ -27,6 +27,7 @@ class MyDiameterEntity : public anna::diameter::comm::Entity { anna::diameter::codec::Engine * a_codecEngine; // for automatic answers (failed-avp), write logs, etc. + void eventRequestRetransmission(const anna::diameter::comm::ClientSession *, anna::diameter::comm::Message*) throw(); void eventResponse(const anna::diameter::comm::Response&) throw(anna::RuntimeException); void eventRequest(anna::diameter::comm::ClientSession *, const anna::DataBlock&) throw(anna::RuntimeException); void eventUnknownResponse(anna::diameter::comm::ClientSession *, const anna::DataBlock&) throw(anna::RuntimeException); diff --git a/source/diameter.comm/Entity.cpp b/source/diameter.comm/Entity.cpp index 25a879c..17c1ebf 100644 --- a/source/diameter.comm/Entity.cpp +++ b/source/diameter.comm/Entity.cpp @@ -90,10 +90,11 @@ int Entity::readSocketId(const Message* message, int maxClientSessions) const th anna::diameter::helpers::base::functions::decodeSessionId(sid, diameterIdentity, high, low /* context-teid */, optional); return (low % maxClientSessions); } - //case anna::diameter::helpers::dcca::ChargingContext::SMS: - //case anna::diameter::helpers::dcca::ChargingContext::MMS: - //default: - // return -1; // IEC model and Unknown traffic types + case anna::diameter::helpers::dcca::ChargingContext::SMS: + case anna::diameter::helpers::dcca::ChargingContext::MMS: + case anna::diameter::helpers::dcca::ChargingContext::Unknown: + default: + return -1; // IEC model and Unknown traffic types } } catch(anna::RuntimeException &ex) { LOGDEBUG( @@ -323,7 +324,11 @@ void Entity::eventPeerShutdown(const ClientSession* clientSession) throw() { void Entity::eventRequestRetransmission(const ClientSession* clientSession, Message *request) throw() { LOGWARNING( std::string msg(clientSession->asString()); - msg += " | eventRequestRetransmission"; + + HopByHop hopByHop = codec::functions::getHopByHop(request->getBody()); // context identification + int retries = request->getRetries(); + + msg += anna::functions::asString(" | eventRequestRetransmission: request with application HopByHop: %u; remaining %d retries", hopByHop, retries); anna::Logger::warning(msg, ANNA_FILE_LOCATION); ); } diff --git a/source/diameter.comm/Session.cpp b/source/diameter.comm/Session.cpp index 051cbce..06bec4b 100644 --- a/source/diameter.comm/Session.cpp +++ b/source/diameter.comm/Session.cpp @@ -240,7 +240,6 @@ throw() { bool doUnbind = false; bool doRetransmission = false; - // Quitar el OnExpiry: no tiene sentido habiendo keep-alive (DWR) if(response->getClassCode() != ClassCode::Bind) { if(response->getRequest()->getOnExpiry() == Message::OnExpiry::Abandon) { a_onDisconnect = OnDisconnect::IgnorePendings; // Abandon is not graceful @@ -270,19 +269,18 @@ throw() { if(doRetransmission) { diameter::comm::Message *request = const_cast(response->getRequest()); - eventRequestRetransmission(request); - int retries = request->getRetries(); if (retries > 0) { retries--; request->setRetries(retries); LOGDEBUG ( - //std::string msg(asString()); - std::string msg = anna::functions::asString("Retransmission initiated for request with HopByHop: %u; remaining %d retries", response->getHopByHop(), retries); + std::string msg(asString()); + msg += anna::functions::asString(" | Retransmission initiated for request with HopByHop: %u; remaining %d retries", response->getHopByHop(), retries); anna::Logger::debug(msg, ANNA_FILE_LOCATION); ); diameter::codec::functions::setPotentiallyReTransmittedMessageBit(*request); + eventRequestRetransmission(request); send(request); } }