- Fixing code style issues 19/6219/3
authorMauro Sardara <[email protected]>
Tue, 18 Apr 2017 09:25:13 +0000 (11:25 +0200)
committerMauro Sardara <[email protected]>
Tue, 18 Apr 2017 09:31:56 +0000 (09:31 +0000)
- Adding new feature to producer test: now it is possible to specify the size of the file to download
- Fixing initialization of max number of retransmissions in icnet_socket_consumer.cc

Change-Id: Ia7e48a4beda6adebf5179700c80f6d7316922187
Signed-off-by: Mauro Sardara <[email protected]>
13 files changed:
apps/producers/icnet_producer_test.cc
icnet/ccnx/icnet_ccnx_content_object.cc
icnet/ccnx/icnet_ccnx_interest.cc
icnet/ccnx/icnet_ccnx_key_locator.cc
icnet/ccnx/icnet_ccnx_local_connector.cc
icnet/ccnx/icnet_ccnx_manifest.cc
icnet/ccnx/icnet_ccnx_name.cc
icnet/ccnx/icnet_ccnx_network_message.cc
icnet/ccnx/icnet_ccnx_segment.cc
icnet/transport/icnet_content_store.cc
icnet/transport/icnet_socket_consumer.cc
icnet/transport/icnet_transport.cc
icnet/transport/icnet_transport_vegas_rto_estimator.cc

index 571e961..6add25d 100755 (executable)
 
 #include "icnet_socket_producer.h"
 
-#define IDENTITY_NAME "ciao"
+#define IDENTITY_NAME "cisco"
 
 namespace icnet {
 
 class CallbackContainer {
  public:
-  CallbackContainer() : buffer_(1400, 'X') {
+  CallbackContainer(unsigned long download_size = 0)
+      : buffer_(1400, 'X'), final_chunk_number_(0) {
     content_object_.setContent((uint8_t *) buffer_.c_str(), 1400);
+    if (download_size > 0) {
+      final_chunk_number_ = static_cast<uint64_t>(std::ceil(download_size / 1400));
+    }
   }
 
   void processInterest(ProducerSocket &p, const Interest &interest) {
@@ -31,17 +35,21 @@ class CallbackContainer {
 
   void processIncomingInterest(ProducerSocket &p, const Interest &interest) {
     content_object_.setName(Name(interest.getName().getWrappedStructure()));
+    if (final_chunk_number_ > 0) {
+      content_object_.setFinalChunkNumber(final_chunk_number_);
+    }
     p.produce(content_object_);
   }
  private:
-
   ContentObject content_object_;
   std::string buffer_;
+  uint64_t final_chunk_number_;
 };
 
 class Signer {
  public:
-  Signer() : counter_(0), identity_name_(IDENTITY_NAME) {
+  Signer()
+      : counter_(0), identity_name_(IDENTITY_NAME) {
   };
 
   ~Signer() {
@@ -102,15 +110,19 @@ void becomeDaemon() {
 
 int main(int argc, char **argv) {
   std::string name = "ccnx:/ccnxtest";
+  unsigned long download_size = 0;
   bool daemon = false;
 
   int opt;
-  while ((opt = getopt(argc, argv, "D")) != -1) {
+  while ((opt = getopt(argc, argv, "Ds:")) != -1) {
 
     switch (opt) {
       case 'D':
         daemon = true;
         break;
+      case 's':
+        download_size = std::stoul(optarg);
+        break;
       default:
         exit(EXIT_FAILURE);
     }
@@ -126,7 +138,8 @@ int main(int argc, char **argv) {
     becomeDaemon();
   }
 
-  CallbackContainer stubs;
+  CallbackContainer stubs(download_size);
+
   //  Signer signer;
 
   std::cout << "Setting name.. " << name << std::endl;
index 1a7fa3c..0387572 100644 (file)
@@ -37,13 +37,10 @@ ContentObject::ContentObject(const Name &name, uint8_t *payload, std::size_t siz
   parcBuffer_Release(&buffer);
 }
 
-ContentObject::ContentObject(const CCNxContentObjectStructure *content_object) : name_(ccnxContentObject_GetName(
-    content_object)),
-                                                                                 ccnx_content_object_(
-                                                                                     ccnxContentObject_Acquire(
-                                                                                         content_object)),
-                                                                                 content_type_((PayloadType) ccnxContentObject_GetPayloadType(
-                                                                                     content_object)) {
+ContentObject::ContentObject(const CCNxContentObjectStructure *content_object)
+    : name_(ccnxContentObject_GetName(content_object)),
+      ccnx_content_object_(ccnxContentObject_Acquire(content_object)),
+      content_type_((PayloadType) ccnxContentObject_GetPayloadType(content_object)) {
 }
 
 ContentObject::ContentObject(const Name &name)
index a2bcf72..6b0f92c 100644 (file)
@@ -31,9 +31,8 @@ Interest::Interest(CCNxInterestStruct *interest)
     : name_(ccnxInterest_GetName(interest)), interest_(ccnxInterest_Acquire(interest)) {
 }
 
-Interest::Interest(const Interest &other_interest) : name_(other_interest.name_),
-                                                     interest_(ccnxInterest_CreateSimple(other_interest.name_
-                                                                                             .getWrappedStructure())) {
+Interest::Interest(const Interest &other_interest)
+    : name_(other_interest.name_), interest_(ccnxInterest_CreateSimple(other_interest.name_.getWrappedStructure())) {
   PARCBuffer *buffer = nullptr;
 
   // Key Id restriction
@@ -58,8 +57,8 @@ Interest::Interest(const Interest &other_interest) : name_(other_interest.name_)
   ccnxInterest_SetLifetime(interest_, ccnxInterest_GetLifetime(other_interest.interest_));
 }
 
-Interest::Interest(Interest &&other_interest) : name_(std::move(other_interest.name_)),
-                                                interest_(ccnxInterest_Acquire(other_interest.interest_)) {
+Interest::Interest(Interest &&other_interest)
+    : name_(std::move(other_interest.name_)), interest_(ccnxInterest_Acquire(other_interest.interest_)) {
 }
 
 Interest &Interest::operator=(const Interest &other_interest) {
index 193573a..ad099bc 100644 (file)
@@ -8,10 +8,12 @@ namespace icnet {
 
 namespace ccnx {
 
-KeyLocator::KeyLocator() : type_(KeyLocatorType::UNKNOWN) {
+KeyLocator::KeyLocator()
+    : type_(KeyLocatorType::UNKNOWN) {
 }
 
-KeyLocator::KeyLocator(KeyLocatorType type, Name &name) : type_(type), name_(name) {
+KeyLocator::KeyLocator(KeyLocatorType type, Name &name)
+    : type_(type), name_(name) {
 }
 
 Name &KeyLocator::getName() {
index efe995c..cd828b0 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "icnet_ccnx_local_connector.h"
 
-
 namespace icnet {
 
 namespace ccnx {
@@ -168,9 +167,9 @@ void LocalConnector::doConnect() {
                                  if (is_reconnection_) {
                                    is_reconnection_ = false;
 #ifdef __ANDROID__
-                                     __android_log_print(ANDROID_LOG_DEBUG, "libICNet", "Connection recovered!\n");
+                                   __android_log_print(ANDROID_LOG_DEBUG, "libICNet", "Connection recovered!\n");
 #else
-                                     std::cout << "Connection recovered!" << std::endl;
+                                   std::cout << "Connection recovered!" << std::endl;
 #endif
                                    for (auto &name : served_name_list_) {
                                      bind(name);
index c818f11..b743291 100644 (file)
@@ -20,7 +20,8 @@ namespace icnet {
 
 namespace ccnx {
 
-Manifest::Manifest(Name &name) : ContentObject(name) {
+Manifest::Manifest(Name &name)
+    : ContentObject(name) {
 }
 
 std::size_t Manifest::estimateManifestSize() {
index 2ea0d8a..bb329c8 100644 (file)
@@ -23,21 +23,26 @@ Name::Name() {
   name_ = ccnxName_Create();
 }
 
-Name::Name(const char *uri) : name_(ccnxName_CreateFromCString(uri)) {
+Name::Name(const char *uri)
+    : name_(ccnxName_CreateFromCString(uri)) {
   ccnxName_AssertValid(name_);
 }
 
-Name::Name(std::string uri) : Name(uri.c_str()) {
+Name::Name(std::string uri)
+    : Name(uri.c_str()) {
 }
 
-Name::Name(const CCNxNameStructure *name) : name_(ccnxName_Acquire(name)) {
+Name::Name(const CCNxNameStructure *name)
+    : name_(ccnxName_Acquire(name)) {
   ccnxName_AssertValid(name_);
 }
 
-Name::Name(const Name &name) : name_(ccnxName_Copy(name.name_)) {
+Name::Name(const Name &name)
+    : name_(ccnxName_Copy(name.name_)) {
 }
 
-Name::Name(Name &&otherName) : name_(ccnxName_Acquire(otherName.name_)) {
+Name::Name(Name &&otherName)
+    : name_(ccnxName_Acquire(otherName.name_)) {
 }
 
 Name &Name::operator=(const Name &name) {
index 70dff5f..28ab0c2 100644 (file)
@@ -19,7 +19,8 @@ namespace icnet {
 
 namespace ccnx {
 
-TransportMessage::TransportMessage() : packet_length_(0) {
+TransportMessage::TransportMessage()
+    : packet_length_(0) {
 }
 
 const uint8_t *TransportMessage::data() const {
index 4215650..e487d41 100644 (file)
@@ -19,17 +19,20 @@ namespace icnet {
 
 namespace ccnx {
 
-Segment::Segment(CCNxNameLabelType type, std::string &segment_value) : name_segment_(
-    ccnxNameSegment_CreateTypeValueArray(type, segment_value.length(), segment_value.c_str())) {
+Segment::Segment(CCNxNameLabelType type, std::string &segment_value)
+    : name_segment_(ccnxNameSegment_CreateTypeValueArray(type, segment_value.length(), segment_value.c_str())) {
 }
 
-Segment::Segment(CCNxNameSegmentStructure *segment) : name_segment_(ccnxNameSegment_Acquire(segment)) {
+Segment::Segment(CCNxNameSegmentStructure *segment)
+    : name_segment_(ccnxNameSegment_Acquire(segment)) {
 }
 
-Segment::Segment(const Segment &segment) : name_segment_(ccnxNameSegment_Copy(segment.name_segment_)) {
+Segment::Segment(const Segment &segment)
+    : name_segment_(ccnxNameSegment_Copy(segment.name_segment_)) {
 }
 
-Segment::Segment(Segment &&otherSegment) : name_segment_(ccnxNameSegment_Acquire(otherSegment.name_segment_)) {
+Segment::Segment(Segment &&otherSegment)
+    : name_segment_(ccnxNameSegment_Acquire(otherSegment.name_segment_)) {
 }
 
 Segment::~Segment() {
index 884ad2e..64694b2 100644 (file)
@@ -17,7 +17,8 @@
 
 namespace icnet {
 
-ContentStore::ContentStore(std::size_t max_packets) : max_content_store_size_(max_packets) {
+ContentStore::ContentStore(std::size_t max_packets)
+    : max_content_store_size_(max_packets) {
 }
 
 ContentStore::~ContentStore() {
index b6c928c..2aec571 100644 (file)
@@ -24,6 +24,7 @@ ConsumerSocket::ConsumerSocket(Name prefix, int protocol)
       min_window_size_(default_values::min_window_size),
       max_window_size_(default_values::max_window_size),
       current_window_size_(-1),
+      max_retransmissions_(default_values::transport_protocol_max_retransmissions),
     /****** RAAQM Parameters ******/
       minimum_drop_probability_(default_values::minimum_drop_probability),
       sample_number_(default_values::sample_number),
index c85f02b..632d03c 100644 (file)
@@ -17,7 +17,8 @@
 
 namespace icnet {
 
-TransportProtocol::TransportProtocol(Socket *icn_socket) : socket_(icn_socket), is_running_(false) {
+TransportProtocol::TransportProtocol(Socket *icn_socket)
+    : socket_(icn_socket), is_running_(false) {
 }
 
 void TransportProtocol::updatePortal() {
index 889a6bd..6653518 100644 (file)
 
 namespace icnet {
 
-RtoEstimator::RtoEstimator(Duration min_rto) : smoothed_rtt_(RtoEstimator::getInitialRtt().count()),
-                                               rtt_variation_(0),
-                                               first_measurement_(true),
-                                               last_rto_(min_rto.count()) {
+RtoEstimator::RtoEstimator(Duration min_rto)
+    : smoothed_rtt_(RtoEstimator::getInitialRtt().count()),
+      rtt_variation_(0),
+      first_measurement_(true),
+      last_rto_(min_rto.count()) {
 }
 
 void RtoEstimator::addMeasurement(Duration rtt) {