NS3 network Emulation (4): Datarate Property

Source: Internet
Author: User

Happy Shrimp

http://blog.csdn.net/lights_joy/

Welcome reprint, but please keep the author information


in the first.py creates a point-to-point channel and has two properties configured:


Pointtopoint = Ns.point_to_point. Pointtopointhelper () Pointtopoint.setdeviceattribute ("Datarate", Ns.core.StringValue ("2Mbps")) Pointtopoint.setchannelattribute ("Delay", Ns.core.StringValue ("100ms"))

in the configurationdataratewhen thefirst.pyA string was passed"2Mbps", this string is finally represented by the followingC + +code to parse:

Booldatarate::D oparse (const std::string s, uint64_t *v) {ns_log_function (S << v);  Std::string::size_type n = s.find_first_not_of ("0123456789.");      if (n! = Std::string::npos) {//Found non-numeric std::istringstream ISS;      Iss.str (s.substr (0, N));      Double R;      ISS >> R;      std::string trailer = S.substr (n, Std::string::npos);        if (trailer = = "bps") {//bit/s *v = (uint64_t) r;        } else if (trailer = = "B/S") {//bit/s *v = (uint64_t) r;        } else if (trailer = = "Bps") {//byte/s *v = (uint64_t) (R * 8);        } else if (trailer = = "B/S") {//byte/s *v = (uint64_t) (R * 8);        } else if (trailer = = "Kbps") {//KILOBITS/S *v = (uint64_t) (R * 1000);        } else if (trailer = = "kb/s") {//KILOBITS/S *v = (uint64_t) (R * 1000); } else if (trailer == "Kbps") {//KILOBITS/S *v = (uint64_t) (R * 1000);        } else if (trailer = = "kb/s") {//KILOBITS/S *v = (uint64_t) (R * 1000);        } else if (trailer = = "KBps") {//kilobyte/s *v = (uint64_t) (R * 8000);        } else if (trailer = = "kb/s") {//kilobyte/s *v = (uint64_t) (R * 8000);        } else if (trailer = = "KBps") {//kilobyte/s *v = (uint64_t) (R * 8000);        } else if (trailer = = "kb/s") {//kilobyte/s *v = (uint64_t) (R * 8000);        } else if (trailer = = "kib/s") {//kibibit/s *v = (uint64_t) (R * 1024);        } else if (trailer = = "kib/s") {//kibibyte/s *v = (uint64_t) (R * 8192);        } else if (trailer = = "Mbps") {//MEGABITS/S *v = (uint64_t) (R * 1000000); } else if (trailer = = "MbS ") {//MEGABITS/S *v = (uint64_t) (R * 1000000);        } else if (trailer = = "MBps") {//MEGABYTES/S *v = (uint64_t) (R * 8000000);        } else if (trailer = = "MB/S") {//MEGABYTES/S *v = (uint64_t) (R * 8000000);        } else if (trailer = = "mib/s") {//MEBIBITS/S *v = (uint64_t) (R * 1048576);        } else if (trailer = = "mib/s") {//mebibyte/s *v = (uint64_t) (R * 1048576 * 8);        } else if (trailer = = "Gbps") {//gigabit/s *v = (uint64_t) (R * 1000000000);        } else if (trailer = = "GB/S") {//gigabit/s *v = (uint64_t) (R * 1000000000);        } else if (trailer = = "GBps") {//gigabyte/s *v = (uint64_t) (R * 8*1000000000); } else if (trailer = = "GB/S") {//gigabyte/s *v = (uint64_t) (R * 8*1000000000);        } else if (trailer = = "gib/s") {//GIBIBITS/S *v = (uint64_t) (R * 1048576 * 1024); } else if (trailer = = "gib/s") {//gibibyte/s *v = (uint64_t) (R * 1048576 * 1024 * 8        );        } else {return false;    } return true;  } std::istringstream ISS;  ISS.STR (s);  ISS >> *v; return true;}

from this piece of code it is also evident that NS3 The expression of the medium rate string and its significance, more clear than the document, it is not known that the rate can have so many ways of expression, Khan a ~~~~


from "Datarate" a few other device properties can be found:

TypeId Simplenetdevice::gettypeid (void) {static TypeId Tid = TypeId ("Ns3::simplenetdevice"). Setparent<netdevice> (). Setgroupname ("Network"). Addconstructor<simplenetdevice> ().                   AddAttribute ("Receiveerrormodel", "the receiver error model used to simulate packet loss",                   Pointervalue (), Makepointeraccessor (&simplenetdevice::m_receiveerrormodel), Makepointerchecker<errormodel> ()). AddAttribute ("Pointtopointmode", "The device is configured and point mode", B Ooleanvalue (False), Makebooleanaccessor (&simplenetdevice::m_pointtopointmode), M Akebooleanchecker ()). AddAttribute ("Txqueue", "A queue to use as the transmit queue in the device.", String          Value ("NS3::D roptailqueue"), Makepointeraccessor (&simplenetdevice::m_queue),         Makepointerchecker<queue> ()). AddAttribute ("Datarate", "the default data rate for point-to-point links. Zero means Infinite ", Dataratevalue (Datarate (" 0b/s ")), Makedatarateaccessor (&si mplenetdevice::m_bps), Makedataratechecker ()).                     Addtracesource ("Phyrxdrop", "Trace source indicating a packet has been dropped"                     "By the device during reception", Maketracesourceaccessor (&simplenetdevice::m_phyrxdroptrace),  "NS3::P acket::tracedcallback"); return TID;}

It's just that we don't care about these properties for now.


Modifydataratevalue that can be found in theNetanimThe most obvious manifestation of this is the length of the arrow that represents the packet, whendatarateto be2MbpsWhen:


when datarate into 200Kbps when it becomes:



The difference is still very obvious!









??

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

NS3 network Emulation (4): Datarate Property

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.