Commit 06be6748 authored by shengjh's avatar shengjh 🇨🇳
Browse files

Change OutbndPktQueue from storing HomaPkt to Packet(so I have to change the sorter class too).

parent 9295c5e0
......@@ -48,6 +48,24 @@ uint32_t HomaPktHelper::getHomaPktHeaderSize(PktType pktType) {
}
return size;
}
uint32_t HomaPktHelper::getDataBytes(PktType pktType)
{
HomaPkt homaPkt = HomaPkt();
homaPkt.setPktType(pktType);
switch (this->getPktType()) {
case PktType::REQUEST:
case PktType::UNSCHED_DATA:
return homaPkt.getUnschedFields().lastByte - homaPkt.getUnschedFields().firstByte + 1;
case PktType::SCHED_DATA:
return homaPkt.getSchedDataFields().lastByte - homaPkt.getSchedDataFields().firstByte + 1;
case PktType::GRANT:
return 0;
default:
throw cRuntimeError("PktType %d not defined", this->getPktType());
}
return 0;
}
/**
*
* For a message of size numDataBytes comprised of packets of type homaPktType,
......
......@@ -15,6 +15,7 @@ public:
HomaPktHelper();
static uint32_t getHomaPktHeaderSize(PktType pktType);
static uint32_t getBytesOnWire(uint32_t numDataBytes, PktType homaPktType);
static uint32_t getDataBytes(PktType pktType);
~HomaPktHelper();
};
......
......@@ -22,7 +22,7 @@
#include "PriorityResolver.h"
#include "HomaPktHelper.h"
#include "inet/networklayer/common/FragmentationTag_m.h"
#include "HomaTransportTag_m.h"
#include "HomaTag_m.h"
// Required by OMNeT++ for all simple modules.
Define_Module(HomaTransport);
......@@ -955,8 +955,9 @@ HomaTransport::OutboundMessage::prepareRequestAndUnsched()
//HomaPkt* unschedPkt = new HomaPkt(sxController->transport); // SJH: change to HomaPktHelper
Packet *packet = new Packet();
packet->addTag<FragmentationReq>()->setDontFragment(true);
packet->addTag<HomaTransport>()->setHomaTransport(sxController->transport);
const auto &unschedDataPart = makeShared<AppMessage>();
unschedDataPart->addTag<Homa>()->setHomaTransport(sxController->transport);//SJH: is it right to add tag to chunk?
unschedDataPart->setPktType(pktType);
EV_DEBUG << "Attaching UserPriorityReq" << EV_FIELD(packet) << EV_ENDL;
packet->addTagIfAbsent<UserPriorityReq>()->setUserPriority(userPriority);
......@@ -991,7 +992,7 @@ HomaTransport::OutboundMessage::prepareRequestAndUnsched()
}
}
unschedDataPart->setUnschedFields(unschedFields);
unschedDataPart->setByteLength(HomaPktHelper::getHomaPktHeaderSize(pktType) + unschedPkt->getDataBytes());
unschedDataPart->setByteLength(HomaPktHelper::getHomaPktHeaderSize(pktType) + HomaPktHelper::getDataBytes(pktType));
packet->insertAtBack(unschedDataPart);
txPkts.push(packet);
/**
......@@ -1098,21 +1099,22 @@ HomaTransport::OutboundMessage::getTransmitReadyPkt(HomaPkt** outPkt)
* true if pkt1 is compared greater than pkt2.
*/
bool
HomaTransport::OutboundMessage::OutbndPktSorter::operator()(const HomaPkt* pkt1,
const HomaPkt* pkt2)
HomaTransport::OutboundMessage::OutbndPktSorter::operator()(const Packet* pkt1, const Packet* pkt2)
{
HomaConfigDepot::SenderScheme txScheme =
pkt1->ownerTransport->homaConfig->getSenderScheme();
auto chunk1 = pkt1->peekAtFront<AppMessage>();
auto chunk2 = pkt2->peekAtFront<AppMessage>();
HomaConfigDepot::SenderScheme txScheme = chunk1->getTag<Homa>()->getHomaTransport()->homaConfig->getSenderScheme();
switch (txScheme) {
case HomaConfigDepot::SenderScheme::OBSERVE_PKT_PRIOS:
case HomaConfigDepot::SenderScheme::SRBF:
return (
pkt1->getFirstByte() > pkt2->getFirstByte() ||
(pkt1->getFirstByte() == pkt2->getFirstByte() &&
pkt1->getCreationTime() > pkt2->getCreationTime()) ||
(pkt1->getFirstByte() == pkt2->getFirstByte() &&
pkt1->getCreationTime() == pkt2->getCreationTime() &&
pkt1->getPriority() > pkt2->getPriority()));
chunk1->getFirstByte() > chunk2->getFirstByte() ||
(chunk1->getFirstByte() == chunk2->getFirstByte() &&
chunk1->getCreationTime() > chunk2->getCreationTime()) ||
(chunk1->getFirstByte() == chunk2->getFirstByte() &&
chunk1->getCreationTime() == chunk2->getCreationTime() &&
chunk1->getPriority() > chunk2->getPriority()));
default:
throw cRuntimeError("Undefined SenderScheme parameter");
}
......
......@@ -68,8 +68,7 @@ public:
~OutboundMessage();
OutboundMessage& operator=(const OutboundMessage& other);
void prepareRequestAndUnsched();
uint32_t prepareSchedPkt(uint32_t offset, uint16_t numBytes,
uint16_t schedPrio);
uint32_t prepareSchedPkt(uint32_t offset, uint16_t numBytes, uint16_t schedPrio);
public:
/**
......@@ -80,10 +79,10 @@ public:
class OutbndPktSorter {
public:
OutbndPktSorter(){}
bool operator()(const HomaPkt* pkt1, const HomaPkt* pkt2);
bool operator()(const Packet* pkt1, const Packet* pkt2);
};
typedef std::priority_queue<HomaPkt*, std::vector<HomaPkt*>, OutbndPktSorter> OutbndPktQueue;
typedef std::priority_queue<Packet*, std::vector<Packet*>, OutbndPktSorter> OutbndPktQueue;
// getters functions
const uint32_t& getMsgSize() { return msgSize; }
......
......@@ -20,7 +20,7 @@ class HomaTransport {
@existingClass;
}
class HomaTransport extends inet::TagBase
class Homa extends inet::TagBase
{
HomaTransport* homaTransport;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment