aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport
diff options
context:
space:
mode:
authormichele papalini <micpapal+fdio@cisco.com>2019-01-22 10:16:53 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-01-22 09:20:37 +0000
commitb8bd68b9544b7e4463178f54b54850cc44f2cb0e (patch)
treedf076c44dfb930ccc3428d6648572bedf6e4de7f /libtransport
parent7d710d62fcb2a15505a7a0fc8feb91b8342fafd6 (diff)
jira issue HICN-7
Change-Id: Id07bd589e06852f0788b823735af1b95e09bba0a Signed-off-by: michele papalini <micpapal+fdio@cisco.com>
Diffstat (limited to 'libtransport')
-rw-r--r--libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc27
-rw-r--r--libtransport/src/hicn/transport/protocols/rtc.cc1
2 files changed, 15 insertions, 13 deletions
diff --git a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc
index ec8c4c69e..7b39e7ac9 100644
--- a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc
+++ b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc
@@ -47,7 +47,9 @@ RTCProducerSocket::RTCProducerSocket(asio::io_service &io_service)
bytesProductionRate_(0),
packetsProductionRate_(INIT_PACKET_PRODUCTION_RATE),
perSecondFactor_(1000 / STATS_INTERVAL_DURATION) {
- nack_->appendPayload(utils::MemBuf::create(NACK_HEADER_SIZE));
+ auto nack_payload = utils::MemBuf::create(NACK_HEADER_SIZE);
+ nack_payload->append(NACK_HEADER_SIZE);
+ nack_->appendPayload(std::move(nack_payload));
lastStats_ = std::chrono::steady_clock::now();
srand(time(NULL));
prodLabel_ = ((rand() % 255) << 24UL);
@@ -100,24 +102,23 @@ void RTCProducerSocket::produce(const uint8_t *buf, size_t buffer_size) {
updateStats(buffer_size + headerSize_ + TIMESTAMP_LEN);
- std::shared_ptr<ContentObject> content_object =
- std::make_shared<ContentObject>(flowName_.setSuffix(currentSeg_));
- auto payload = utils::MemBuf::copyBuffer(buf, buffer_size, TIMESTAMP_LEN);
-
- // content_object->setLifetime(content_object_expiry_time_);
- content_object->setLifetime(1000); // XXX this should be set by the APP
+ ContentObject content_object(flowName_.setSuffix(currentSeg_));
uint64_t timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
- payload->prepend(TIMESTAMP_LEN);
- uint8_t *payloadPointer = payload->writableData();
- *(uint64_t *)payloadPointer = timestamp;
- content_object->appendPayload(std::move(payload));
+ auto payload = utils::MemBuf::create(buffer_size + TIMESTAMP_LEN);
+
+ memcpy(payload->writableData(), &timestamp, TIMESTAMP_LEN);
+ memcpy(payload->writableData() + TIMESTAMP_LEN, buf, buffer_size);
+ payload->append(buffer_size + TIMESTAMP_LEN);
+ content_object.appendPayload(std::move(payload));
+
+ content_object.setLifetime(1000); // XXX this should be set by the APP
- content_object->setPathLabel(prodLabel_);
- portal_->sendContentObject(*content_object);
+ content_object.setPathLabel(prodLabel_);
+ portal_->sendContentObject(content_object);
currentSeg_++;
}
diff --git a/libtransport/src/hicn/transport/protocols/rtc.cc b/libtransport/src/hicn/transport/protocols/rtc.cc
index ee90e5d9e..f73b40d1b 100644
--- a/libtransport/src/hicn/transport/protocols/rtc.cc
+++ b/libtransport/src/hicn/transport/protocols/rtc.cc
@@ -102,6 +102,7 @@ void RTCTransportProtocol::onRTCPPacket(uint8_t *packet, size_t len) {
// private
void RTCTransportProtocol::reset() {
+ portal_->setConsumerCallback(this);
// controller var
lastRoundBegin_ = std::chrono::steady_clock::now();
currentState_ = RTC_SYNC_STATE;