├── CMakeLists.txt ├── README.md ├── README_mpquic.md ├── bindings ├── modulegen__gcc_ILP32.py └── modulegen__gcc_LP64.py ├── doc ├── .gitignore ├── Makefile ├── conf.py ├── index.rst ├── make.bat ├── mpquic.rst └── quic.rst ├── examples ├── CMakeLists.txt ├── quic-pacing.cc ├── quic-tester-streams.cc ├── quic-tester.cc ├── quic-variants-comparison-bulksend.cc ├── quic-variants-comparison.cc ├── wns3-mpquic-four-path.cc ├── wns3-mpquic-one-path.cc ├── wns3-mpquic-two-path-cwnd.cc ├── wns3-mpquic-two-path-flip.cc ├── wns3-mpquic-two-path.cc └── wscript ├── helper ├── quic-helper.cc └── quic-helper.h ├── model ├── mp-quic-congestion-ops.cc ├── mp-quic-congestion-ops.h ├── mp-quic-path-manager.cc ├── mp-quic-path-manager.h ├── mp-quic-scheduler.cc ├── mp-quic-scheduler.h ├── mp-quic-subflow.cc ├── mp-quic-subflow.h ├── quic-bbr.cc ├── quic-bbr.h ├── quic-congestion-ops.cc ├── quic-congestion-ops.h ├── quic-header.cc ├── quic-header.h ├── quic-l4-protocol.cc ├── quic-l4-protocol.h ├── quic-l5-protocol.cc ├── quic-l5-protocol.h ├── quic-socket-base.cc ├── quic-socket-base.h ├── quic-socket-factory.cc ├── quic-socket-factory.h ├── quic-socket-rx-buffer.cc ├── quic-socket-rx-buffer.h ├── quic-socket-tx-buffer.cc ├── quic-socket-tx-buffer.h ├── quic-socket-tx-edf-scheduler.cc ├── quic-socket-tx-edf-scheduler.h ├── quic-socket-tx-pfifo-scheduler.cc ├── quic-socket-tx-pfifo-scheduler.h ├── quic-socket-tx-scheduler.cc ├── quic-socket-tx-scheduler.h ├── quic-socket.cc ├── quic-socket.h ├── quic-stream-base.cc ├── quic-stream-base.h ├── quic-stream-rx-buffer.cc ├── quic-stream-rx-buffer.h ├── quic-stream-tx-buffer.cc ├── quic-stream-tx-buffer.h ├── quic-stream.cc ├── quic-stream.h ├── quic-subheader.cc ├── quic-subheader.h ├── quic-transport-parameters.cc ├── quic-transport-parameters.h └── windowed-filter.h ├── ns3.patch ├── quic-applications ├── helper │ ├── mpquic-bulk-send-helper.cc │ ├── mpquic-bulk-send-helper.h │ ├── quic-client-server-helper.cc │ ├── quic-client-server-helper.h │ ├── quic-echo-helper.cc │ └── quic-echo-helper.h └── model │ ├── mpquic-bulk-send-application.cc │ ├── mpquic-bulk-send-application.h │ ├── quic-client.cc │ ├── quic-client.h │ ├── quic-echo-client.cc │ ├── quic-echo-client.h │ ├── quic-echo-server.cc │ ├── quic-echo-server.h │ ├── quic-server.cc │ └── quic-server.h ├── test ├── quic-header-test.cc ├── quic-rx-buffer-test.cc └── quic-tx-buffer-test.cc └── wscript /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | build_lib( 2 | LIBNAME quic 3 | SOURCE_FILES 4 | model/quic-congestion-ops.cc 5 | model/quic-socket.cc 6 | model/quic-socket-base.cc 7 | model/quic-socket-factory.cc 8 | model/quic-l4-protocol.cc 9 | model/quic-socket-rx-buffer.cc 10 | model/quic-socket-tx-buffer.cc 11 | model/quic-socket-tx-scheduler.cc 12 | model/quic-socket-tx-pfifo-scheduler.cc 13 | model/quic-socket-tx-edf-scheduler.cc 14 | model/quic-stream.cc 15 | model/quic-stream-base.cc 16 | model/quic-l5-protocol.cc 17 | model/quic-stream-tx-buffer.cc 18 | model/quic-stream-rx-buffer.cc 19 | model/quic-header.cc 20 | model/quic-subheader.cc 21 | model/quic-transport-parameters.cc 22 | model/quic-bbr.cc 23 | model/mp-quic-subflow.cc 24 | model/mp-quic-scheduler.cc 25 | model/mp-quic-path-manager.cc 26 | model/mp-quic-congestion-ops.cc 27 | helper/quic-helper.cc 28 | HEADER_FILES 29 | model/quic-congestion-ops.h 30 | model/quic-socket.h 31 | model/quic-socket-base.h 32 | model/quic-socket-factory.h 33 | model/quic-l4-protocol.h 34 | model/quic-socket-rx-buffer.h 35 | model/quic-socket-tx-buffer.h 36 | model/quic-socket-tx-scheduler.h 37 | model/quic-socket-tx-pfifo-scheduler.h 38 | model/quic-socket-tx-edf-scheduler.h 39 | model/quic-stream.h 40 | model/quic-stream-base.h 41 | model/quic-l5-protocol.h 42 | model/quic-stream-tx-buffer.h 43 | model/quic-stream-rx-buffer.h 44 | model/quic-header.h 45 | model/quic-subheader.h 46 | model/quic-transport-parameters.h 47 | model/quic-bbr.h 48 | helper/quic-helper.h 49 | model/mp-quic-subflow.h 50 | model/mp-quic-scheduler.h 51 | model/mp-quic-path-manager.h 52 | model/mp-quic-congestion-ops.h 53 | model/windowed-filter.h 54 | LIBRARIES_TO_LINK 55 | ${libinternet} 56 | ${libapplications} 57 | ${libflow-monitor} 58 | ${libpoint-to-point} 59 | TEST_SOURCES 60 | test/quic-rx-buffer-test.cc 61 | test/quic-tx-buffer-test.cc 62 | test/quic-header-test.cc 63 | ) 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Align with the MPQUIC IETF Draft 3 | ================================ 4 | 5 | `mpquic-1.2` implements most of the basic features mentioned in [IETF draft](https://datatracker.ietf.org/doc/draft-ietf-quic-multipath/04/) (March 2023). 6 | 7 | ![alt text](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/results-wns3/mpquic_uml_diagram.png) 8 | 9 | 10 | ## Features ## 11 | 12 | 1. [Handshake Negotiation and Transport Parameter](#handshake-negotiation-and-transport-parameter) [Sec. 3 in IETF draft] 13 | 2. [Path Setup and Removal](#path-setup-and-removal) [Sec. 4 in IETF draft] 14 | 3. [Multipath Operation with Multiple Packet Number Spaces](#multipath-operation-with-multiple-packet-numer-spaces) [Sec. 5 in IETF draft] 15 | 4. [Implementation Considerations](#implementation-consiterations) [Sec. 7 in IETF draft] 16 | 5. [New Frames](#new-frames) [Sec. 8 in IETF draft] 17 | 18 | Note: For features that implemented in our current version, we illustrate the variables, functions or classes in the specific file. (x) represents that part of the features are not supported in the current version. 19 | 20 | ### Handshake Negotiation and Transport Parameter ### 21 | 1. New transport parameter enable_multipath => `m_enableMultipath` in quic-sochet-base.h 22 | 23 | ### Path Setup and Removal ### 24 | 1. Path Initiation => `MpQuicPathManager::InitialSubflow0` in mp-quic-path-manager.h 25 | 2. Path State Management => PATH_STATUS frame (x) 26 | 3. Path Close => `QuicSocketBase::SendConnectionClosePacket` in quic-sochet-base.h 27 | 4. Pate States => `SubflowStates_t` in mp-quic-subflow.h; `QuicSocketBase::SendPathChallenge` and `QuicSocketBase::SendPathResponse` in quic-sochet-base.h 28 | 29 | ### Multipath Operation with Multiple Packet Number Spaces ### 30 | 1. Sending Acknowledgements => `QuicSocketBase::SendAck` and `QuicSocketBase::OnReceivedAckFrame` in quic-sochet-base.h 31 | 2. Packet Protection => TLS and AEAD (x) 32 | 33 | ### Implementation Considerations ### 34 | 1. Number Spaces => `m_receivedPacketNumbers` in mp-quic-subflow.h 35 | 2. Congestion Control => mp-quic-congestion-ops.h 36 | 3. Computing Path RTT => `m_tcb->m_lastRtt` in mp-quic-subflow.h 37 | 4. Packet Scheduling => mp-quic-scheduler.h 38 | 5. Retransmissions => `QuicSocketBase::DoRetransmit` in quic-sochet-base.h 39 | 6. Handling different PMTU sizes => (x) 40 | 7. Keep Alive => (x) 41 | 8. Connection ID Changes and NAT Rebindings => (x) 42 | 43 | ### New Frames ### 44 | 1. ACK_MP Frame => `MP_ACK` in quic-subheader.h 45 | 2. PATH_ABANDON Frame => `PATH_ABANDON` in quic-subheader.h 46 | 3. PATH_CHALLENGE => `PATH_CHALLENGE` in quic-subheader.h 47 | 4. PATH_RESPONSE => `PATH_RESPONSE` in quic-subheader.h 48 | 5. PATH_STATUS Frame => (x) 49 | 50 | 51 | ### Modified Files #### 52 | New File Created: 53 | 1. [mp-quic-congestion-ops.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/mp-quic-congestion-ops.cc) 54 | 1. [mp-quic-congestion-ops.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/mp-quic-congestion-ops.h) 55 | 2. [mp-quic-path-manager.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/mp-quic-path-manager.cc) 56 | 2. [mp-quic-path-manager.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/mp-quic-path-manager.h) 57 | 3. [mp-quic-scheduler.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/mp-quic-scheduler.cc) 58 | 3. [mp-quic-scheduler.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/mp-quic-scheduler.h) 59 | 4. [mp-quic-subflow.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/mp-quic-subflow.cc) 60 | 4. [mp-quic-subflow.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/mp-quic-subflow.h) 61 | 1. [mpquic-bulk-send-application.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/applications/model/mpquic-bulk-send-application.cc) 62 | 1. [mpquic-bulk-send-application.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/applications/model/mpquic-bulk-send-application.cc) 63 | 64 | Quic File Modified: 65 | 1. [quic-l4-protocol.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-l4-protocol.cc) 66 | 1. [quic-l4-protocol.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-l4-protocol.h) 67 | 1. [quic-socket-base.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-socket-base.cc) 68 | 1. [quic-socket-base.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-socket-base.h) 69 | 1. [quic-socket-tx-buffer.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-socket-tx-buffer.cc) 70 | 1. [quic-socket-tx-buffer.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-socket-tx-buffer.h) 71 | 1. [quic-stream-base.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-stream-base.cc) 72 | 1. [quic-stream-base.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-stream-base.h) 73 | 1. [quic-l5-protocol.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-l5-protocol.cc) 74 | 4. [quic-subheader.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-subheader.cc) 75 | 4. [quic-subheader.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-subheader.h) 76 | 3. [quic-header.cc](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-header.cc) 77 | 3. [quic-header.h](https://github.com/ssjShirley/mpquic-ns3/blob/mpquic-1.2/src/quic/model/quic-header.h) 78 | 79 | 80 | -------------------------------------------------------------------------------- /README_mpquic.md: -------------------------------------------------------------------------------- 1 | To integrate mpquic module in ns-3, 2 | 3 | ``` 4 | cd src 5 | git clone https://github.com/ssjShirley/ns3-mpquic-module.git quic 6 | cp -r quic/quic-applications/helper/. applications/helper/. 7 | cp -r quic/quic-applications/model/. applications/model/. 8 | cp -r quic/examples ../examples/quic 9 | ``` 10 | 11 | ## `CMake` 12 | After `ns-3.36`, `ns-3` adopted `cmake` as the new build system. 13 | 14 | ``` 15 | git apply < quic/ns3.patch 16 | ``` 17 | 18 | To enable Python bindings, additionally install `cppyy` and add `--enable-python-bindings` to the `./ns3 configure` command line. 19 | 20 | ``` 21 | ./ns3 configure --enable-examples --enable-python-bindings -- -DNS3_BINDINGS_INSTALL_DIR="$HOME/.local/lib/python3.10/site-packages" 22 | ``` 23 | 24 | Otherwise, configure `ns3` without Python bindings 25 | 26 | ``` 27 | ./ns3 configure --enable-examples 28 | ``` 29 | 30 | Build and install 31 | 32 | ``` 33 | ./ns3 build -j$(nproc) 34 | ./ns3 install 35 | sudo ldconfig 36 | ``` 37 | 38 | Run mpquic examples 39 | 40 | ``` 41 | ./ns3 run wns3-mpquic-two-path 42 | ``` 43 | 44 | ## `Waf` 45 | 46 | In src/applications/wscript, add the following to module.source 47 | ``` 48 | 'model/mpquic-bulk-send-application.cc', 49 | 'model/quic-client.cc', 50 | 'model/quic-server.cc', 51 | 'model/quic-echo-client.cc', 52 | 'model/quic-echo-server.cc', 53 | 'helper/mpquic-bulk-send-helper.cc', 54 | 'helper/quic-client-server-helper.cc', 55 | 'helper/quic-echo-helper.cc', 56 | ``` 57 | 58 | add the following to headers.source 59 | ``` 60 | 'model/mpquic-bulk-send-application.h', 61 | 'model/quic-client.h', 62 | 'model/quic-server.h', 63 | 'model/quic-echo-client.h', 64 | 'model/quic-echo-server.h', 65 | 'helper/mpquic-bulk-send-helper.h', 66 | 'helper/quic-client-server-helper.h', 67 | 'helper/quic-echo-helper.h', 68 | ``` 69 | 70 | Configure the mpquic module 71 | ``` 72 | ./waf configure --enable-example 73 | ./waf 74 | ``` 75 | 76 | Run examples 77 | ``` 78 | ./waf --run wns3-mpquic-two-path 79 | ``` 80 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | _build/* 2 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /doc/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | # import os 14 | # import sys 15 | # sys.path.insert(0, os.path.abspath('.')) 16 | 17 | 18 | # -- Project information ----------------------------------------------------- 19 | 20 | project = 'mpquic' 21 | copyright = '2023, Shengjie Shu' 22 | author = 'Shengjie Shu' 23 | 24 | # The full version, including alpha/beta/rc tags 25 | release = '1.2' 26 | 27 | 28 | # -- General configuration --------------------------------------------------- 29 | 30 | # Add any Sphinx extension module names here, as strings. They can be 31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 32 | # ones. 33 | extensions = [ 34 | ] 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ['_templates'] 38 | 39 | # List of patterns, relative to source directory, that match files and 40 | # directories to ignore when looking for source files. 41 | # This pattern also affects html_static_path and html_extra_path. 42 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 43 | 44 | 45 | # -- Options for HTML output ------------------------------------------------- 46 | 47 | # The theme to use for HTML and HTML Help pages. See the documentation for 48 | # a list of builtin themes. 49 | # 50 | html_theme = 'alabaster' 51 | 52 | # Add any paths that contain custom static files (such as style sheets) here, 53 | # relative to this directory. They are copied after the builtin static files, 54 | # so a file named "default.css" will overwrite the builtin "default.css". 55 | html_static_path = ['_static'] -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | .. mpquic documentation master file, created by 2 | sphinx-quickstart on Tue Apr 18 22:17:44 2023. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to mpquic's documentation! 7 | ================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | 12 | quic.rst 13 | 14 | 15 | Indices and tables 16 | ================== 17 | 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.https://www.sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /doc/mpquic.rst: -------------------------------------------------------------------------------- 1 | Multipath QUIC Module Documentation 2 | ---------------------------- 3 | 4 | .. include:: replace.txt 5 | .. highlight:: cpp 6 | 7 | .. heading hierarchy: 8 | ------------- Chapter 9 | ************* Section (#.#) 10 | ============= Subsection (#.#.#) 11 | ############# Paragraph (no number) 12 | 13 | This is an outline for the modified module ``src/quic``. Specifically, this 14 | document discribes the added feature of multipath functions over the original 15 | quic module in |ns3|. 16 | 17 | The introductory paragraph is for describing what this code is trying to 18 | model. 19 | 20 | Model Description 21 | ***************** 22 | 23 | The source code for the modified module lives in the directory ``src/quic``. 24 | 25 | Add here a basic description of what is being modified. 26 | 27 | Design 28 | ====== 29 | 30 | The existing quic module has the basic functions to supporting single path transmission between client and server, which includes the basic transmission features, like quic headers and frames, establishment with handshake, reliability with acknowledgment, flow control and different congestion control algorithms. Based on these valuable functions, we aim to implement the multipath features, including the multiple path establishment, path management, realiable transmission with multipath acknowledgment, path scheduler, and congestion control algorithm. 31 | 32 | To realize this goal, we need to add new headers and frames that work for multipath, modify the original data flow and make it run over the path management layer, solve the reordering issue for different paths, and implement scheduling and congestion control algorithms that fit in the multipath scenarios. 33 | 34 | 35 | Scope and Limitations 36 | ===================== 37 | 38 | This module is currently able to support multiple paths connection between client and server. As a transport layer protocol, it is able to utilized bulk-send and other |ns3| supported applications. It is also able to build upon different topologies as long as the quic stack is installed on the sender and recever side. 39 | 40 | It likes the other transport layer protocols in |ns3|, supporting most of the transmission and multipath features, including handshake negotiation and transport parameters , path setup and removal, multipath operation with multiple packet number spaces, path scheduling, and congestion control. 41 | 42 | Since the IETF MPQUIC is still under discussion, our current version 1.2 tries to align the latest IETF draft (2023.03). Here are some minor different features that we will consider for our future work. IETF introduces a ``PATH_STATUS`` frame that informs the peer to send packets in the preference. Our implementation is able to have the path status locally, however, we do not support transmitting the path status between peers currently. In the path close stage, IETF includes a ``RETIRE_CONNECTION_ID`` frame to indicate to the receiving peer that the sender will not send any packets associated with the Connection ID used on that path anymore, which is not included in our current version. On the other hand, our implementation of MPQUIC currently only supports transmitting ``MP_ACK`` with the path given by the coming packets. An ``MP_ACK`` frame that can be returned via a different path is considered as our future work. Additionally, IETF indicates the packet protection with TLS and AEAD for connection ID, while the security features are not considered in our current stage. We will continue to improve our implementation to align with the latest IETF Draft. 43 | 44 | 45 | References [Will update later] 46 | ========== 47 | 48 | Add academic citations here, such as if you published a paper on this 49 | model, or if readers should read a particular specification or other work. 50 | 51 | Usage 52 | ***** 53 | 54 | Helpers 55 | ======= 56 | 57 | quic_helper is used to install the internet stack on the end-host. This should be utilized when you want to run a mpquic connection between end-hosts. 58 | 59 | Attributes 60 | ========== 61 | 62 | Here introduces some of the usable attributes. For the full attributes list, please check each .cc file. 63 | 64 | 1. QuicSocketBase::EnableMultipath enables the multipath features only when it is true. 65 | 2. QuicSocketBase::CcType supports different congestion control algorithms. 66 | 3. MpQuicScheduler::SchedulerType supports different scheduling algorithms. 67 | 68 | 69 | Output 70 | ====== 71 | It is able to trace the received bytes for each node, the receiver buffer size, the congestion window, and the transmission complete time. 72 | 73 | Examples 74 | ======== 75 | The sample scripts are located in scratch/ 76 | 77 | Take ``wns3-mpquic-two-path.cc`` as an example. line 18-26 shows the network topology. ThroughputModitor in line 52 traces the total received bytes of the node and the simulation time. 78 | 79 | ModifyLinkRate in line 66 is used to set the point-to-point bandwidth and delay along the time of the simulation. It is used in line 315 and 316. 80 | 81 | line 98-115 are used for set different experiment scenarios from cmd. ``exp-wns3-two-path-scheduler.sh`` shows how to set them. 82 | 83 | line 177-277 are used to create the network topology. 84 | 85 | We use the MpquicBulkSendHelper to bind the application to the sender side in line 285 and use PacketSinkHelper to set the receiver side. 86 | 87 | Troubleshooting 88 | =============== 89 | 90 | To report a bug, please open a GitHub Issue. 91 | -------------------------------------------------------------------------------- /doc/quic.rst: -------------------------------------------------------------------------------- 1 | Example Module Documentation 2 | ---------------------------- 3 | 4 | .. include:: replace.txt 5 | .. highlight:: cpp 6 | 7 | .. heading hierarchy: 8 | ------------- Chapter 9 | ************* Section (#.#) 10 | ============= Subsection (#.#.#) 11 | ############# Paragraph (no number) 12 | 13 | This is a suggested outline for adding new module documentation to |ns3|. 14 | See ``src/click/doc/click.rst`` for an example. 15 | 16 | The introductory paragraph is for describing what this code is trying to 17 | model. 18 | 19 | For consistency (italicized formatting), please use |ns3| to refer to 20 | ns-3 in the documentation (and likewise, |ns2| for ns-2). These macros 21 | are defined in the file ``replace.txt``. 22 | 23 | Model Description 24 | ***************** 25 | 26 | The source code for the new module lives in the directory ``src/quic``. 27 | 28 | Add here a basic description of what is being modeled. 29 | 30 | Design 31 | ====== 32 | 33 | Briefly describe the software design of the model and how it fits into 34 | the existing ns-3 architecture. 35 | 36 | Scope and Limitations 37 | ===================== 38 | 39 | What can the model do? What can it not do? Please use this section to 40 | describe the scope and limitations of the model. 41 | 42 | References 43 | ========== 44 | 45 | Add academic citations here, such as if you published a paper on this 46 | model, or if readers should read a particular specification or other work. 47 | 48 | Usage 49 | ***** 50 | 51 | This section is principally concerned with the usage of your model, using 52 | the public API. Focus first on most common usage patterns, then go 53 | into more advanced topics. 54 | 55 | Building New Module 56 | =================== 57 | 58 | Include this subsection only if there are special build instructions or 59 | platform limitations. 60 | 61 | Helpers 62 | ======= 63 | 64 | What helper API will users typically use? Describe it here. 65 | 66 | Attributes 67 | ========== 68 | 69 | What classes hold attributes, and what are the key ones worth mentioning? 70 | 71 | Output 72 | ====== 73 | 74 | What kind of data does the model generate? What are the key trace 75 | sources? What kind of logging output can be enabled? 76 | 77 | Advanced Usage 78 | ============== 79 | 80 | Go into further details (such as using the API outside of the helpers) 81 | in additional sections, as needed. 82 | 83 | Examples 84 | ======== 85 | 86 | What examples using this new code are available? Describe them here. 87 | 88 | Troubleshooting 89 | =============== 90 | 91 | Add any tips for avoiding pitfalls, etc. 92 | 93 | Validation 94 | ********** 95 | 96 | Describe how the model has been tested/validated. What tests run in the 97 | test suite? How much API and code is covered by the tests? Again, 98 | references to outside published work may help here. 99 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | build_example( 2 | NAME wns3-mpquic-two-path 3 | SOURCE_FILES wns3-mpquic-two-path.cc 4 | LIBRARIES_TO_LINK 5 | ${libquic} 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /examples/quic-pacing.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation; 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | // Network topology 18 | // 19 | // n0 ----------- n1 20 | // 40 Gbps 21 | // 0.01 ms 22 | 23 | // This programs illustrates how QUIC pacing can be used and how user can set 24 | // pacing rate. The program gives information about each flow like transmitted 25 | // and received bytes (packets) and throughput of that flow. Currently, it is 26 | // using QUIC NewReno-like but in future after having congestion control algorithms 27 | // which can change pacing rate can be used. 28 | 29 | #include 30 | #include 31 | #include "ns3/core-module.h" 32 | #include "ns3/point-to-point-module.h" 33 | #include "ns3/internet-module.h" 34 | #include "ns3/quic-module.h" 35 | #include "ns3/applications-module.h" 36 | #include "ns3/network-module.h" 37 | #include "ns3/packet-sink.h" 38 | #include "ns3/flow-monitor-module.h" 39 | 40 | using namespace ns3; 41 | 42 | NS_LOG_COMPONENT_DEFINE ("QuicPacingExample"); 43 | 44 | int 45 | main (int argc, char *argv[]) 46 | { 47 | 48 | bool tracing = false; 49 | uint32_t maxBytes = 0; 50 | uint32_t QUICFlows = 1; 51 | bool isPacingEnabled = true; 52 | std::string pacingRate = "4Gbps"; 53 | uint32_t maxPackets = 0; 54 | 55 | CommandLine cmd; 56 | cmd.AddValue ("tracing", "Flag to enable/disable tracing", tracing); 57 | cmd.AddValue ("maxBytes", 58 | "Total number of bytes for application to send", maxBytes); 59 | cmd.AddValue ("maxPackets", 60 | "Total number of bytes for application to send", maxPackets); 61 | cmd.AddValue ("QUICFlows", "Number of application flows between sender and receiver", QUICFlows); 62 | cmd.AddValue ("Pacing", "Flag to enable/disable pacing in QUIC", isPacingEnabled); 63 | cmd.AddValue ("PacingRate", "Max Pacing Rate in bps", pacingRate); 64 | cmd.Parse (argc, argv); 65 | 66 | if (maxPackets != 0 ) 67 | { 68 | maxBytes = 500 * maxPackets; 69 | } 70 | 71 | Config::SetDefault ("ns3::TcpSocketState::MaxPacingRate", StringValue (pacingRate)); 72 | Config::SetDefault ("ns3::TcpSocketState::EnablePacing", BooleanValue (isPacingEnabled)); 73 | 74 | NS_LOG_INFO ("Create nodes."); 75 | NodeContainer nodes; 76 | nodes.Create (2); 77 | 78 | NS_LOG_INFO ("Create channels."); 79 | PointToPointHelper pointToPoint; 80 | pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("40Gbps")); 81 | pointToPoint.SetChannelAttribute ("Delay", StringValue ("0.01ms")); 82 | 83 | NetDeviceContainer devices; 84 | devices = pointToPoint.Install (nodes); 85 | 86 | QuicHelper stack; 87 | stack.InstallQuic (nodes); 88 | 89 | NS_LOG_INFO ("Assign IP Addresses."); 90 | Ipv4AddressHelper ipv4; 91 | ipv4.SetBase ("10.1.1.0", "255.255.255.0"); 92 | Ipv4InterfaceContainer i = ipv4.Assign (devices); 93 | 94 | NS_LOG_INFO ("Create Applications."); 95 | 96 | ApplicationContainer sourceApps; 97 | ApplicationContainer sinkApps; 98 | for (uint32_t iterator = 0; iterator < QUICFlows; iterator++) 99 | { 100 | uint16_t port = 10000 + iterator; 101 | 102 | BulkSendHelper source ("ns3::QuicSocketFactory", 103 | InetSocketAddress (i.GetAddress (1), port)); 104 | // Set the amount of data to send in bytes. Zero is unlimited. 105 | source.SetAttribute ("MaxBytes", UintegerValue (maxBytes)); 106 | sourceApps.Add (source.Install (nodes.Get (0))); 107 | 108 | PacketSinkHelper sink ("ns3::QuicSocketFactory", 109 | InetSocketAddress (Ipv4Address::GetAny (), port)); 110 | sinkApps.Add (sink.Install (nodes.Get (1))); 111 | } 112 | 113 | sinkApps.Start (Seconds (0.0)); 114 | sinkApps.Stop (Seconds (5)); 115 | sourceApps.Start (Seconds (1)); 116 | sourceApps.Stop (Seconds (5)); 117 | 118 | if (tracing) 119 | { 120 | AsciiTraceHelper ascii; 121 | pointToPoint.EnableAsciiAll (ascii.CreateFileStream ("quic-pacing.tr")); 122 | pointToPoint.EnablePcapAll ("quic-pacing", false); 123 | } 124 | 125 | FlowMonitorHelper flowmon; 126 | Ptr monitor = flowmon.InstallAll (); 127 | 128 | NS_LOG_INFO ("Run Simulation."); 129 | Simulator::Stop (Seconds (5)); 130 | Simulator::Run (); 131 | 132 | monitor->CheckForLostPackets (); 133 | Ptr classifier = DynamicCast (flowmon.GetClassifier ()); 134 | FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats (); 135 | for (std::map::const_iterator i = stats.begin (); i != stats.end (); ++i) 136 | { 137 | Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (i->first); 138 | if (t.sourceAddress == "10.1.1.2") 139 | { 140 | continue; 141 | } 142 | std::cout << "Flow " << i->first << " (" << t.sourceAddress << " -> " << t.destinationAddress << ")\n"; 143 | std::cout << " Tx Packets: " << i->second.txPackets << "\n"; 144 | std::cout << " Tx Bytes: " << i->second.txBytes << "\n"; 145 | std::cout << " TxOffered: " << i->second.txBytes * 8.0 / 9.0 / 1000 / 1000 << " Mbps\n"; 146 | std::cout << " Rx Packets: " << i->second.rxPackets << "\n"; 147 | std::cout << " Rx Bytes: " << i->second.rxBytes << "\n"; 148 | std::cout << " Throughput: " << i->second.rxBytes * 8.0 / 9.0 / 1000 / 1000 << " Mbps\n"; 149 | } 150 | 151 | Simulator::Destroy (); 152 | NS_LOG_INFO ("Done."); 153 | } 154 | -------------------------------------------------------------------------------- /examples/quic-tester.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2019 SIGNET Lab, Department of Information Engineering, University of Padova 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation; 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Authors: Alvise De Biasio 19 | * Federico Chiariotti 20 | * Michele Polese 21 | * Davide Marcato 22 | * 23 | */ 24 | 25 | #include "ns3/core-module.h" 26 | #include "ns3/network-module.h" 27 | #include "ns3/internet-module.h" 28 | #include "ns3/quic-module.h" 29 | #include "ns3/point-to-point-module.h" 30 | #include "ns3/applications-module.h" 31 | #include "ns3/config-store-module.h" 32 | #include 33 | 34 | using namespace ns3; 35 | 36 | NS_LOG_COMPONENT_DEFINE("quic-tester"); 37 | 38 | int 39 | main (int argc, char *argv[]) 40 | { 41 | CommandLine cmd; 42 | cmd.Parse (argc, argv); 43 | 44 | std::cout 45 | << "\n\n#################### SIMULATION SET-UP ####################\n\n\n"; 46 | 47 | LogLevel log_precision = LOG_LEVEL_LOGIC; 48 | Time::SetResolution (Time::NS); 49 | LogComponentEnableAll (LOG_PREFIX_TIME); 50 | LogComponentEnableAll (LOG_PREFIX_FUNC); 51 | LogComponentEnableAll (LOG_PREFIX_NODE); 52 | LogComponentEnable ("QuicEchoClientApplication", log_precision); 53 | LogComponentEnable ("QuicEchoServerApplication", log_precision); 54 | // LogComponentEnable ("QuicHeader", log_precision); 55 | //LogComponentEnable ("QuicSocketBase", log_precision); 56 | // LogComponentEnable ("QuicStreamBase", LOG_LEVEL_LOGIC); 57 | // LogComponentEnable ("Socket", log_precision); 58 | // LogComponentEnable ("Application", log_precision); 59 | // LogComponentEnable ("Node", log_precision); 60 | // LogComponentEnable ("InternetStackHelper", log_precision); 61 | // LogComponentEnable ("QuicSocketFactory", log_precision); 62 | // LogComponentEnable ("ObjectFactory", log_precision); 63 | // //LogComponentEnable ("TypeId", log_precision); 64 | // LogComponentEnable ("QuicL4Protocol", log_precision); 65 | // LogComponentEnable ("QuicL5Protocol", log_precision); 66 | // //LogComponentEnable ("ObjectBase", log_precision); 67 | // 68 | // LogComponentEnable ("QuicEchoHelper", log_precision); 69 | LogComponentEnable ("QuicSocketTxScheduler", log_precision); 70 | // LogComponentEnable ("QuicSocketRxBuffer", log_precision); 71 | // LogComponentEnable ("QuicHeader", log_precision); 72 | // LogComponentEnable ("QuicSubheader", log_precision); 73 | // LogComponentEnable ("Header", log_precision); 74 | // LogComponentEnable ("PacketMetadata", log_precision); 75 | 76 | 77 | NodeContainer nodes; 78 | nodes.Create (2); 79 | auto n1 = nodes.Get (0); 80 | auto n2 = nodes.Get (1); 81 | 82 | PointToPointHelper pointToPoint; 83 | pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); 84 | pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); 85 | 86 | NetDeviceContainer devices; 87 | devices = pointToPoint.Install (nodes); 88 | 89 | QuicHelper stack; 90 | stack.InstallQuic (nodes); 91 | 92 | Ipv4AddressHelper address; 93 | address.SetBase ("10.1.1.0", "255.255.255.0"); 94 | 95 | Ipv4InterfaceContainer interfaces = address.Assign (devices); 96 | 97 | QuicEchoServerHelper echoServer (9); 98 | 99 | ApplicationContainer serverApps = echoServer.Install (nodes.Get (1)); 100 | serverApps.Start (Seconds (1.0)); 101 | serverApps.Stop (Seconds (1200.0)); 102 | 103 | QuicEchoClientHelper echoClient (interfaces.GetAddress (1), 9); 104 | echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); 105 | echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0))); 106 | //echoClient.SetAttribute ("MaxStreamData", UintegerValue (1024)); 107 | 108 | ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); 109 | echoClient.SetFill (clientApps.Get (0), "Hello World"); 110 | clientApps.Start (Seconds (2.0)); 111 | clientApps.Stop (Seconds (5.0)); 112 | 113 | Packet::EnablePrinting (); 114 | Packet::EnableChecking (); 115 | 116 | std::cout << "\n\n#################### STARTING RUN ####################\n\n"; 117 | Simulator::Run (); 118 | std::cout 119 | << "\n\n#################### RUN FINISHED ####################\n\n\n"; 120 | Simulator::Destroy (); 121 | 122 | std::cout 123 | << "\n\n#################### SIMULATION END ####################\n\n\n"; 124 | return 0; 125 | } 126 | -------------------------------------------------------------------------------- /examples/wscript: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | def build(bld): 4 | obj = bld.create_ns3_program('quic-tester-streams', ['quic']) 5 | obj.source = 'quic-tester-streams.cc' 6 | obj = bld.create_ns3_program('quic-tester', ['quic']) 7 | obj.source = 'quic-tester.cc' 8 | obj = bld.create_ns3_program('quic-variants-comparison', ['quic']) 9 | obj.source = 'quic-variants-comparison.cc' 10 | obj = bld.create_ns3_program('quic-variants-comparison-bulksend', ['quic']) 11 | obj.source = 'quic-variants-comparison-bulksend.cc' 12 | obj = bld.create_ns3_program('wns3-mpquic-one-path', ['quic']) 13 | obj.source = 'wns3-mpquic-one-path.cc' 14 | obj = bld.create_ns3_program('wns3-mpquic-two-path', ['quic']) 15 | obj.source = 'wns3-mpquic-two-path.cc' 16 | obj = bld.create_ns3_program('wns3-mpquic-four-path', ['quic']) 17 | obj.source = 'wns3-mpquic-four-path.cc' 18 | obj = bld.create_ns3_program('wns3-mpquic-two-path-cwnd', ['quic']) 19 | obj.source = 'wns3-mpquic-two-path-cwnd.cc' 20 | obj = bld.create_ns3_program('wns3-mpquic-two-path-flip', ['quic']) 21 | obj.source = 'wns3-mpquic-two-path-flip.cc' 22 | 23 | -------------------------------------------------------------------------------- /helper/quic-helper.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2008 INRIA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation; 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Author: Mathieu Lacage 19 | * Author: Faker Moatamri 20 | */ 21 | 22 | #include "ns3/assert.h" 23 | #include "ns3/log.h" 24 | #include "ns3/object.h" 25 | #include "ns3/names.h" 26 | #include "ns3/ipv4.h" 27 | #include "ns3/ipv6.h" 28 | #include "ns3/packet-socket-factory.h" 29 | #include "ns3/config.h" 30 | #include "ns3/simulator.h" 31 | #include "ns3/string.h" 32 | #include "ns3/net-device.h" 33 | #include "ns3/callback.h" 34 | #include "ns3/node.h" 35 | #include "ns3/node-list.h" 36 | #include "ns3/core-config.h" 37 | #include "ns3/arp-l3-protocol.h" 38 | #include "ns3/internet-stack-helper.h" 39 | #include "quic-helper.h" 40 | #include "ns3/ipv4-global-routing.h" 41 | #include "ns3/ipv4-list-routing-helper.h" 42 | #include "ns3/ipv4-static-routing-helper.h" 43 | #include "ns3/ipv4-global-routing-helper.h" 44 | #include "ns3/ipv6-static-routing-helper.h" 45 | #include "ns3/ipv6-extension.h" 46 | #include "ns3/ipv6-extension-demux.h" 47 | #include "ns3/ipv6-extension-header.h" 48 | #include "ns3/icmpv6-l4-protocol.h" 49 | #include "ns3/global-router-interface.h" 50 | #include "ns3/traffic-control-layer.h" 51 | #include "ns3/quic-socket-factory.h" 52 | 53 | namespace ns3 { 54 | 55 | NS_LOG_COMPONENT_DEFINE ("QuicHelper"); 56 | 57 | // 58 | // Historically, the only context written to ascii traces was the protocol. 59 | // Traces from the protocols include the interface, though. It is not 60 | // possible to really determine where an event originated without including 61 | // this. If you want the additional context information, define 62 | // INTERFACE_CONTEXT. If you want compatibility with the old-style traces 63 | // comment it out. 64 | // 65 | #define INTERFACE_CONTEXT 66 | 67 | // 68 | // Things are going to work differently here with respect to trace file handling 69 | // than in most places because the Tx and Rx trace sources we are interested in 70 | // are going to multiplex receive and transmit callbacks for all Ipv4 and 71 | // interface pairs through one callback. We want packets to or from each 72 | // distinct pair to go to an individual file, so we have got to demultiplex the 73 | // Ipv4 and interface pair into a corresponding Ptr at the 74 | // callback. 75 | // 76 | // A complication in this situation is that the trace sources are hooked on 77 | // a protocol basis. There is no trace source hooked by an Ipv4 and interface 78 | // pair. This means that if we naively proceed to hook, say, a drop trace 79 | // for a given Ipv4 with interface 0, and then hook for Ipv4 with interface 1 80 | // we will hook the drop trace twice and get two callbacks per event. What 81 | // we need to do is to hook the event once, and that will result in a single 82 | // callback per drop event, and the trace source will provide the interface 83 | // which we filter on in the trace sink. 84 | // 85 | // This has got to continue to work properly after the helper has been 86 | // destroyed; but must be cleaned up at the end of time to avoid leaks. 87 | // Global maps of protocol/interface pairs to file objects seems to fit the 88 | // bill. 89 | // 90 | 91 | void 92 | QuicHelper::InstallQuic (NodeContainer c) const 93 | { 94 | NS_LOG_INFO("stack install"); 95 | for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) 96 | { 97 | Install (*i); 98 | NS_LOG_INFO("ok " << *i); 99 | CreateAndAggregateObjectFromTypeId (*i, "ns3::QuicL4Protocol"); 100 | 101 | // Ptr factory = CreateObject (); 102 | // factory->SetNode(*i); 103 | // (*i)->AggregateObject (factory); 104 | } 105 | } 106 | 107 | void 108 | QuicHelper::CreateAndAggregateObjectFromTypeId (Ptr node, const std::string typeId) 109 | { 110 | ObjectFactory factory; 111 | factory.SetTypeId (typeId); 112 | Ptr protocol = factory.Create (); 113 | node->AggregateObject (protocol); 114 | } 115 | 116 | } // namespace ns3 117 | -------------------------------------------------------------------------------- /helper/quic-helper.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2008 INRIA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation; 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Author: Mathieu Lacage 19 | */ 20 | 21 | #ifndef QUIC_HELPER_H 22 | #define QUIC_HELPER_H 23 | 24 | #include "ns3/node-container.h" 25 | #include "ns3/net-device-container.h" 26 | #include "ns3/packet.h" 27 | #include "ns3/ptr.h" 28 | #include "ns3/object-factory.h" 29 | #include "ns3/ipv4-l3-protocol.h" 30 | #include "ns3/ipv6-l3-protocol.h" 31 | #include "ns3/internet-trace-helper.h" 32 | #include "ns3/internet-stack-helper.h" 33 | 34 | namespace ns3 { 35 | /** 36 | * \defgroup internet Internet 37 | * 38 | * This section documents the API of the ns-3 internet module. For a generic functional description, please refer to the ns-3 manual. 39 | */ 40 | 41 | /** 42 | * \ingroup internet 43 | * \defgroup ipv4Helpers IPv4 Helper classes 44 | */ 45 | 46 | /** 47 | * \ingroup internet 48 | * \defgroup ipv6Helpers IPv6 Helper classes 49 | */ 50 | 51 | /** 52 | * \ingroup internet 53 | * 54 | * \brief aggregate IP/TCP/UDP functionality to existing Nodes. 55 | * 56 | * This helper enables pcap and ascii tracing of events in the internet stack 57 | * associated with a node. This is substantially similar to the tracing 58 | * that happens in device helpers, but the important difference is that, well, 59 | * there is no device. This means that the creation of output file names will 60 | * change, and also the user-visible methods will not reference devices and 61 | * therefore the number of trace enable methods is reduced. 62 | * 63 | * Normally we avoid multiple inheritance in ns-3, however, the classes 64 | * PcapUserHelperForIpv4 and AsciiTraceUserHelperForIpv4 are 65 | * treated as "mixins". A mixin is a self-contained class that 66 | * encapsulates a general attribute or a set of functionality that 67 | * may be of interest to many other classes. 68 | * 69 | * This class aggregates instances of these objects, by default, to each node: 70 | * - ns3::ArpL3Protocol 71 | * - ns3::Ipv4L3Protocol 72 | * - ns3::Icmpv4L4Protocol 73 | * - ns3::Ipv6L3Protocol 74 | * - ns3::Icmpv6L4Protocol 75 | * - ns3::UdpL4Protocol 76 | * - ns3::TrafficControlLayer 77 | * - a TCP based on the TCP factory provided 78 | * - a PacketSocketFactory 79 | * - Ipv4 routing (a list routing object, a global routing object, and a static routing object) 80 | * - Ipv6 routing (a static routing object) 81 | */ 82 | class QuicHelper : public InternetStackHelper 83 | { 84 | public: 85 | /** 86 | * For each node in the input container, aggregate implementations of the 87 | * ns3::Ipv4, ns3::Ipv6, ns3::Udp, ns3::Quic, and ns3::Tcp classes. The program will assert 88 | * if this method is called on a container with a node that already has 89 | * an Ipv4 object aggregated to it. 90 | * 91 | * \param c NodeContainer that holds the set of nodes on which to install the 92 | * new stacks. 93 | */ 94 | void InstallQuic (NodeContainer c) const; 95 | 96 | private: 97 | /** 98 | * \brief create an object from its TypeId and aggregates it to the node 99 | * \param node the node 100 | * \param typeId the object TypeId 101 | */ 102 | static void CreateAndAggregateObjectFromTypeId (Ptr node, const std::string typeId); 103 | }; 104 | 105 | } // namespace ns3 106 | 107 | #endif /* QUIC_HELPER_H */ 108 | -------------------------------------------------------------------------------- /model/mp-quic-congestion-ops.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2020 SIGNET Lab, Department of Information Engineering, University of Padova 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation; 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Authors: Alvise De Biasio 19 | * Federico Chiariotti 20 | * Michele Polese 21 | * Davide Marcato 22 | * Umberto Paro 23 | * Shengjie Shu 24 | */ 25 | 26 | #ifndef MPMpQUICCONGESTIONOPS_H 27 | #define MPMpQUICCONGESTIONOPS_H 28 | 29 | #include "ns3/timer.h" 30 | #include "ns3/object.h" 31 | #include "quic-subheader.h" 32 | #include "ns3/tcp-congestion-ops.h" 33 | #include "ns3/tcp-socket-base.h" 34 | #include "quic-socket-base.h" 35 | #include "quic-socket-tx-buffer.h" 36 | #include "quic-congestion-ops.h" 37 | 38 | namespace ns3 { 39 | 40 | /** 41 | * \ingroup quic 42 | * \defgroup congestionOps Congestion Control Algorithms. 43 | * 44 | * The various congestion control algorithms. 45 | */ 46 | 47 | /** 48 | * \ingroup congestionOps 49 | * 50 | * \brief Congestion control abstract class 51 | * 52 | * The congestion control is splitted from the main socket code, and it is a 53 | * pluggable component. An interface has been defined; variables are maintained 54 | * in the QuicSocketState class, while subclasses of MpQuicCongestionOps operate 55 | * over an instance of that class. 56 | * 57 | * The design extends TcpNewReno to provide compatibility with the TCP congestion 58 | * control implementations, as well as the possibility of extending it with new 59 | * QUIC-related capabilities. 60 | * 61 | */ 62 | class MpQuicCongestionOps : public QuicCongestionOps 63 | { 64 | public: 65 | /** 66 | * \brief Get the type ID. 67 | * \return the object TypeId 68 | */ 69 | static TypeId GetTypeId (void); 70 | 71 | MpQuicCongestionOps (); 72 | MpQuicCongestionOps (const MpQuicCongestionOps& sock); 73 | ~MpQuicCongestionOps (); 74 | 75 | /** 76 | * \brief Get the name of the congestion control algorithm 77 | * 78 | * \return A string identifying the name 79 | */ 80 | std::string GetName () const; 81 | 82 | /** 83 | * \brief Copy the congestion control algorithm across socket 84 | * 85 | * \return a pointer of the copied object 86 | */ 87 | Ptr Fork (); 88 | 89 | // MpQuicCongestionControl Draft10 90 | 91 | /** 92 | * \brief Method called when a packet is sent. It updates the quantities in the tcb 93 | * 94 | * \param tcb a smart pointer to the SocketState (it accepts a QuicSocketState) 95 | * \param packetNumber the packet number 96 | * \param isAckOnly a flag to signal if the packet has only an ACK frame 97 | */ 98 | virtual void OnPacketSent (Ptr tcb, SequenceNumber32 packetNumber, bool isAckOnly); 99 | 100 | /** 101 | * \brief Method called when an ack is received. It process the received ack and updates 102 | * the quantities in the tcb. 103 | * 104 | * \param tcb a smart pointer to the SocketState (it accepts a QuicSocketState) 105 | * \param ack the received ACK 106 | * \param newAcks the newly acked packets 107 | * \param rs the connection RateSample 108 | */ 109 | virtual void OnAckReceived (Ptr tcb, QuicSubheader &ack, std::vector > newAcks, 110 | const struct RateSample *rs, double alpha, double sum_rate); 111 | 112 | /** 113 | * \brief Method called when a packet is lost. It process the lost packets and updates 114 | * the quantities in the tcb. 115 | * 116 | * \param tcb a smart pointer to the SocketState (it accepts a QuicSocketState) 117 | * \param lostPackets the lost packets 118 | */ 119 | virtual void OnPacketsLost (Ptr tcb, std::vector > lostPackets); 120 | 121 | void OnRetransmissionTimeout (Ptr tcb); 122 | 123 | 124 | protected: 125 | // MpQuicCongestionControl Draft10 126 | 127 | /** 128 | * \brief Method called to update the Rtt. It updates the quantities in the tcb. 129 | * 130 | * \param tcb a smart pointer to the SocketState (it accepts a QuicSocketState) 131 | * \param latestRtt the latest Rtt 132 | * \param ackDelay the ack delay 133 | */ 134 | void UpdateRtt (Ptr tcb, Time latestRtt, Time ackDelay); 135 | 136 | /** 137 | * \brief Method called when a packet is acked. It process the acked packet and updates 138 | * the quantities in the tcb. 139 | * 140 | * \param tcb a smart pointer to the SocketState (it accepts a QuicSocketState) 141 | * \param ackedPacked the acked packet 142 | */ 143 | virtual void OnPacketAcked (Ptr tcb, Ptr ackedPacket, double alpha, double sum_rate); 144 | 145 | /** 146 | * \brief Check if in recovery period 147 | * 148 | * \param tcb a smart pointer to the SocketState (it accepts a QuicSocketState) 149 | * \param packetNumber to be checked 150 | * \return true if in recovery, false otherwhise 151 | */ 152 | bool InRecovery (Ptr tcb, SequenceNumber32 packetNumber); 153 | 154 | /** 155 | * \brief Method called when a packet is acked. It updates the quantities in the tcb. 156 | * 157 | * \param tcb a smart pointer to the SocketState (it accepts a QuicSocketState) 158 | * \param ackedPacked the acked packet 159 | */ 160 | void OnPacketAckedCC (Ptr tcb, Ptr ackedPacket, double alpha, double sum_rate); 161 | 162 | /** 163 | * \brief Method called when retransmission timeout fires. It updates the quantities in the tcb. 164 | * 165 | * \param tcb a smart pointer to the SocketState (it accepts a QuicSocketState) 166 | */ 167 | virtual void OnRetransmissionTimeoutVerified (Ptr tcb); 168 | 169 | bool m_inCCAvoid; 170 | 171 | }; 172 | 173 | } 174 | #endif //QUIC_NS3_QUIC_CONGESTION_OPS_H_H 175 | -------------------------------------------------------------------------------- /model/mp-quic-path-manager.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Pan Lab, Department of Computer Science, University of Victoria 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation; 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Authors: Shengjie Shu 19 | */ 20 | 21 | #include "ns3/object.h" 22 | #include "ns3/log.h" 23 | #include "ns3/uinteger.h" 24 | #include "ns3/double.h" 25 | #include "ns3/boolean.h" 26 | #include "ns3/trace-source-accessor.h" 27 | #include "ns3/nstime.h" 28 | #include "quic-stream.h" 29 | #include "ns3/node.h" 30 | #include "ns3/string.h" 31 | 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | 40 | #include "mp-quic-path-manager.h" 41 | #include "mp-quic-subflow.h" 42 | 43 | namespace ns3 { 44 | 45 | NS_LOG_COMPONENT_DEFINE ("MpQuicPathManager"); 46 | 47 | NS_OBJECT_ENSURE_REGISTERED (MpQuicPathManager); 48 | 49 | 50 | TypeId 51 | MpQuicPathManager::GetTypeId (void) 52 | { 53 | static TypeId tid = TypeId ("ns3::MpQuicPathManager") 54 | .SetParent () 55 | .SetGroupName ("Internet") 56 | ; 57 | return tid; 58 | } 59 | 60 | MpQuicPathManager::MpQuicPathManager () 61 | : m_socket(0), 62 | m_segSize(0), 63 | m_initialSsThresh(0) 64 | { 65 | NS_LOG_FUNCTION_NOARGS (); 66 | 67 | } 68 | 69 | MpQuicPathManager::~MpQuicPathManager () 70 | { 71 | NS_LOG_FUNCTION_NOARGS (); 72 | 73 | } 74 | 75 | Ptr 76 | MpQuicPathManager::InitialSubflow0 (Address localAddress, Address peerAddress) 77 | { 78 | NS_LOG_FUNCTION(this); 79 | 80 | Ptr sFlow = CreateObject (); 81 | sFlow->m_flowId = 0; 82 | sFlow->m_peerAddr = peerAddress; 83 | sFlow->m_localAddr = localAddress; 84 | sFlow->m_subflowState = MpQuicSubFlow::Active; 85 | sFlow->SetSegSize(m_segSize); 86 | sFlow->m_tcb->m_initialSsThresh = m_initialSsThresh; 87 | m_socket->SubflowInsert(sFlow); 88 | bool ok; 89 | ok = sFlow->m_tcb->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&QuicSocketBase::UpdateCwnd, m_socket)); 90 | NS_ASSERT_MSG (ok == true, "Failed connection to CWND0 trace"); 91 | ok = sFlow->m_tcb->TraceConnectWithoutContext ("SlowStartThreshold", MakeCallback (&QuicSocketBase::UpdateSsThresh, m_socket)); 92 | NS_ASSERT_MSG (ok == true, "Failed connection to SSTHR0 trace"); 93 | ok = sFlow->m_tcb->TraceConnectWithoutContext ("RTT", MakeCallback (&QuicSocketBase::TraceRTT0, m_socket)); 94 | NS_ASSERT_MSG (ok == true, "Failed connection to RTT0 trace"); 95 | return sFlow; 96 | 97 | } 98 | 99 | Ptr 100 | MpQuicPathManager::AddSubflow(Address localAddress, Address peerAddress, uint8_t pathId) 101 | { 102 | 103 | NS_LOG_FUNCTION(this); 104 | Ptr sFlow = CreateObject (); 105 | sFlow->m_flowId = pathId; 106 | sFlow->m_localAddr = localAddress; 107 | sFlow->m_peerAddr = peerAddress; 108 | 109 | sFlow->m_subflowState = MpQuicSubFlow::Validating; 110 | sFlow->SetSegSize(m_segSize); 111 | sFlow->m_tcb->m_initialSsThresh = m_initialSsThresh; 112 | sFlow->m_tcb->m_cWnd = sFlow->m_tcb->m_initialCWnd; 113 | sFlow->m_tcb->m_ssThresh = sFlow->m_tcb->m_initialSsThresh; 114 | m_socket->SubflowInsert(sFlow); 115 | m_socket->AddPath(localAddress, peerAddress, pathId); 116 | m_socket->SendAddAddress(localAddress, pathId); 117 | 118 | return sFlow; 119 | 120 | } 121 | 122 | 123 | Ptr 124 | MpQuicPathManager::AddSubflowWithPeerAddress(Address localAddress, Address peerAddress, uint8_t pathId) 125 | { 126 | NS_LOG_FUNCTION(this); 127 | Ptr sFlow = CreateObject (); 128 | sFlow->m_flowId = pathId; 129 | sFlow->m_localAddr = localAddress; 130 | sFlow->m_peerAddr = peerAddress; 131 | sFlow->m_subflowState = MpQuicSubFlow::Validating; 132 | sFlow->SetSegSize(m_segSize); 133 | sFlow->m_tcb->m_initialSsThresh = m_initialSsThresh; 134 | sFlow->m_tcb->m_cWnd = sFlow->m_tcb->m_initialCWnd; 135 | sFlow->m_tcb->m_ssThresh = sFlow->m_tcb->m_initialSsThresh; 136 | m_socket->SubflowInsert(sFlow); 137 | m_socket->SendPathChallenge(pathId); 138 | bool ok; 139 | ok = sFlow->m_tcb->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&QuicSocketBase::UpdateCwnd1, m_socket)); 140 | NS_ASSERT_MSG (ok == true, "Failed connection to CWND trace"); 141 | ok = sFlow->m_tcb->TraceConnectWithoutContext ("SlowStartThreshold", MakeCallback (&QuicSocketBase::UpdateSsThresh1, m_socket)); 142 | NS_ASSERT_MSG (ok == true, "Failed connection to SSTHR1 trace"); 143 | ok = sFlow->m_tcb->TraceConnectWithoutContext ("RTT", MakeCallback (&QuicSocketBase::TraceRTT1, m_socket)); 144 | NS_ASSERT_MSG (ok == true, "Failed connection to RTT1 trace"); 145 | return sFlow; 146 | } 147 | 148 | 149 | void 150 | MpQuicPathManager::SetSocket(Ptr sock) 151 | { 152 | NS_LOG_FUNCTION (this); 153 | m_socket = sock; 154 | } 155 | 156 | void 157 | MpQuicPathManager::SetSegSize(uint32_t size) 158 | { 159 | NS_LOG_FUNCTION(this); 160 | m_segSize = size; 161 | } 162 | 163 | uint32_t 164 | MpQuicPathManager::GetSegSize() const 165 | { 166 | NS_LOG_FUNCTION(this); 167 | return m_segSize; 168 | } 169 | 170 | void 171 | MpQuicPathManager::SetInitialSSThresh (uint32_t threshold) 172 | { 173 | m_initialSsThresh = threshold; 174 | } 175 | 176 | uint32_t 177 | MpQuicPathManager::GetInitialSSThresh (void) const 178 | { 179 | return m_initialSsThresh; 180 | } 181 | 182 | 183 | } -------------------------------------------------------------------------------- /model/mp-quic-path-manager.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Pan Lab, Department of Computer Science, University of Victoria 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation; 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Authors: Shengjie Shu 19 | */ 20 | 21 | #ifndef MpQUICPATHMANAGER_H 22 | #define MpQUICPATHMANAGER_H 23 | 24 | #include "ns3/node.h" 25 | 26 | #include "quic-socket-base.h" 27 | #include "mp-quic-subflow.h" 28 | 29 | namespace ns3 { 30 | 31 | /** 32 | * \ingroup quic 33 | * 34 | * \see MpQuicPathManagerBase 35 | * \brief (abstract) base class of all MpQuicPathManagers 36 | * 37 | * This class constitutes a basic implementation of a Quic Stream. 38 | * 39 | */ 40 | class MpQuicPathManager : public Object 41 | { 42 | public: 43 | /** 44 | * Get the type ID. 45 | * \brief Get the type ID. 46 | * \return the object TypeId 47 | */ 48 | static TypeId GetTypeId (void); 49 | 50 | MpQuicPathManager (void); 51 | virtual ~MpQuicPathManager (void); 52 | 53 | 54 | Ptr InitialSubflow0 (Address localAddress, Address peerAddress); 55 | Ptr AddSubflow(Address address, Address from, uint8_t pathId); 56 | Ptr AddSubflowWithPeerAddress(Address localAddress, Address peerAddress, uint8_t pathId); 57 | 58 | void SetSocket(Ptr sock); 59 | void SetSegSize(uint32_t size); 60 | uint32_t GetSegSize() const; 61 | void SetInitialSSThresh (uint32_t threshold); 62 | uint32_t GetInitialSSThresh (void) const; 63 | 64 | 65 | 66 | private: 67 | Ptr m_socket; 68 | uint32_t m_segSize; 69 | uint32_t m_initialSsThresh; 70 | 71 | 72 | }; 73 | 74 | } // namespace ns3 75 | 76 | #endif /* MP_QUIC_PATH_MANAGER_H */ 77 | 78 | 79 | -------------------------------------------------------------------------------- /model/mp-quic-scheduler.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Pan Lab, Department of Computer Science, University of Victoria 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation; 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Authors: Shengjie Shu 19 | */ 20 | 21 | 22 | #ifndef MPQUICSCHEDULER_H 23 | #define MPQUICSCHEDULER_H 24 | 25 | #include "ns3/node.h" 26 | #include "quic-socket-base.h" 27 | #include 28 | using Eigen::MatrixXd; 29 | using Eigen::VectorXd; 30 | 31 | namespace ns3 { 32 | 33 | class MpQuicScheduler : public Object 34 | { 35 | public: 36 | 37 | typedef enum 38 | { 39 | ROUND_ROBIN, 40 | MIN_RTT, 41 | BLEST, 42 | ECF, 43 | PEEKABOO, 44 | MAB_DELAY 45 | } SchedulerType_t; 46 | 47 | /** 48 | * Get the type ID. 49 | * \brief Get the type ID. 50 | * \return the object TypeId 51 | */ 52 | static TypeId GetTypeId (void); 53 | 54 | MpQuicScheduler (void); 55 | virtual ~MpQuicScheduler (void); 56 | 57 | std::vector GetNextPathIdToUse(); 58 | void SetSocket(Ptr sock); 59 | 60 | void UpdateReward (uint32_t oldValue, uint32_t newValue); 61 | void SetNumOfLostPackets(uint16_t lost); 62 | void UpdateRewardMab(uint8_t pathId, uint32_t lostOut, uint32_t inflight, uint32_t round); 63 | uint32_t GetCurrentRound(); 64 | 65 | void PeekabooReward(uint8_t pathId, Time lastActTime); 66 | 67 | private: 68 | Ptr m_socket; 69 | uint8_t m_lastUsedPathId; 70 | 71 | 72 | std::vector > m_subflows; 73 | SchedulerType_t m_schedulerType; 74 | 75 | 76 | std::vector RoundRobin(); 77 | std::vector MinRtt(); 78 | std::vector Peekaboo(); 79 | std::vector MabDelay(); 80 | std::vector Blest(); 81 | std::vector Ecf(); 82 | std::vector LocalOpt(); 83 | 84 | std::vector m_rewards; 85 | std::vector m_rewardTemp; 86 | std::vector m_rewardTemp0; 87 | std::vector m_rewardAvg; 88 | uint32_t m_rounds; 89 | TracedValue m_reward {0}; 90 | 91 | uint32_t m_rate; 92 | uint16_t m_lostPackets; 93 | uint16_t m_lambda; 94 | uint16_t m_bVar; 95 | uint8_t m_waiting = 0; 96 | uint16_t m_select; 97 | 98 | std::vector m_cost; 99 | std::vector m_missingRounds; 100 | uint32_t m_lastUpdateRounds; 101 | uint32_t m_e; 102 | std::vector m_L; 103 | std::vector m_eL; 104 | std::vector m_p; 105 | std::vector EPR; 106 | std::vector A; 107 | std::vector b; 108 | VectorXd peek_x = VectorXd::Constant(6,0); 109 | double T_r, g = 1, R = 0, T_e; 110 | double rtt[8]; 111 | }; 112 | 113 | } // namespace ns3 114 | 115 | #endif /* MP_QUIC_SCHEDULER_H */ 116 | 117 | 118 | -------------------------------------------------------------------------------- /model/mp-quic-subflow.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Pan Lab, Department of Computer Science, University of Victoria 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation; 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Authors: Shengjie Shu 19 | */ 20 | 21 | 22 | #include 23 | #include 24 | #include "ns3/buffer.h" 25 | #include "ns3/address-utils.h" 26 | #include "ns3/log.h" 27 | #include "mp-quic-subflow.h" 28 | #include 29 | #include 30 | #include "ns3/traced-value.h" 31 | #include "ns3/trace-source-accessor.h" 32 | #include 33 | #include "ns3/simulator.h" 34 | #include "time.h" 35 | #include "ns3/string.h" 36 | 37 | #include "quic-socket-tx-scheduler.h" 38 | #include "quic-socket-base.h" 39 | 40 | #include 41 | #include 42 | #include 43 | 44 | NS_LOG_COMPONENT_DEFINE ("MpQuicSubFlow"); 45 | namespace ns3 { 46 | 47 | NS_OBJECT_ENSURE_REGISTERED (MpQuicSubFlow); 48 | 49 | 50 | TypeId 51 | MpQuicSubFlow::GetTypeId (void) 52 | { 53 | static TypeId tid = TypeId ("ns3::MpQuicSubFlow") 54 | .SetParent (Object::GetTypeId ()) 55 | 56 | .AddTraceSource ("CWindow", 57 | "The QUIC connection's congestion window", 58 | MakeTraceSourceAccessor (&MpQuicSubFlow::m_cWndTrace), 59 | "ns3::TracedValueCallback::Uint32") 60 | ; 61 | return tid; 62 | } 63 | 64 | MpQuicSubFlow::MpQuicSubFlow() 65 | : m_flowId (0), 66 | m_lastMaxData(0), 67 | m_maxDataInterval(10), 68 | m_rounds(1) 69 | { 70 | 71 | m_numPacketsReceivedSinceLastAckSent = 0; 72 | m_queue_ack = false; 73 | m_receivedPacketNumbers = std::vector (); 74 | 75 | //For congestion control 76 | m_tcb = CreateObject (); 77 | m_tcb->m_cWnd = m_tcb->m_initialCWnd; 78 | m_tcb->m_ssThresh = m_tcb->m_initialSsThresh; 79 | m_tcb->m_pacingRate = m_tcb->m_maxPacingRate; 80 | 81 | // connect callbacks 82 | bool ok; 83 | ok = m_tcb->TraceConnectWithoutContext ("CongestionWindow", 84 | MakeCallback (&MpQuicSubFlow::UpdateCwnd, this)); 85 | NS_ASSERT_MSG (ok == true, "Failed connection to CWND trace"); 86 | 87 | } 88 | 89 | MpQuicSubFlow::~MpQuicSubFlow() 90 | { 91 | m_flowId = 0; 92 | } 93 | 94 | 95 | 96 | void 97 | MpQuicSubFlow::SetSegSize (uint32_t size) 98 | { 99 | NS_LOG_FUNCTION (this << size); 100 | 101 | m_tcb->m_segmentSize = size; 102 | m_tcb->m_initialCWnd = 2 * size; 103 | m_tcb->m_kMinimumWindow = 2 * size; 104 | } 105 | 106 | uint32_t 107 | MpQuicSubFlow::GetSegSize (void) const 108 | { 109 | return m_tcb->m_segmentSize; 110 | } 111 | 112 | double 113 | MpQuicSubFlow::GetRate() 114 | { 115 | if (m_tcb->m_lastRtt.Get().GetSeconds() == 0){ 116 | return 0; 117 | } 118 | return m_tcb->m_cWnd/m_tcb->m_segmentSize/m_tcb->m_lastRtt.Get().GetSeconds(); 119 | } 120 | 121 | void 122 | MpQuicSubFlow::UpdateCwnd (uint32_t oldValue, uint32_t newValue) 123 | { 124 | m_cWndTrace (oldValue, newValue); 125 | } 126 | 127 | 128 | } // namespace ns3 129 | -------------------------------------------------------------------------------- /model/mp-quic-subflow.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Pan Lab, Department of Computer Science, University of Victoria 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation; 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * Authors: Shengjie Shu 19 | */ 20 | 21 | #include 22 | #include 23 | #include "ns3/sequence-number.h" 24 | #include "ns3/rtt-estimator.h" 25 | #include "ns3/ipv4-address.h" 26 | #include "ns3/event-id.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "ns3/object.h" 33 | #include "ns3/uinteger.h" 34 | #include "ns3/traced-value.h" 35 | #include "ns3/trace-source-accessor.h" 36 | 37 | #include "quic-socket-tx-buffer.h" 38 | #include "quic-socket-base.h" 39 | 40 | #ifndef MP_QUIC_SUBFLOW_H 41 | #define MP_QUIC_SUBFLOW_H 42 | 43 | using namespace std; 44 | 45 | namespace ns3 { 46 | 47 | class MpQuicSubFlow : public Object 48 | { 49 | public: 50 | 51 | typedef enum 52 | { 53 | Validating, //!< subflow is initialed, cannot send data yet 54 | Active, //!< sublfow is fully active 55 | Closeing, //!< subflow is closing 56 | Closed //!< subflow is fully closed 57 | } SubflowStates_t; 58 | 59 | static TypeId GetTypeId (void); 60 | 61 | MpQuicSubFlow (); 62 | ~MpQuicSubFlow (); 63 | 64 | uint16_t m_flowId; 65 | Address m_localAddr; 66 | Address m_peerAddr; 67 | 68 | TracedValue m_subflowState; //!< State 69 | 70 | void SetSegSize (uint32_t size); 71 | uint32_t GetSegSize (void) const; 72 | double GetRate(); 73 | 74 | 75 | void UpdateCwnd (uint32_t oldValue, uint32_t newValue); 76 | 77 | // The following member parameters are moved from 'quic-socket-base.h' 78 | // Timers and Events 79 | EventId m_sendPendingDataEvent; //!< Micro-delay event to send pending data 80 | EventId m_retxEvent; //!< Retransmission event 81 | EventId m_idleTimeoutEvent; //!< Event triggered upon receiving or sending a packet, when it expires the connection closes 82 | EventId m_drainingPeriodEvent; //!< Event triggered upon idle timeout or immediate connection close, when it expires all closes 83 | TracedValue