OLD | NEW |
1 .. include:: replace.txt | 1 .. include:: replace.txt |
2 .. highlight:: cpp | 2 .. highlight:: cpp |
3 | 3 |
4 TCP models in ns-3 | 4 TCP models in ns-3 |
5 ------------------ | 5 ------------------ |
6 | 6 |
7 This chapter describes the TCP models available in |ns3|. | 7 This chapter describes the TCP models available in |ns3|. |
8 | 8 |
9 Generic support for TCP | 9 Generic support for TCP |
10 *********************** | 10 *********************** |
(...skipping 22 matching lines...) Expand all Loading... |
33 with |ns3| makes available also some additional TCP implementations, but | 33 with |ns3| makes available also some additional TCP implementations, but |
34 those are out of scope for this chapter. | 34 those are out of scope for this chapter. |
35 | 35 |
36 ns-3 TCP | 36 ns-3 TCP |
37 ******** | 37 ******** |
38 | 38 |
39 In brief, the native |ns3| TCP model supports a full bidirectional TCP with | 39 In brief, the native |ns3| TCP model supports a full bidirectional TCP with |
40 connection setup and close logic. Several congestion control algorithms | 40 connection setup and close logic. Several congestion control algorithms |
41 are supported, with NewReno the default, and Westwood, Hybla, HighSpeed, | 41 are supported, with NewReno the default, and Westwood, Hybla, HighSpeed, |
42 Vegas, Scalable, Veno, Binary Increase Congestion Control (BIC), Yet Another | 42 Vegas, Scalable, Veno, Binary Increase Congestion Control (BIC), Yet Another |
43 HighSpeed TCP (YeAH), Illinois, H-TCP and Low Extra Delay Background Transport | 43 HighSpeed TCP (YeAH), Illinois, H-TCP, Low Extra Delay Background Transport |
44 (LEDBAT) also supported. The model also supports Selective Acknowledgements | 44 (LEDBAT), Data Center TCP (DCTCP) also supported. The model also supports |
45 (SACK). Multipath-TCP is not yet supported in the |ns3| releases. | 45 Selective Acknowledgements (SACK). Multipath-TCP is not yet supported in the |
| 46 |ns3| releases. |
46 | 47 |
47 Model history | 48 Model history |
48 +++++++++++++ | 49 +++++++++++++ |
49 | 50 |
50 Until the ns-3.10 release, |ns3| contained a port of the TCP model from `GTNetS | 51 Until the ns-3.10 release, |ns3| contained a port of the TCP model from `GTNetS |
51 <http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/index.html>`_.· | 52 <http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/index.html>`_.· |
52 This implementation was substantially rewritten by Adriam Tam for ns-3.10. | 53 This implementation was substantially rewritten by Adriam Tam for ns-3.10. |
53 In 2015, the TCP module has been redesigned in order to create a better· | 54 In 2015, the TCP module has been redesigned in order to create a better· |
54 environment for creating and carrying out automated tests. One of the main· | 55 environment for creating and carrying out automated tests. One of the main· |
55 changes involves congestion control algorithms, and how they are implemented. | 56 changes involves congestion control algorithms, and how they are implemented. |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 | 727 |
727 In comparison to RFC 6817, the scope and limitations of the current LEDBAT | 728 In comparison to RFC 6817, the scope and limitations of the current LEDBAT |
728 implementation are: | 729 implementation are: |
729 | 730 |
730 * It assumes that the clocks on the sender side and receiver side are synchronis
ed | 731 * It assumes that the clocks on the sender side and receiver side are synchronis
ed |
731 * In line with Linux implementation, the one-way delay is calculated at the send
er side by using the timestamps option in TCP header | 732 * In line with Linux implementation, the one-way delay is calculated at the send
er side by using the timestamps option in TCP header |
732 * Only the MIN function is used for noise filtering· | 733 * Only the MIN function is used for noise filtering· |
733 | 734 |
734 More information about LEDBAT is available in RFC 6817: https://tools.ietf.org/h
tml/rfc6817 | 735 More information about LEDBAT is available in RFC 6817: https://tools.ietf.org/h
tml/rfc6817 |
735 | 736 |
| 737 Data Center TCP (DCTCP) |
| 738 ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 739 · |
| 740 DCTCP is an enhancement to the TCP congestion control algorithm for data center· |
| 741 networks and leverages Explicit Congestion Notification (ECN) to provide multi-b
it· |
| 742 feedback to the end hosts. DCTCP extends the Explicit Congestion Notification· |
| 743 to estimate the fraction of bytes that encounter congestion, rather than simply· |
| 744 detecting that the congestion has occurred. DCTCP then scales the congestion· |
| 745 window based on this estimate. This approach achieves high burst tolerance, low· |
| 746 latency, and high throughput with shallow-buffered switches.· |
| 747 · |
| 748 * Receiver functionality: If CE is set in IP header of incoming packet, send con
gestion notification to the sender by setting ECE in TCP header. |
| 749 |
| 750 * Sender functionality: It should maintain an average of fraction of packets mar
ked (α) by using the exponential weighted moving average as shown below: |
| 751 |
| 752 α = (1 - g) x α + g x F |
| 753 |
| 754 where· |
| 755 * g is the estimation gain (between 0 and 1)· |
| 756 * F is fraction of packets marked in current RTT. |
| 757 · |
| 758 On receipt of an ACK with ECE bit set, the sender should respond by reducing the
congestion |
| 759 window as follows, once for every window of data: |
| 760 |
| 761 cwnd = cwnd * (1 - α / 2) |
| 762 · |
| 763 Following the recommendation of IETF of DCTCP, the default values of the paramet
ers are: |
| 764 · |
| 765 * g = 0.0625 |
| 766 * alpha = 0 |
| 767 · |
| 768 To enable DCTCP on all TCP sockets, the following configuration can be used: |
| 769 · |
| 770 :: |
| 771 |
| 772 Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpDctcp::G
etTypeId ())); |
| 773 · |
| 774 To enable DCTCP on a chosen TCP socket, the following configuration can be used: |
| 775 · |
| 776 :: |
| 777 · |
| 778 Config::Set ("$ns3::NodeListPriv/NodeList/1/$ns3::TcpL4Protocol/SocketType", T
ypeIdValue (TcpDctcp::GetTypeId ())); |
| 779 · |
| 780 The following unit tests have been written to validate the implementation of DCT
CP: |
| 781 · |
| 782 * ECT flags should be set for SYN, SYN+ACK, ACK and data packets for DCTCP traff
ic |
| 783 * ECT flags should not be set for SYN, SYN+ACK and pure ACK packets, but should
be set on data packets for ECN enabled traditional TCP flows |
| 784 * ECE should be set only when CE flags are received at receiver and even if send
er doesn’t send CWR, receiver should not send ECE if it doesn’t receive packets
with CE flags |
| 785 * Test to validate cwnd increment in DCTCP |
| 786 * Test to validate cwnd decrement in DCTCP |
| 787 · |
| 788 Limitations of DCTCP implementation: DCTCP depends on a simple queue management |
| 789 algorithm in routers / switches to mark packets. The current implementation of |
| 790 DCTCP in ns-3 uses RED with a simple configuration to achieve the behavior of |
| 791 desired queue management algorithm. The same can also be achieved by using a |
| 792 PfifoFast, but it does not support ECN marking yet. |
| 793 · |
| 794 More information about DCTCP is available in the following Internet draft: |
| 795 https://tools.ietf.org/html/draft-ietf-tcpm-dctcp-07 |
| 796 |
| 797 |
| 798 Support for Explicit Congestion Notification (ECN) |
| 799 ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 800 |
| 801 ECN provides end-to-end notification of network congestion without dropping |
| 802 packets. It uses two bits in the IP header: ECN Capable Transport (ECT bit) |
| 803 and Congestion Experienced (CE bit), and two bits in the TCP header: Congestion |
| 804 Window Reduced (CWR) and ECN Echo (ECE).· |
| 805 |
| 806 More information is available in RFC 3168: https://tools.ietf.org/html/rfc3168 |
| 807 |
| 808 The following ECN states are declared in ``src/internet/model/tcp-socket.h`` |
| 809 |
| 810 :: |
| 811 |
| 812 typedef enum |
| 813 { |
| 814 ECN_DISABLED = 0, //!< ECN disabled traffic· |
| 815 ECN_IDLE, //!< ECN is enabled but currently there is no action per
taining to ECE or CWR to be taken· |
| 816 ECN_CE_RCVD, //!< This state indicates that the receiver has received
a packet with CE bit set in IP header· |
| 817 ECN_ECE_SENT, //!< This state indicates that the receiver has sent an
ACK with ECE bit set in TCP header |
| 818 ECN_ECE_RCVD, //!< This state indicates that the sender has received a
n ACK with ECE bit set in TCP header· |
| 819 ECN_CWR_SENT //!< This state indicates that the sender has reduced th
e congestion window, and sent a packet |
| 820 with CWR bit set in TCP header |
| 821 } EcnStates_t; |
| 822 |
| 823 The following are some important ECN parameters |
| 824 |
| 825 :: |
| 826 |
| 827 // ECN parameters |
| 828 bool m_ecn; //!< Socket ECN capability |
| 829 TracedValue<EcnStates_t> m_ecnState; //!< Current ECN State, represente
d as combination of EcnState values |
| 830 TracedValue<SequenceNumber32> m_ecnEchoSeq; //< Sequence number of the last re
ceived ECN Echo |
| 831 |
| 832 Enabling ECN |
| 833 ^^^^^^^^^^^^ |
| 834 |
| 835 By default, support for ECN is disabled in TCP sockets. To enable, change |
| 836 the value of the attribute ``ns3::TcpSocketBase::UseEcn`` from false to true. |
| 837 |
| 838 ECN negotiation |
| 839 ^^^^^^^^^^^^^^^ |
| 840 |
| 841 ECN capability is negotiated during the three-way TCP handshake: |
| 842 |
| 843 1. Sender sends SYN + CWR + ECE |
| 844 |
| 845 :: |
| 846 |
| 847 if (m_ecn) |
| 848 {· |
| 849 SendEmptyPacket (TcpHeader::SYN | TcpHeader::ECE | TcpHeader::CWR); |
| 850 } |
| 851 else |
| 852 { |
| 853 SendEmptyPacket (TcpHeader::SYN); |
| 854 } |
| 855 m_ecnState = ECN_DISABLED; |
| 856 |
| 857 2. Receiver sends SYN + ACK + ECE |
| 858 |
| 859 :: |
| 860 |
| 861 if (m_ecn && (tcpHeader.GetFlags () & (TcpHeader::CWR | TcpHeader::ECE)) ==
(TcpHeader::CWR | TcpHeader::ECE)) |
| 862 { |
| 863 SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK |TcpHeader::ECE); |
| 864 m_ecnState = ECN_IDLE; |
| 865 } |
| 866 else |
| 867 { |
| 868 SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK); |
| 869 m_ecnState = ECN_DISABLED; |
| 870 } |
| 871 |
| 872 3. Sender sends ACK |
| 873 |
| 874 :: |
| 875 |
| 876 if (m_ecn && (tcpHeader.GetFlags () & (TcpHeader::CWR | TcpHeader::ECE)) ==
(TcpHeader::ECE)) |
| 877 { |
| 878 m_ecnState = ECN_IDLE; |
| 879 } |
| 880 else |
| 881 { |
| 882 m_ecnState = ECN_DISABLED; |
| 883 } |
| 884 |
| 885 Once the ECN-negotiation is successful, the sender sends data packets with ECT |
| 886 bits set in the IP header. |
| 887 |
| 888 Note: As mentioned in Section 6.1.1 of RFC 3168, ECT bits should not be set |
| 889 during ECN negotiation. The ECN negotiation implemented in |ns3| follows· |
| 890 this guideline. |
| 891 |
| 892 ECN State Transitions |
| 893 ^^^^^^^^^^^^^^^^^^^^^ |
| 894 |
| 895 1. Initially both sender and receiver have their m_ecnState set as ECN_DISABLED |
| 896 2. Once the ECN negotiation is successful, their states are set to ECN_IDLE· |
| 897 3. Upon receipt of a packet with CE bits set in IP header, the |
| 898 receiver changes its state to ECN_CE_RCVD |
| 899 4. When the receiver sends an ACK with ECE bit set, its state is set as· |
| 900 ECN_ECE_SENT |
| 901 5. When the sender receives an ACK with ECE bit set from receiver, its state· |
| 902 is set as ECN_ECE_RCVD |
| 903 6. When the sender sends the packet with CWR bit set, its state is set as· |
| 904 ECN_CWR_SENT |
| 905 7. When the receiver receives the packet with CWR bit set, its state is set· |
| 906 as ECN_IDLE |
| 907 |
| 908 RFC 3168 compliance |
| 909 ^^^^^^^^^^^^^^^^^^^ |
| 910 |
| 911 Based on the suggestions provided in RFC 3168, the following behavior has |
| 912 been implemented: |
| 913 |
| 914 1. Pure ACK packets should not have the ECT bit set (Section 6.1.4). |
| 915 2. Retransmitted packets should not have the ECT bit set in order to prevent DoS |
| 916 attack (Section 6.1.5).· |
| 917 3. The sender should should reduce the congestion window only once in each· |
| 918 window (Section 6.1.2). |
| 919 4. The receiver should ignore the CE bits set in a packet arriving out of |
| 920 window (Section 6.1.5).· |
| 921 5. The sender should ignore the ECE bits set in the packet arriving out of |
| 922 window (Section 6.1.2). |
| 923 |
| 924 Open issues |
| 925 ^^^^^^^^^^^ |
| 926 |
| 927 The following issues are yet to be addressed: |
| 928 |
| 929 1. Retransmitted packets should not have the CWR bit set (Section 6.1.5). |
| 930 |
| 931 2. Despite the congestion window size being 1 MSS, the sender should reduce its |
| 932 congestion window by half when it receives a packet with the ECE bit set. The |
| 933 sender must reset the retransmit timer on receiving the ECN-Echo packet when |
| 934 the congestion window is one. The sending TCP will then be able to send a |
| 935 new packet only when the retransmit timer expires (Section 6.1.2). |
| 936 ·· |
| 937 3. Support for separately handling the enabling of ECN on the incoming and |
| 938 outgoing TCP sessions (e.g. a TCP may perform ECN echoing but not set the |
| 939 ECT codepoints on its outbound data segments). |
| 940 |
736 Validation | 941 Validation |
737 ++++++++++ | 942 ++++++++++ |
738 | 943 |
739 The following tests are found in the ``src/internet/test`` directory. In | 944 The following tests are found in the ``src/internet/test`` directory. In |
740 general, TCP tests inherit from a class called :cpp:class:`TcpGeneralTest`, | 945 general, TCP tests inherit from a class called :cpp:class:`TcpGeneralTest`, |
741 which provides common operations to set up test scenarios involving TCP | 946 which provides common operations to set up test scenarios involving TCP |
742 objects. For more information on how to write new tests, see the | 947 objects. For more information on how to write new tests, see the |
743 section below on :ref:`Writing-tcp-tests`. | 948 section below on :ref:`Writing-tcp-tests`. |
744 | 949 |
745 * **tcp:** Basic transmission of string of data from client to server | 950 * **tcp:** Basic transmission of string of data from client to server |
746 * **tcp-bytes-in-flight-test:** TCP correctly estimates bytes in flight under lo
ss conditions | 951 * **tcp-bytes-in-flight-test:** TCP correctly estimates bytes in flight under lo
ss conditions |
747 * **tcp-cong-avoid-test:** TCP congestion avoidance for different packet sizes | 952 * **tcp-cong-avoid-test:** TCP congestion avoidance for different packet sizes |
748 * **tcp-datasentcb:** Check TCP's 'data sent' callback | 953 * **tcp-datasentcb:** Check TCP's 'data sent' callback |
749 * **tcp-endpoint-bug2211-test:** A test for an issue that was causing stack over
flow | 954 * **tcp-endpoint-bug2211-test:** A test for an issue that was causing stack over
flow |
750 * **tcp-fast-retr-test:** Fast Retransmit testing | 955 * **tcp-fast-retr-test:** Fast Retransmit testing |
751 * **tcp-header:** Unit tests on the TCP header | 956 * **tcp-header:** Unit tests on the TCP header |
752 * **tcp-highspeed-test:** Unit tests on the Highspeed congestion control | 957 * **tcp-highspeed-test:** Unit tests on the Highspeed congestion control |
753 * **tcp-htcp-test:** Unit tests on the H-TCP congestion control | 958 * **tcp-htcp-test:** Unit tests on the H-TCP congestion control |
754 * **tcp-hybla-test:** Unit tests on the Hybla congestion control | 959 * **tcp-hybla-test:** Unit tests on the Hybla congestion control |
755 * **tcp-vegas-test:** Unit tests on the Vegas congestion control | 960 * **tcp-vegas-test:** Unit tests on the Vegas congestion control |
756 * **tcp-veno-test:** Unit tests on the Veno congestion control | 961 * **tcp-veno-test:** Unit tests on the Veno congestion control |
757 * **tcp-scalable-test:** Unit tests on the Scalable congestion control | 962 * **tcp-scalable-test:** Unit tests on the Scalable congestion control |
758 * **tcp-bic-test:** Unit tests on the BIC congestion control | 963 * **tcp-bic-test:** Unit tests on the BIC congestion control |
759 * **tcp-yeah-test:** Unit tests on the YeAH congestion control | 964 * **tcp-yeah-test:** Unit tests on the YeAH congestion control |
760 * **tcp-illinois-test:** Unit tests on the Illinois congestion control | 965 * **tcp-illinois-test:** Unit tests on the Illinois congestion control |
761 * **tcp-ledbat-test:** Unit tests on the LEDBAT congestion control | 966 * **tcp-ledbat-test:** Unit tests on the LEDBAT congestion control |
| 967 * **tcp-dctcp-test:** Unit tests on the DCTCP congestion control |
762 * **tcp-option:** Unit tests on TCP options | 968 * **tcp-option:** Unit tests on TCP options |
763 * **tcp-pkts-acked-test:** Unit test the number of time that PktsAcked is called | 969 * **tcp-pkts-acked-test:** Unit test the number of time that PktsAcked is called |
764 * **tcp-rto-test:** Unit test behavior after a RTO timeout occurs | 970 * **tcp-rto-test:** Unit test behavior after a RTO timeout occurs |
765 * **tcp-rtt-estimation-test:** Check RTT calculations, including retransmission
cases | 971 * **tcp-rtt-estimation-test:** Check RTT calculations, including retransmission
cases |
766 * **tcp-slow-start-test:** Check behavior of slow start | 972 * **tcp-slow-start-test:** Check behavior of slow start |
767 * **tcp-timestamp:** Unit test on the timestamp option | 973 * **tcp-timestamp:** Unit test on the timestamp option |
768 * **tcp-wscaling:** Unit test on the window scaling option | 974 * **tcp-wscaling:** Unit test on the window scaling option |
769 * **tcp-zero-window-test:** Unit test persist behavior for zero window condition
s | 975 * **tcp-zero-window-test:** Unit test persist behavior for zero window condition
s |
| 976 * **tcp-ecn-test:** Unit tests on explicit congestion notification |
770 | 977 |
771 Several tests have dependencies outside of the ``internet`` module, so they | 978 Several tests have dependencies outside of the ``internet`` module, so they |
772 are located in a system test directory called ``src/test/ns3tcp``. Three | 979 are located in a system test directory called ``src/test/ns3tcp``. Three |
773 of these six tests involve use of the Network Simulation Cradle, and are | 980 of these six tests involve use of the Network Simulation Cradle, and are |
774 disabled if NSC is not enabled in the build.·· | 981 disabled if NSC is not enabled in the build.·· |
775 | 982 |
776 * **ns3-tcp-cwnd:** Check to see that ns-3 TCP congestion control works against
liblinux2.6.26.so implementation | 983 * **ns3-tcp-cwnd:** Check to see that ns-3 TCP congestion control works against
liblinux2.6.26.so implementation |
777 * **ns3-tcp-interoperability:** Check to see that ns-3 TCP interoperates with li
blinux2.6.26.so implementation | 984 * **ns3-tcp-interoperability:** Check to see that ns-3 TCP interoperates with li
blinux2.6.26.so implementation |
778 * **ns3-tcp-loss:** Check behavior of ns-3 TCP upon packet losses | 985 * **ns3-tcp-loss:** Check behavior of ns-3 TCP upon packet losses |
779 * **nsc-tcp-loss:** Check behavior of NSC TCP upon packet losses | 986 * **nsc-tcp-loss:** Check behavior of NSC TCP upon packet losses |
780 * **ns3-tcp-no-delay:** Check that ns-3 TCP Nagle"s algorithm works correctly an
d that it can be disabled | 987 * **ns3-tcp-no-delay:** Check that ns-3 TCP Nagle"s algorithm works correctly an
d that it can be disabled |
781 * **ns3-tcp-socket:** Check that ns-3 TCP successfully transfers an application
data write of various sizes | 988 * **ns3-tcp-socket:** Check that ns-3 TCP successfully transfers an application
data write of various sizes |
782 * **ns3-tcp-state:** Check the operation of the TCP state machine for several ca
ses | 989 * **ns3-tcp-state:** Check the operation of the TCP state machine for several ca
ses |
783 · | 990 · |
784 Several TCP validation test results can also be found in the | 991 Several TCP validation test results can also be found in the |
785 `wiki page <http://www.nsnam.org/wiki/New_TCP_Socket_Architecture>`_· | 992 `wiki page <http://www.nsnam.org/wiki/New_TCP_Socket_Architecture>`_· |
786 describing this implementation. | 993 describing this implementation. |
787 | 994 |
| 995 TCP ECN operation is tested in the ARED and RED tests that are documented in the
traffic-control· |
| 996 module documentation. |
| 997 |
788 Writing a new congestion control algorithm | 998 Writing a new congestion control algorithm |
789 ++++++++++++++++++++++++++++++++++++++++++ | 999 ++++++++++++++++++++++++++++++++++++++++++ |
790 | 1000 |
791 Writing (or porting) a congestion control algorithms from scratch (or from | 1001 Writing (or porting) a congestion control algorithms from scratch (or from |
792 other systems) is a process completely separated from the internals of | 1002 other systems) is a process completely separated from the internals of |
793 TcpSocketBase. | 1003 TcpSocketBase. |
794 | 1004 |
795 All operations that are delegated to a congestion control are contained in | 1005 All operations that are delegated to a congestion control are contained in |
796 the class TcpCongestionOps. It mimics the structure tcp_congestion_ops of | 1006 the class TcpCongestionOps. It mimics the structure tcp_congestion_ops of |
797 Linux, and the following operations are defined: | 1007 Linux, and the following operations are defined: |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 Limitations | 1787 Limitations |
1578 +++++++++++ | 1788 +++++++++++ |
1579 | 1789 |
1580 * NSC only works on single-interface nodes; attempting to run it on a | 1790 * NSC only works on single-interface nodes; attempting to run it on a |
1581 multi-interface node will cause a program error.·· | 1791 multi-interface node will cause a program error.·· |
1582 * Cygwin and OS X PPC are not supported; OS X Intel is not supported but may wor
k | 1792 * Cygwin and OS X PPC are not supported; OS X Intel is not supported but may wor
k |
1583 * The non-Linux stacks of NSC are not supported in |ns3| | 1793 * The non-Linux stacks of NSC are not supported in |ns3| |
1584 * Not all socket API callbacks are supported | 1794 * Not all socket API callbacks are supported |
1585 | 1795 |
1586 For more information, see `this wiki page <http://www.nsnam.org/wiki/Network_Sim
ulation_Cradle_Integration>`_. | 1796 For more information, see `this wiki page <http://www.nsnam.org/wiki/Network_Sim
ulation_Cradle_Integration>`_. |
OLD | NEW |