diff --git a/common/normNode.cpp b/common/normNode.cpp index 8dc4a3f..d8c1c12 100644 --- a/common/normNode.cpp +++ b/common/normNode.cpp @@ -1143,7 +1143,6 @@ void NormServerNode::RepairCheck(NormObject::CheckLevel checkLevel, // and queue for transmission to this server node bool NormServerNode::OnRepairTimeout(ProtoTimer& /*theTimer*/) { - switch(repair_timer.GetRepeatCount()) { case 0: // hold-off time complete @@ -1375,16 +1374,17 @@ void NormServerNode::UpdateRecvRate(const struct timeval& currentTime, unsigned if (currentTime.tv_usec > prev_update_time.tv_sec) interval += 1.0e-06*(double)(currentTime.tv_usec - prev_update_time.tv_usec); else - interval -= 1.0e-06*(double)(prev_update_time.tv_usec - currentTime.tv_usec); - recv_accumulator += msgSize; - + interval -= 1.0e-06*(double)(prev_update_time.tv_usec - currentTime.tv_usec); double rttEstimate = rtt_confirmed ? rtt_estimate : grtt_estimate; - - if (interval >= rttEstimate) + if (interval < rttEstimate) + { + recv_accumulator += msgSize; + } + else { recv_rate = ((double)(recv_accumulator)) / interval; prev_update_time = currentTime; - recv_accumulator = 0; + recv_accumulator = msgSize; } } else @@ -1421,6 +1421,19 @@ bool NormServerNode::OnActivityTimeout(ProtoTimer& /*theTimer*/) struct timeval currentTime; ::ProtoSystemTime(currentTime); UpdateRecvRate(currentTime, 0); + if (synchronized) + { + NormObject* objMax = rx_table.Find(max_pending_object); + if (NULL != objMax) + RepairCheck(NormObject::THRU_SEGMENT, + max_pending_object, + objMax->GetMaxPendingBlockId(), + objMax->GetMaxPendingSegmentId()); + else + RepairCheck(NormObject::THRU_SEGMENT, // (TBD) thru object??? + max_pending_object, 0, 0); + } + } if (0 == activity_timer.GetRepeatCount()) { diff --git a/common/normObject.cpp b/common/normObject.cpp index 955751f..6267865 100644 --- a/common/normObject.cpp +++ b/common/normObject.cpp @@ -312,6 +312,7 @@ bool NormObject::ActivateRepairs() // Activate partial block (segment) repairs NormBlockBuffer::Iterator iterator(block_buffer); NormBlock* block; + while ((block = iterator.GetNextBlock())) { if (block->ActivateRepairs(nparity)) @@ -944,9 +945,9 @@ void NormObject::HandleObjectMessage(const NormObjectMsg& msg, { if (!(block = server->GetFreeBlock(transport_id, blockId))) { - DMSG(2, "NormObject::HandleObjectMessage() node>%lu server>%lu obj>%hu " - "Warning! no free blocks ...\n", LocalNodeId(), server->GetId(), - (UINT16)transport_id); + //DMSG(2, "NormObject::HandleObjectMessage() node>%lu server>%lu obj>%hu " + // "Warning! no free blocks ...\n", LocalNodeId(), server->GetId(), + // (UINT16)transport_id); return; } block->RxInit(blockId, numData, nparity); @@ -958,9 +959,9 @@ void NormObject::HandleObjectMessage(const NormObjectMsg& msg, char* segment = server->GetFreeSegment(transport_id, blockId); if (!segment) { - DMSG(2, "NormObject::HandleObjectMessage() node>%lu server>%lu obj>%hu " - "Warning! no free segments ...\n", LocalNodeId(), server->GetId(), - (UINT16)transport_id); + //DMSG(2, "NormObject::HandleObjectMessage() node>%lu server>%lu obj>%hu " + // "Warning! no free segments ...\n", LocalNodeId(), server->GetId(), + // (UINT16)transport_id); return; } UINT16 segmentLength = data.GetPayloadDataLength(); @@ -1024,9 +1025,9 @@ void NormObject::HandleObjectMessage(const NormObjectMsg& msg, { if (!(segment = server->GetFreeSegment(transport_id, blockId))) { - DMSG(2, "NormObject::HandleObjectMessage() node>%lu server>%lu obj>%hu " - "Warning! no free segments ...\n", LocalNodeId(), server->GetId(), - (UINT16)transport_id); + //DMSG(2, "NormObject::HandleObjectMessage() node>%lu server>%lu obj>%hu " + // "Warning! no free segments ...\n", LocalNodeId(), server->GetId(), + // (UINT16)transport_id); // (TBD) Dump the block ...??? return; } @@ -1122,7 +1123,7 @@ NormBlock* NormObject::StealNonPendingBlock(bool excludeBlock, NormBlockId exclu } // end NormObject::StealNonPendingBlock() -// For client resource management, steals newer block resources when +// For client & server resource management, steals newer block resources when // needing resources for ordinally older blocks. NormBlock* NormObject::StealNewestBlock(bool excludeBlock, NormBlockId excludeId) { @@ -1223,8 +1224,8 @@ bool NormObject::NextServerMsg(NormObjectMsg* msg) { if (!(block = session->ServerGetFreeBlock(transport_id, blockId))) { - DMSG(2, "NormObject::NextServerMsg() node>%lu Warning! server resource " - "constrained (no free blocks).\n", LocalNodeId()); + //DMSG(2, "NormObject::NextServerMsg() node>%lu Warning! server resource " + // "constrained (no free blocks).\n", LocalNodeId()); return false; } // Load block with zero initialized parity segments @@ -1243,8 +1244,8 @@ bool NormObject::NextServerMsg(NormObjectMsg* msg) } else { - DMSG(2, "NormObject::NextServerMsg() node>%lu Warning! server resource " - "constrained (no free segments).\n", LocalNodeId()); + //DMSG(2, "NormObject::NextServerMsg() node>%lu Warning! server resource " + // "constrained (no free segments).\n", LocalNodeId()); session->ServerPutFreeBlock(block); return false; } @@ -1437,8 +1438,8 @@ NormBlock* NormObject::ServerRecoverBlock(NormBlockId blockId) } else { - DMSG(2, "NormObject::ServerRecoverBlock() node>%lu Warning! server resource " - "constrained (no free segments).\n", LocalNodeId()); + //DMSG(2, "NormObject::ServerRecoverBlock() node>%lu Warning! server resource " + // "constrained (no free segments).\n", LocalNodeId()); session->ServerPutFreeBlock(block); return (NormBlock*)NULL; } @@ -1462,8 +1463,8 @@ NormBlock* NormObject::ServerRecoverBlock(NormBlockId blockId) } else { - DMSG(2, "NormObject::ServerRecoverBlock() node>%lu Warning! server resource " - "constrained (no free blocks).\n", LocalNodeId()); + //DMSG(2, "NormObject::ServerRecoverBlock() node>%lu Warning! server resource " + // "constrained (no free blocks).\n", LocalNodeId()); return (NormBlock*)NULL; } } // end NormObject::ServerRecoverBlock() diff --git a/common/normObject.h b/common/normObject.h index 1b16d20..fda8d83 100644 --- a/common/normObject.h +++ b/common/normObject.h @@ -142,6 +142,9 @@ class NormObject bool ActivateRepairs(); bool IsRepairSet(NormBlockId blockId) {return repair_mask.Test(blockId);} bool AppendRepairAdv(NormCmdRepairAdvMsg& cmd); + + NormBlockId GetMaxPendingBlockId() const {return max_pending_block;} + NormSegmentId GetMaxPendingSegmentId() const {return max_pending_segment;} // Used by sender for resource management scheme NormBlock* StealNonPendingBlock(bool excludeBlock, NormBlockId excludeId = 0); diff --git a/common/normSegment.cpp b/common/normSegment.cpp index dbc1af3..6dbcee0 100644 --- a/common/normSegment.cpp +++ b/common/normSegment.cpp @@ -82,6 +82,7 @@ char* NormSegmentPool::Get() { if (!overrun_flag) { + DMSG(0, "NormSegmentPool::Get() warning: operating with constrained buffering resources\n"); overruns++; overrun_flag = true; } @@ -233,7 +234,15 @@ bool NormBlock::TxReset(UINT16 numData, char** ptr = segment_table+numData; while (numParity--) { - if (*ptr) memset(*ptr, 0, segmentSize); + if (*ptr) + { + UINT16 payloadMax = segmentSize + + NormDataMsg::GetStreamPayloadHeaderLength(); +#ifdef SIMULATE + payloadMax = MIN(payloadMax, SIM_PAYLOAD_MAX); +#endif // SIMULATE + memset(*ptr, 0, payloadMax+1); + } ptr++; } erasure_count = 0; diff --git a/common/normSegment.h b/common/normSegment.h index dbb1268..b765610 100644 --- a/common/normSegment.h +++ b/common/normSegment.h @@ -261,6 +261,7 @@ class NormBlockPool } else if (!overrun_flag) { + DMSG(0, "NormBlockPool::Get() warning: operating with constrained buffering resources\n"); overruns++; overrun_flag = true; } diff --git a/common/normSession.cpp b/common/normSession.cpp index d1fd6ee..66d9d27 100644 --- a/common/normSession.cpp +++ b/common/normSession.cpp @@ -2,6 +2,7 @@ #include #include // for gmtime() in NormTrace() + const UINT8 NormSession::DEFAULT_TTL = 255; // bits/sec const double NormSession::DEFAULT_TRANSMIT_RATE = 64000.0; // bits/sec const double NormSession::DEFAULT_GRTT_INTERVAL_MIN = 1.0; // sec @@ -197,7 +198,6 @@ bool NormSession::StartServer(unsigned long bufferSpace, if (numBlocks < 2) numBlocks = 2; unsigned long numSegments = numBlocks * numParity; - if (!block_pool.Init(numBlocks, blockSize)) { DMSG(0, "NormSession::StartServer() block_pool init error\n"); @@ -890,8 +890,6 @@ void NormSession::HandleReceiveMessage(NormMsg& msg, bool wasUnicast) if (trace) NormTrace(currentTime, LocalNodeId(), msg, false); - - switch (msg.GetType()) { case NormMsg::INFO: @@ -907,8 +905,7 @@ void NormSession::HandleReceiveMessage(NormMsg& msg, bool wasUnicast) if (IsClient()) ClientHandleCommand(currentTime, (NormCmdMsg&)msg); break; case NormMsg::NACK: - DMSG(4, "NormSession::HandleReceiveMessage(NormMsg::NACK) node>%lu ...\n", - LocalNodeId()); + DMSG(4, "NormSession::HandleReceiveMessage(NormMsg::NACK) node>%lu ...\n", LocalNodeId()); if (IsServer() && (((NormNackMsg&)msg).GetServerId() == LocalNodeId())) { ServerHandleNackMessage(currentTime, (NormNackMsg&)msg); @@ -924,6 +921,10 @@ void NormSession::HandleReceiveMessage(NormMsg& msg, bool wasUnicast) } } if (IsClient()) ClientHandleNackMessage((NormNackMsg&)msg); + if ((3 == LocalNodeId()) && (currentTime.tv_sec > 26)) + { + int x = 5; + } break; case NormMsg::ACK: if (IsServer() && (((NormAckMsg&)msg).GetServerId() == LocalNodeId())) @@ -1606,7 +1607,7 @@ void NormSession::ServerHandleNackMessage(const struct timeval& currentTime, Nor continue; } } - } + } freshBlock = false; numErasures = extra_parity; prevBlockId = nextBlockId; @@ -1628,13 +1629,19 @@ void NormSession::ServerHandleNackMessage(const struct timeval& currentTime, Nor if (1 == (txBlockIndex - nextBlockId)) { // We're currently sending this block - ASSERT(block->IsPending()); - NormSegmentId firstPending = 0; - block->GetFirstPending(firstPending); - if (lastLockId <= firstPending) - attemptLock = false; - else if (nextSegmentId < firstPending) - firstLockId = firstPending; + if (block->IsPending()) + { + NormSegmentId firstPending = 0; + block->GetFirstPending(firstPending); + if (lastLockId <= firstPending) + attemptLock = false; + else if (nextSegmentId < firstPending) + firstLockId = firstPending; + } + else + { + // block was just recovered + } } else { @@ -1692,13 +1699,20 @@ void NormSession::ServerHandleNackMessage(const struct timeval& currentTime, Nor else if (1 == (txBlockIndex - nextBlockId)) { NormSegmentId firstPending = 0; - if (!block->GetFirstPending(firstPending)) ASSERT(0); - if (nextSegmentId > firstPending) + if (block->GetFirstPending(firstPending)) + { + if (nextSegmentId > firstPending) + object->TxUpdateBlock(block, nextSegmentId, lastSegmentId, numErasures); + else if (lastSegmentId > firstPending) + object->TxUpdateBlock(block, firstPending, lastSegmentId, numErasures); + else if (numErasures > block->ParityCount()) + object->TxUpdateBlock(block, firstPending, firstPending, numErasures); + } + else + { + // This block was just recovered, so do full update object->TxUpdateBlock(block, nextSegmentId, lastSegmentId, numErasures); - else if (lastSegmentId > firstPending) - object->TxUpdateBlock(block, firstPending, lastSegmentId, numErasures); - else if (numErasures > block->ParityCount()) - object->TxUpdateBlock(block, firstPending, firstPending, numErasures); + } } } } @@ -2169,18 +2183,18 @@ bool NormSession::SendMessage(NormMsg& msg) interval += 1.0e-06*(double)(currentTime.tv_usec - prev_update_time.tv_usec); else interval -= 1.0e-06*(double)(prev_update_time.tv_usec - currentTime.tv_usec); - sent_rate += 0.125 * (((double)msgSize)/interval - sent_rate); - prev_update_time = currentTime; - /*if (interval < grtt_advertised) + /*sent_rate += 0.125 * (((double)msgSize)/interval - sent_rate); + prev_update_time = currentTime; */ + if (interval < grtt_advertised) { sent_accumulator += msgSize; } else { - sent_rate = ((double)(sent_accumulator+msgSize)) / interval; + sent_rate = ((double)(sent_accumulator)) / interval; prev_update_time = currentTime; - sent_accumulator = 0; - }*/ + sent_accumulator = msgSize; + } } else { diff --git a/common/normVersion.h b/common/normVersion.h index f4ab427..0c05746 100644 --- a/common/normVersion.h +++ b/common/normVersion.h @@ -32,6 +32,6 @@ #ifndef _NORM_VERSION #define _NORM_VERSION -#define VERSION "1.1b6" +#define VERSION "1.1b7" #endif // _NORM_VERSION diff --git a/unix/Makefile.common b/unix/Makefile.common index 23310bd..43523ec 100644 --- a/unix/Makefile.common +++ b/unix/Makefile.common @@ -13,7 +13,7 @@ NS = ../ns INCLUDES = $(TCL_INCL_PATH) $(SYSTEM_INCLUDES) -I$(UNIX) -I$(COMMON) -I$(PROTOLIB)/common -CFLAGS = -g -DPROTO_DEBUG -DUNIX -O -fPIC $(SYSTEM_HAVES) $(INCLUDES) +CFLAGS = -DPROTO_DEBUG -DUNIX -O -fPIC $(SYSTEM_HAVES) $(INCLUDES) LDFLAGS = $(SYSTEM_LDFLAGS)