Changelog:

  • 19 Nov 2025: adjust some formatting issues
  • 19 Nov 2025: update supplied git repository to use higher target throughput instead of higher rate in messages for better clarity; mention explicitly that –assignmentTestScenario runs the two configurations and compares the bytes sent
  • 20 Nov 2025: update supplied git repository to populate ARP tables, which prevents getting 0 bytes sent if ARP messages are lost, which can be somewhat random
  • 21 Nov 2025: add some (arguable) hints
  • 23 Nov 2025: added hint re: thinking about number of frames that must be sent per segment
  • 1 Dec 2025: change 5 scenarios to 6 scenarios; numerical numbers to numerical values

1 Your Task

  1. Download our copy of NS-3 (same git repository as for AIMD):

    git clone -b cs4457-dist https://github.com/charlesreiss/ns-3-dev ./ns-3-dev
  2. Look at the simulation in scratch/wireless-ex.cc of a wireless networking scenario with four nodes, where node 1 transmits to node 2 and node 3 transmits to node 4.

    The simulation has various parameters affecting the data rate transmitted and the wireless network configuration.

    In this assignment, we’ll be measuring the total number of bytes received by nodes 2 and 4.

  3. Your goal is to manipulate the SetupPositions functions to set the positions of the nodes so that one network configuration achieves better performance than another.

    In addition to completing the code for SetupPositions, you need to describe how you did so (see below), so make sure you keep track of any experiments or calculations you performed.

    We have 6 scenarios for you to choose position for, which are documented by running ./ns3 run scratch/wireless-ex -- --listScenarios=true:

    Scenario #1
    With
      --physicalMode=DsssRate1Mbps --sendRate=0.9Mbps --rtsCts=false --txPower=16 --retryCount=7 --useTcp=false
    send at least 150.0% of the bytes sent with
      --physicalMode=DsssRate1Mbps --sendRate=0.9Mbps --rtsCts=false --txPower=3 --retryCount=7 --useTcp=false
    
    Scenario #2
    With
      --physicalMode=DsssRate1Mbps --sendRate=0.9Mbps --rtsCts=false --txPower=3 --retryCount=7 --useTcp=false
    send at least 150.0% of the bytes sent with
      --physicalMode=DsssRate1Mbps --sendRate=0.9Mbps --rtsCts=false --txPower=16 --retryCount=7 --useTcp=false
    
    Scenario #3
    With
      --physicalMode=DsssRate1Mbps --sendRate=0.9Mbps --rtsCts=true --txPower=16.0206 --retryCount=7 --useTcp=false
    send at least 150.0% of the bytes sent with
      --physicalMode=DsssRate5_5Mbps --sendRate=0.9Mbps --rtsCts=true --txPower=16.0206 --retryCount=7 --useTcp=false
    
    Scenario #4
    With
      --physicalMode=DsssRate1Mbps --sendRate=0.45Mbps --rtsCts=true --txPower=16.0206 --retryCount=7 --useTcp=false
    send at least 180.0% of the bytes sent with
      --physicalMode=DsssRate1Mbps --sendRate=0.45Mbps --rtsCts=false --txPower=16.0206 --retryCount=7 --useTcp=false
    
    Scenario #5
    With
      --physicalMode=DsssRate1Mbps --sendRate=0.9Mbps --rtsCts=false --txPower=16.0206 --retryCount=7 --useTcp=false
    send at least 130.0% of the bytes sent with
      --physicalMode=DsssRate1Mbps --sendRate=0.9Mbps --rtsCts=true --txPower=16.0206 --retryCount=7 --useTcp=false
    
    Scenario #6
    With
      --physicalMode=DsssRate1Mbps --sendRate=0.25Mbps --rtsCts=false --txPower=16.0206 --retryCount=7 --useTcp=true
    send at least 150.0% of the bytes sent with
      --physicalMode=DsssRate1Mbps --sendRate=0.25Mbps --rtsCts=false --txPower=16.0206 --retryCount=1 --useTcp=true
  4. Produce a report in a text, HTML, or PDF file with, for each scenario:

    • a brief description of why you think your scenario results in the desired bytes-received difference. (For example, what is happening the low-performance case that is not happening in the high-performance case.)

    • a brief description of any calculations or experiments you performed to find the exact numerical values. For example, if you tried to find out the maximum range of a transmission by trying a bunch of positions, describe what result you determined, how you varied positions to do so, and what measurements you got doing this.

  5. Submit your code (as a .cc file) and your report to the submission site.

2 Using the simulation

  1. You can use a command like

    ./ns3 run scratch/wireless-ex -- --scenarioId=1 --physicalMode=DsssRate1Mbps \
        --sendRate=0.9Mbps --rtsCts=false --txPower=3 --retryCount=7 --useTcp=false

    to run with a specific set of parameters.

  2. You can adjust the duration with an option like --duration=1s if you want a shorter test to limit debug output.

  3. There are various options you can use to get more detailed debug output:

    1. You can use --flowDump=true to get a count of the bytes sent between each pair of IP addresses, including differences between transmitted and received bytes/packets.

    2. You can use --enablePcaps=true to have pcap files written for each node. The files will be named like wireless-ex-N-0.pcap, where N is the node number. (The 0 is a device number; each node has one network device, its simulated wireless link.)

    3. You can use --retransmitCountDump=true to get a count of the number of packets retransmitted by each node.

    4. You can use --enableWifiLogging=true to get very detailed logging of events in the wifi simulation.

  4. As documented in the reelvant section of NS-3 manual, you can set the NS_LOG enviroment variable to control what logging is enabled in NS-3.

    For example, since scratch/wireless-ex.cc declares NS_LOG_COMPONENT_DEFINE("WirelessEx"); at the top, if you type

    NS_LOG_INFO("This is a message where scenarioId = " << scenarioId);

    and run scratch/wireless-ex like

    NS_LOG="WirelessEx" ./ns3 run scratch/wireless-ex ...

    or NS_LOG=WirelessEx=level_info ./ns3 run scratch/wireless-ex …

    or export NS_LOG=WirelessEx … ./ns3 run scratch/wireless-ex …

    or similar, then that message will be output, including the actual value of the scenarioId variable.

  5. You can use --verbose to enable lots of logging of wireless behavior and the production of pcap files.

  6. You can use

    ./ns3 run scratch/wireless-ex -- --assignmentTestScenario=1

    to test both the high target throughput/low target throughput case and see how their achieved bytes sent compares.

3 Notes on simulation models

  1. The simulation uses (an approximation of) the 802.11b MAC protocol. The simulated links are all in ad-hoc mode, so there is not access point (base station); nodes just transmit directly to other nodes in range. There is no routing.

  2. The simulation determines the tranmission strength received using NS-3’s Friis propoagation loss model, documented here

  3. The simulation ends up using NS_3’s DSSS (802.11b bit encoding) error rate model, described here. In particular, figure 1.2 shows the bit error rate (BER) used by the model for various transmission rates based on the signal to noise ratio (labeled SIR); figure 1.3 shows the packet reception rate versus signal strength when there is no interference.

4 Hints

  1. I found it helpful to modify the .cc file to sweep through a bunch of distances after having an idea of a kind of placement that should be helpful, but not having it be immediately apparent what distances would work.

  2. The distance at which signals may interfere with each other is not the same as the distance at which they can be received well.

  3. If a configuration requires us to exchange more frames successfully/promptly to send one segment of data, then it’s likely to be more sensitive to poor reception/interference.