diff --git a/examples/csma-bridge-one-hop.cc b/examples/csma/csma-bridge-one-hop.cc similarity index 100% rename from examples/csma-bridge-one-hop.cc rename to examples/csma/csma-bridge-one-hop.cc diff --git a/examples/csma-bridge.cc b/examples/csma/csma-bridge.cc similarity index 100% rename from examples/csma-bridge.cc rename to examples/csma/csma-bridge.cc diff --git a/examples/csma-bridge.py b/examples/csma/csma-bridge.py similarity index 100% rename from examples/csma-bridge.py rename to examples/csma/csma-bridge.py diff --git a/examples/csma-broadcast.cc b/examples/csma/csma-broadcast.cc similarity index 100% rename from examples/csma-broadcast.cc rename to examples/csma/csma-broadcast.cc diff --git a/examples/csma-multicast.cc b/examples/csma/csma-multicast.cc similarity index 100% rename from examples/csma-multicast.cc rename to examples/csma/csma-multicast.cc diff --git a/examples/csma-one-subnet.cc b/examples/csma/csma-one-subnet.cc similarity index 100% rename from examples/csma-one-subnet.cc rename to examples/csma/csma-one-subnet.cc diff --git a/examples/csma-packet-socket.cc b/examples/csma/csma-packet-socket.cc similarity index 100% rename from examples/csma-packet-socket.cc rename to examples/csma/csma-packet-socket.cc diff --git a/examples/csma-ping.cc b/examples/csma/csma-ping.cc similarity index 100% rename from examples/csma-ping.cc rename to examples/csma/csma-ping.cc diff --git a/examples/csma-raw-ip-socket.cc b/examples/csma/csma-raw-ip-socket.cc similarity index 100% rename from examples/csma-raw-ip-socket.cc rename to examples/csma/csma-raw-ip-socket.cc diff --git a/examples/csma-star.cc b/examples/csma/csma-star.cc similarity index 100% rename from examples/csma-star.cc rename to examples/csma/csma-star.cc diff --git a/examples/csma/waf b/examples/csma/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/csma/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/csma/wscript b/examples/csma/wscript new file mode 100644 index 000000000..6dd0a867d --- /dev/null +++ b/examples/csma/wscript @@ -0,0 +1,29 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('csma-one-subnet', ['csma', 'internet-stack']) + obj.source = 'csma-one-subnet.cc' + + obj = bld.create_ns3_program('csma-bridge', ['bridge', 'csma', 'internet-stack']) + obj.source = 'csma-bridge.cc' + + obj = bld.create_ns3_program('csma-bridge-one-hop', ['bridge', 'csma', 'internet-stack']) + obj.source = 'csma-bridge-one-hop.cc' + + obj = bld.create_ns3_program('csma-broadcast', ['csma', 'internet-stack']) + obj.source = 'csma-broadcast.cc' + + obj = bld.create_ns3_program('csma-packet-socket', ['csma', 'internet-stack']) + obj.source = 'csma-packet-socket.cc' + + obj = bld.create_ns3_program('csma-multicast', ['csma', 'internet-stack']) + obj.source = 'csma-multicast.cc' + + obj = bld.create_ns3_program('csma-star', ['csma', 'internet-stack']) + obj.source = 'csma-star.cc' + + obj = bld.create_ns3_program('csma-raw-ip-socket', ['csma', 'internet-stack']) + obj.source = 'csma-raw-ip-socket.cc' + + obj = bld.create_ns3_program('csma-ping', ['csma', 'internet-stack', 'v4ping']) + obj.source = 'csma-ping.cc' diff --git a/examples/emu-ping.cc b/examples/emulation/emu-ping.cc similarity index 100% rename from examples/emu-ping.cc rename to examples/emulation/emu-ping.cc diff --git a/examples/emu-udp-echo.cc b/examples/emulation/emu-udp-echo.cc similarity index 100% rename from examples/emu-udp-echo.cc rename to examples/emulation/emu-udp-echo.cc diff --git a/examples/emulation/waf b/examples/emulation/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/emulation/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/emulation/wscript b/examples/emulation/wscript new file mode 100644 index 000000000..70c42cb46 --- /dev/null +++ b/examples/emulation/wscript @@ -0,0 +1,10 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + env = bld.env_of_name('default') + if env['ENABLE_EMU']: + obj = bld.create_ns3_program('emu-udp-echo', ['emu', 'internet-stack']) + obj.source = 'emu-udp-echo.cc' + + obj = bld.create_ns3_program('emu-ping', ['emu', 'internet-stack']) + obj.source = 'emu-ping.cc' diff --git a/examples/simple-error-model.cc b/examples/error-model/simple-error-model.cc similarity index 100% rename from examples/simple-error-model.cc rename to examples/error-model/simple-error-model.cc diff --git a/examples/error-model/waf b/examples/error-model/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/error-model/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/error-model/wscript b/examples/error-model/wscript new file mode 100644 index 000000000..a058ec454 --- /dev/null +++ b/examples/error-model/wscript @@ -0,0 +1,5 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('simple-error-model', ['point-to-point', 'internet-stack']) + obj.source = 'simple-error-model.cc' diff --git a/examples/flowmon/waf b/examples/flowmon/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/flowmon/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/wifi-olsr-flowmon.py b/examples/flowmon/wifi-olsr-flowmon.py similarity index 100% rename from examples/wifi-olsr-flowmon.py rename to examples/flowmon/wifi-olsr-flowmon.py diff --git a/examples/flowmon/wscript b/examples/flowmon/wscript new file mode 100644 index 000000000..594d10cf5 --- /dev/null +++ b/examples/flowmon/wscript @@ -0,0 +1,4 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + pass diff --git a/examples/icmpv6-redirect.cc b/examples/ipv6/icmpv6-redirect.cc similarity index 100% rename from examples/icmpv6-redirect.cc rename to examples/ipv6/icmpv6-redirect.cc diff --git a/examples/ping6.cc b/examples/ipv6/ping6.cc similarity index 100% rename from examples/ping6.cc rename to examples/ipv6/ping6.cc diff --git a/examples/radvd-two-prefix.cc b/examples/ipv6/radvd-two-prefix.cc similarity index 100% rename from examples/radvd-two-prefix.cc rename to examples/ipv6/radvd-two-prefix.cc diff --git a/examples/radvd.cc b/examples/ipv6/radvd.cc similarity index 100% rename from examples/radvd.cc rename to examples/ipv6/radvd.cc diff --git a/examples/test-ipv6.cc b/examples/ipv6/test-ipv6.cc similarity index 100% rename from examples/test-ipv6.cc rename to examples/ipv6/test-ipv6.cc diff --git a/examples/ipv6/waf b/examples/ipv6/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/ipv6/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/ipv6/wscript b/examples/ipv6/wscript new file mode 100644 index 000000000..62d5552ed --- /dev/null +++ b/examples/ipv6/wscript @@ -0,0 +1,17 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('icmpv6-redirect', ['csma', 'internet-stack']) + obj.source = 'icmpv6-redirect.cc' + + obj = bld.create_ns3_program('ping6', ['csma', 'internet-stack']) + obj.source = 'ping6.cc' + + obj = bld.create_ns3_program('radvd', ['csma', 'internet-stack']) + obj.source = 'radvd.cc' + + obj = bld.create_ns3_program('radvd-two-prefix', ['csma', 'internet-stack']) + obj.source = 'radvd-two-prefix.cc' + + obj = bld.create_ns3_program('test-ipv6', ['point-to-point', 'internet-stack']) + obj.source = 'test-ipv6.cc' diff --git a/examples/mesh.cc b/examples/mesh/mesh.cc similarity index 100% rename from examples/mesh.cc rename to examples/mesh/mesh.cc diff --git a/examples/mesh/waf b/examples/mesh/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/mesh/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/mesh/wscript b/examples/mesh/wscript new file mode 100644 index 000000000..dc8917831 --- /dev/null +++ b/examples/mesh/wscript @@ -0,0 +1,5 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('mesh', ['core', 'simulator', 'mobility', 'wifi', 'mesh']) + obj.source = 'mesh.cc' diff --git a/examples/object-names.cc b/examples/naming/object-names.cc similarity index 100% rename from examples/object-names.cc rename to examples/naming/object-names.cc diff --git a/examples/naming/waf b/examples/naming/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/naming/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/naming/wscript b/examples/naming/wscript new file mode 100644 index 000000000..ac0e7735b --- /dev/null +++ b/examples/naming/wscript @@ -0,0 +1,5 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('object-names', ['core', 'simulator', 'csma', 'internet-stack']) + obj.source = 'object-names.cc' diff --git a/examples/realtime-udp-echo.cc b/examples/realtime/realtime-udp-echo.cc similarity index 100% rename from examples/realtime-udp-echo.cc rename to examples/realtime/realtime-udp-echo.cc diff --git a/examples/realtime/waf b/examples/realtime/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/realtime/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/realtime/wscript b/examples/realtime/wscript new file mode 100644 index 000000000..e82688730 --- /dev/null +++ b/examples/realtime/wscript @@ -0,0 +1,5 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('realtime-udp-echo', ['csma', 'internet-stack']) + obj.source = 'realtime-udp-echo.cc' diff --git a/examples/dynamic-global-routing.cc b/examples/routing/dynamic-global-routing.cc similarity index 100% rename from examples/dynamic-global-routing.cc rename to examples/routing/dynamic-global-routing.cc diff --git a/examples/global-injection-slash32.cc b/examples/routing/global-injection-slash32.cc similarity index 100% rename from examples/global-injection-slash32.cc rename to examples/routing/global-injection-slash32.cc diff --git a/examples/global-routing-slash32.cc b/examples/routing/global-routing-slash32.cc similarity index 100% rename from examples/global-routing-slash32.cc rename to examples/routing/global-routing-slash32.cc diff --git a/examples/mixed-global-routing.cc b/examples/routing/mixed-global-routing.cc similarity index 100% rename from examples/mixed-global-routing.cc rename to examples/routing/mixed-global-routing.cc diff --git a/examples/nix-simple.cc b/examples/routing/nix-simple.cc similarity index 100% rename from examples/nix-simple.cc rename to examples/routing/nix-simple.cc diff --git a/examples/nms-p2p-nix.cc b/examples/routing/nms-p2p-nix.cc similarity index 100% rename from examples/nms-p2p-nix.cc rename to examples/routing/nms-p2p-nix.cc diff --git a/examples/simple-alternate-routing.cc b/examples/routing/simple-alternate-routing.cc similarity index 100% rename from examples/simple-alternate-routing.cc rename to examples/routing/simple-alternate-routing.cc diff --git a/examples/simple-global-routing.cc b/examples/routing/simple-global-routing.cc similarity index 100% rename from examples/simple-global-routing.cc rename to examples/routing/simple-global-routing.cc diff --git a/examples/simple-point-to-point-olsr.cc b/examples/routing/simple-point-to-point-olsr.cc similarity index 100% rename from examples/simple-point-to-point-olsr.cc rename to examples/routing/simple-point-to-point-olsr.cc diff --git a/examples/simple-routing-ping6.cc b/examples/routing/simple-routing-ping6.cc similarity index 100% rename from examples/simple-routing-ping6.cc rename to examples/routing/simple-routing-ping6.cc diff --git a/examples/simple-routing-ping6.py b/examples/routing/simple-routing-ping6.py similarity index 100% rename from examples/simple-routing-ping6.py rename to examples/routing/simple-routing-ping6.py diff --git a/examples/static-routing-slash32.cc b/examples/routing/static-routing-slash32.cc similarity index 100% rename from examples/static-routing-slash32.cc rename to examples/routing/static-routing-slash32.cc diff --git a/examples/routing/waf b/examples/routing/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/routing/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/routing/wscript b/examples/routing/wscript new file mode 100644 index 000000000..bff2f8b0e --- /dev/null +++ b/examples/routing/wscript @@ -0,0 +1,46 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('dynamic-global-routing', + ['point-to-point', 'csma', 'internet-stack', 'global-routing']) + obj.source = 'dynamic-global-routing.cc' + + obj = bld.create_ns3_program('static-routing-slash32', + ['point-to-point', 'internet-stack', 'global-routing']) + obj.source = 'static-routing-slash32.cc' + + obj = bld.create_ns3_program('global-routing-slash32', + ['point-to-point', 'internet-stack', 'global-routing']) + obj.source = 'global-routing-slash32.cc' + + obj = bld.create_ns3_program('global-injection-slash32', + ['point-to-point', 'internet-stack', 'global-routing']) + obj.source = 'global-injection-slash32.cc' + + obj = bld.create_ns3_program('simple-global-routing', + ['point-to-point', 'internet-stack', 'global-routing']) + obj.source = 'simple-global-routing.cc' + + obj = bld.create_ns3_program('simple-alternate-routing', + ['point-to-point', 'internet-stack', 'global-routing']) + obj.source = 'simple-alternate-routing.cc' + + obj = bld.create_ns3_program( 'mixed-global-routing', + ['point-to-point', 'internet-stack', 'global-routing' , 'csma-cd']) + obj.source = 'mixed-global-routing.cc' + + obj = bld.create_ns3_program('simple-point-to-point-olsr', + ['point-to-point', 'internet-stack', 'olsr']) + obj.source = 'simple-point-to-point-olsr.cc' + + obj = bld.create_ns3_program('nix-simple', + ['point-to-point', 'internet-stack', 'nix-vector-routing']) + obj.source = 'nix-simple.cc' + + obj = bld.create_ns3_program('nms-p2p-nix', + ['point-to-point', 'internet-stack', 'nix-vector-routing']) + obj.source = 'nms-p2p-nix.cc' + + obj = bld.create_ns3_program('simple-routing-ping6', + ['csma', 'internet-stack']) + obj.source = 'simple-routing-ping6.cc' diff --git a/examples/tap-wifi-dumbbell.cc b/examples/tap/tap-wifi-dumbbell.cc similarity index 100% rename from examples/tap-wifi-dumbbell.cc rename to examples/tap/tap-wifi-dumbbell.cc diff --git a/examples/tap/waf b/examples/tap/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/tap/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/tap/wscript b/examples/tap/wscript new file mode 100644 index 000000000..c80b7ae70 --- /dev/null +++ b/examples/tap/wscript @@ -0,0 +1,8 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + env = bld.env_of_name('default') + if env['ENABLE_TAP']: + obj = bld.create_ns3_program('tap-wifi-dumbbell', + ['wifi', 'csma', 'point-to-point', 'tap-bridge', 'internet-stack']) + obj.source = 'tap-wifi-dumbbell.cc' diff --git a/examples/star.cc b/examples/tcp/star.cc similarity index 100% rename from examples/star.cc rename to examples/tcp/star.cc diff --git a/examples/tcp-large-transfer.cc b/examples/tcp/tcp-large-transfer.cc similarity index 100% rename from examples/tcp-large-transfer.cc rename to examples/tcp/tcp-large-transfer.cc diff --git a/examples/tcp-nsc-lfn.cc b/examples/tcp/tcp-nsc-lfn.cc similarity index 100% rename from examples/tcp-nsc-lfn.cc rename to examples/tcp/tcp-nsc-lfn.cc diff --git a/examples/tcp-nsc-zoo.cc b/examples/tcp/tcp-nsc-zoo.cc similarity index 100% rename from examples/tcp-nsc-zoo.cc rename to examples/tcp/tcp-nsc-zoo.cc diff --git a/examples/tcp-star-server.cc b/examples/tcp/tcp-star-server.cc similarity index 100% rename from examples/tcp-star-server.cc rename to examples/tcp/tcp-star-server.cc diff --git a/examples/tcp/waf b/examples/tcp/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/tcp/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/tcp/wscript b/examples/tcp/wscript new file mode 100644 index 000000000..32638a057 --- /dev/null +++ b/examples/tcp/wscript @@ -0,0 +1,22 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('tcp-large-transfer', + ['point-to-point', 'internet-stack']) + obj.source = 'tcp-large-transfer.cc' + + obj = bld.create_ns3_program('tcp-nsc-lfn', + ['point-to-point', 'internet-stack']) + obj.source = 'tcp-nsc-lfn.cc' + + obj = bld.create_ns3_program('tcp-nsc-zoo', + ['csma', 'internet-stack']) + obj.source = 'tcp-nsc-zoo.cc' + + obj = bld.create_ns3_program('tcp-star-server', + ['point-to-point', 'internet-stack']) + obj.source = 'tcp-star-server.cc' + + obj = bld.create_ns3_program('star', + ['point-to-point', 'internet-stack']) + obj.source = 'star.cc' diff --git a/examples/virtual-net-device.cc b/examples/tunneling/virtual-net-device.cc similarity index 100% rename from examples/virtual-net-device.cc rename to examples/tunneling/virtual-net-device.cc diff --git a/examples/tunneling/waf b/examples/tunneling/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/tunneling/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/tunneling/wscript b/examples/tunneling/wscript new file mode 100644 index 000000000..0ace2d5c6 --- /dev/null +++ b/examples/tunneling/wscript @@ -0,0 +1,6 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('virtual-net-device', ['point-to-point', 'internet-stack', 'global-routing', + 'virtual-net-device']) + obj.source = 'virtual-net-device.cc' diff --git a/examples/first.cc b/examples/tutorial/first.cc similarity index 100% rename from examples/first.cc rename to examples/tutorial/first.cc diff --git a/examples/first.py b/examples/tutorial/first.py similarity index 100% rename from examples/first.py rename to examples/tutorial/first.py diff --git a/examples/hello-simulator.cc b/examples/tutorial/hello-simulator.cc similarity index 100% rename from examples/hello-simulator.cc rename to examples/tutorial/hello-simulator.cc diff --git a/examples/second.cc b/examples/tutorial/second.cc similarity index 100% rename from examples/second.cc rename to examples/tutorial/second.cc diff --git a/examples/third.cc b/examples/tutorial/third.cc similarity index 100% rename from examples/third.cc rename to examples/tutorial/third.cc diff --git a/examples/tutorial/waf b/examples/tutorial/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/tutorial/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/tutorial/wscript b/examples/tutorial/wscript new file mode 100644 index 000000000..590a75c22 --- /dev/null +++ b/examples/tutorial/wscript @@ -0,0 +1,14 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('hello-simulator') + obj.source = 'hello-simulator.cc' + + obj = bld.create_ns3_program('first', ['core', 'simulator', 'point-to-point', 'internet-stack']) + obj.source = 'first.cc' + + obj = bld.create_ns3_program('second', ['core', 'simulator', 'point-to-point', 'csma', 'internet-stack']) + obj.source = 'second.cc' + + obj = bld.create_ns3_program('third', ['core', 'simulator', 'point-to-point', 'csma', 'wifi', 'internet-stack']) + obj.source = 'third.cc' diff --git a/examples/udp-echo.cc b/examples/udp/udp-echo.cc similarity index 100% rename from examples/udp-echo.cc rename to examples/udp/udp-echo.cc diff --git a/examples/udp/waf b/examples/udp/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/udp/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/udp/wscript b/examples/udp/wscript new file mode 100644 index 000000000..ede60f5bb --- /dev/null +++ b/examples/udp/wscript @@ -0,0 +1,5 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('udp-echo', ['csma', 'internet-stack']) + obj.source = 'udp-echo.cc' diff --git a/examples/mixed-wireless.cc b/examples/wireless/mixed-wireless.cc similarity index 100% rename from examples/mixed-wireless.cc rename to examples/wireless/mixed-wireless.cc diff --git a/examples/mixed-wireless.py b/examples/wireless/mixed-wireless.py similarity index 100% rename from examples/mixed-wireless.py rename to examples/wireless/mixed-wireless.py diff --git a/examples/multirate.cc b/examples/wireless/multirate.cc similarity index 100% rename from examples/multirate.cc rename to examples/wireless/multirate.cc diff --git a/examples/simple-wifi-frame-aggregation.cc b/examples/wireless/simple-wifi-frame-aggregation.cc similarity index 100% rename from examples/simple-wifi-frame-aggregation.cc rename to examples/wireless/simple-wifi-frame-aggregation.cc diff --git a/examples/wireless/waf b/examples/wireless/waf new file mode 100755 index 000000000..941d56b43 --- /dev/null +++ b/examples/wireless/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/examples/wifi-adhoc.cc b/examples/wireless/wifi-adhoc.cc similarity index 100% rename from examples/wifi-adhoc.cc rename to examples/wireless/wifi-adhoc.cc diff --git a/examples/wifi-ap.cc b/examples/wireless/wifi-ap.cc similarity index 100% rename from examples/wifi-ap.cc rename to examples/wireless/wifi-ap.cc diff --git a/examples/wifi-ap.py b/examples/wireless/wifi-ap.py similarity index 100% rename from examples/wifi-ap.py rename to examples/wireless/wifi-ap.py diff --git a/examples/wifi-clear-channel-cmu.cc b/examples/wireless/wifi-clear-channel-cmu.cc similarity index 100% rename from examples/wifi-clear-channel-cmu.cc rename to examples/wireless/wifi-clear-channel-cmu.cc diff --git a/examples/wireless/wifi-simple-adhoc-grid.cc b/examples/wireless/wifi-simple-adhoc-grid.cc new file mode 100644 index 000000000..a9c367d1d --- /dev/null +++ b/examples/wireless/wifi-simple-adhoc-grid.cc @@ -0,0 +1,239 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 University of Washington + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +// +// This program configures a grid (default 5x5) of nodes on an +// 802.11b physical layer, with +// 802.11b NICs in adhoc mode, and by default, sends one packet of 1000 +// (application) bytes to node 1. +// +// The default layout is like this, on a 2-D grid. +// +// n20 n21 n22 n23 n24 +// n15 n16 n17 n18 n19 +// n10 n11 n12 n13 n14 +// n5 n6 n7 n8 n9 +// n0 n1 n2 n3 n4 +// +// the layout is affected by the parameters given to GridPositionAllocator; +// by default, GridWidth is 5 and numNodes is 25.. +// +// There are a number of command-line options available to control +// the default behavior. The list of available command-line options +// can be listed with the following command: +// ./waf --run "scratch/wifi-simple-adhoc-grid --help" +// +// Note that all ns-3 attributes (not just the ones exposed in the below +// script) can be changed at command line; see the ns-3 documentation. +// +// For instance, for this configuration, the physical layer will +// stop successfully receiving packets when distance increases beyond +// the default of 500m. +// To see this effect, try running: +// +// ./waf --run "scratch/wifi-simple-adhoc --distance=500" +// ./waf --run "scratch/wifi-simple-adhoc --distance=1000" +// ./waf --run "scratch/wifi-simple-adhoc --distance=1500" +// +// The source node and sink node can be changed like this: +// +// ./waf --run "scratch/wifi-simple-adhoc --sourceNode=20 --sinkNode=10" +// +// This script can also be helpful to put the Wifi layer into verbose +// logging mode; this command will turn on all wifi logging: +// +// ./waf --run "scratch/wifi-simple-adhoc-grid --verbose=1" +// +// By default, trace file writing is off-- to enable it, try: +// ./waf --run "scratch/wifi-simple-adhoc-grid --tracing=1" +// +// When you are done tracing, you will notice many pcap trace files +// in your directory. If you have tcpdump installed, you can try this: +// +// tcpdump -r wifi-simple-adhoc-grid-0-0.pcap -nn -tt +// + +#include "ns3/core-module.h" +#include "ns3/common-module.h" +#include "ns3/node-module.h" +#include "ns3/helper-module.h" +#include "ns3/mobility-module.h" +#include "ns3/contrib-module.h" +#include "ns3/wifi-module.h" + +#include +#include +#include +#include + +NS_LOG_COMPONENT_DEFINE ("WifiSimpleAdhocGrid"); + +using namespace ns3; + +void ReceivePacket (Ptr socket) +{ + NS_LOG_UNCOND ("Received one packet!"); +} + +static void GenerateTraffic (Ptr socket, uint32_t pktSize, + uint32_t pktCount, Time pktInterval ) +{ + if (pktCount > 0) + { + socket->Send (Create (pktSize)); + Simulator::Schedule (pktInterval, &GenerateTraffic, + socket, pktSize,pktCount-1, pktInterval); + } + else + { + socket->Close (); + } +} + + +int main (int argc, char *argv[]) +{ + std::string phyMode ("wifib-1mbs"); + double distance = 500; // m + uint32_t packetSize = 1000; // bytes + uint32_t numPackets = 1; + uint32_t numNodes = 25; // by default, 5x5 + uint32_t sinkNode = 0; + uint32_t sourceNode = 24; + double interval = 1.0; // seconds + bool verbose = false; + bool tracing = false; + + CommandLine cmd; + + cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode); + cmd.AddValue ("distance", "distance (m)", distance); + cmd.AddValue ("packetSize", "size of application packet sent", packetSize); + cmd.AddValue ("numPackets", "number of packets generated", numPackets); + cmd.AddValue ("interval", "interval (seconds) between packets", interval); + cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose); + cmd.AddValue ("tracing", "turn on ascii and pcap tracing", tracing); + cmd.AddValue ("numNodes", "number of nodes", numNodes); + cmd.AddValue ("sinkNode", "Receiver node number", sinkNode); + cmd.AddValue ("sourceNode", "Sender node number", sourceNode); + + cmd.Parse (argc, argv); + // Convert to time object + Time interPacketInterval = Seconds (interval); + + // disable fragmentation for frames below 2200 bytes + Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); + // turn off RTS/CTS for frames below 2200 bytes + Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200")); + // Fix non-unicast data rate to be the same as that of unicast + Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", + StringValue (phyMode)); + + NodeContainer c; + c.Create (numNodes); + + // The below set of helpers will help us to put together the wifi NICs we want + WifiHelper wifi; + if (verbose) + { + wifi.EnableLogComponents (); // Turn on all Wifi logging + } + + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + // This is one parameter that matters when using FixedRssLossModel + // set it to zero; otherwise, gain will be added + wifiPhy.Set ("RxGain", DoubleValue (-10) ); + // ns-3 support RadioTap and Prism tracing extensions for 802.11b + wifiPhy.SetPcapFormat (YansWifiPhyHelper::PCAP_FORMAT_80211_RADIOTAP); + + YansWifiChannelHelper wifiChannel ; + wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); + wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel"); + wifiPhy.SetChannel (wifiChannel.Create ()); + + // Add a non-QoS upper mac, and disable rate control + NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", + "DataMode",StringValue(phyMode), + "ControlMode",StringValue(phyMode)); + // Set it to adhoc mode + wifiMac.SetType ("ns3::AdhocWifiMac"); + NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c); + + MobilityHelper mobility; + mobility.SetPositionAllocator ("ns3::GridPositionAllocator", + "MinX", DoubleValue (0.0), + "MinY", DoubleValue (0.0), + "DeltaX", DoubleValue (distance), + "DeltaY", DoubleValue (distance), + "GridWidth", UintegerValue (5), + "LayoutType", StringValue ("RowFirst")); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (c); + + // Enable OLSR + OlsrHelper olsr; + Ipv4StaticRoutingHelper staticRouting; + + Ipv4ListRoutingHelper list; + list.Add (staticRouting, 0); + list.Add (olsr, 10); + + InternetStackHelper internet; + internet.SetRoutingHelper (list); + internet.Install (c); + + Ipv4AddressHelper ipv4; + NS_LOG_INFO ("Assign IP Addresses."); + ipv4.SetBase ("10.1.1.0", "255.255.255.0"); + Ipv4InterfaceContainer i = ipv4.Assign (devices); + + TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); + Ptr recvSink = Socket::CreateSocket (c.Get (0), tid); + InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80); + recvSink->Bind (local); + recvSink->SetRecvCallback (MakeCallback (&ReceivePacket)); + + Ptr source = Socket::CreateSocket (c.Get (sourceNode), tid); + InetSocketAddress remote = InetSocketAddress (i.GetAddress (sinkNode, 0), 80); + source->Connect (remote); + + if (tracing == true) + { + wifiPhy.EnablePcap ("wifi-simple-adhoc-grid", devices); + std::ofstream ascii; + ascii.open ("wifi-simple-adhoc-grid.tr"); + YansWifiPhyHelper::EnableAsciiAll (ascii); + // To do-- enable an IP-level trace that shows forwarding events only + } + + // Give OLSR time to converge-- 30 seconds perhaps + Simulator::Schedule (Seconds (30.0), &GenerateTraffic, + source, packetSize, numPackets, interPacketInterval); + + // Output what we are doing + NS_LOG_UNCOND ("Testing from node " << sourceNode << " to " << sinkNode << " with grid distance " << distance); + + Simulator::Stop (Seconds (32.0)); + Simulator::Run (); + Simulator::Destroy (); + + return 0; +} + diff --git a/examples/wireless/wifi-simple-adhoc.cc b/examples/wireless/wifi-simple-adhoc.cc new file mode 100644 index 000000000..0a2dcbd79 --- /dev/null +++ b/examples/wireless/wifi-simple-adhoc.cc @@ -0,0 +1,198 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 The Boeing Company + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +// +// This script configures two nodes on an 802.11b physical layer, with +// 802.11b NICs in adhoc mode, and by default, sends one packet of 1000 +// (application) bytes to the other node. The physical layer is configured +// to receive at a fixed RSS (regardless of the distance and transmit +// power); therefore, changing position of the nodes has no effect. +// +// There are a number of command-line options available to control +// the default behavior. The list of available command-line options +// can be listed with the following command: +// ./waf --run "scratch/wifi-simple-adhoc --help" +// +// For instance, for this configuration, the physical layer will +// stop successfully receiving packets when rss drops below -97 dBm. +// To see this effect, try running: +// +// ./waf --run "scratch/wifi-simple-adhoc --rss=-97 --numPackets=20" +// ./waf --run "scratch/wifi-simple-adhoc --rss=-98 --numPackets=20" +// ./waf --run "scratch/wifi-simple-adhoc --rss=-99 --numPackets=20" +// +// Note that all ns-3 attributes (not just the ones exposed in the below +// script) can be changed at command line; see the documentation. +// +// This script can also be helpful to put the Wifi layer into verbose +// logging mode; this command will turn on all wifi logging: +// +// ./waf --run "scratch/wifi-simple-adhoc --verbose=1" +// +// When you are done, you will notice two pcap trace files in your directory. +// If you have tcpdump installed, you can try this: +// +// tcpdump -r wifi-simple-adhoc-0-0.pcap -nn -tt +// + +#include "ns3/core-module.h" +#include "ns3/common-module.h" +#include "ns3/node-module.h" +#include "ns3/helper-module.h" +#include "ns3/mobility-module.h" +#include "ns3/contrib-module.h" +#include "ns3/wifi-module.h" + +#include +#include +#include +#include + +NS_LOG_COMPONENT_DEFINE ("WifiSimpleAdhoc"); + +using namespace ns3; + +void ReceivePacket (Ptr socket) +{ + NS_LOG_UNCOND ("Received one packet!"); +} + +static void GenerateTraffic (Ptr socket, uint32_t pktSize, + uint32_t pktCount, Time pktInterval ) +{ + if (pktCount > 0) + { + socket->Send (Create (pktSize)); + Simulator::Schedule (pktInterval, &GenerateTraffic, + socket, pktSize,pktCount-1, pktInterval); + } + else + { + socket->Close (); + } +} + + +int main (int argc, char *argv[]) +{ + std::string phyMode ("wifib-1mbs"); + double rss = -80; // -dBm + uint32_t packetSize = 1000; // bytes + uint32_t numPackets = 1; + double interval = 1.0; // seconds + bool verbose = false; + + CommandLine cmd; + + cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode); + cmd.AddValue ("rss", "received signal strength", rss); + cmd.AddValue ("packetSize", "size of application packet sent", packetSize); + cmd.AddValue ("numPackets", "number of packets generated", numPackets); + cmd.AddValue ("interval", "interval (seconds) between packets", interval); + cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose); + + cmd.Parse (argc, argv); + // Convert to time object + Time interPacketInterval = Seconds (interval); + + // disable fragmentation for frames below 2200 bytes + Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); + // turn off RTS/CTS for frames below 2200 bytes + Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200")); + // Fix non-unicast data rate to be the same as that of unicast + Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", + StringValue (phyMode)); + + NodeContainer c; + c.Create (2); + + // The below set of helpers will help us to put together the wifi NICs we want + WifiHelper wifi; + if (verbose) + { + wifi.EnableLogComponents (); // Turn on all Wifi logging + } + wifi.SetStandard (WIFI_PHY_STANDARD_80211b); + + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + // This is one parameter that matters when using FixedRssLossModel + // set it to zero; otherwise, gain will be added + wifiPhy.Set ("RxGain", DoubleValue (0) ); + // ns-3 support RadioTap and Prism tracing extensions for 802.11b + wifiPhy.SetPcapFormat (YansWifiPhyHelper::PCAP_FORMAT_80211_RADIOTAP); + + YansWifiChannelHelper wifiChannel ; + wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); + // The below FixedRssLossModel will cause the rss to be fixed regardless + // of the distance between the two stations, and the transmit power + wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss)); + wifiPhy.SetChannel (wifiChannel.Create ()); + + // Add a non-QoS upper mac, and disable rate control + NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", + "DataMode",StringValue(phyMode), + "ControlMode",StringValue(phyMode)); + // Set it to adhoc mode + wifiMac.SetType ("ns3::AdhocWifiMac"); + NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c); + + // Note that with FixedRssLossModel, the positions below are not + // used for received signal strength. + MobilityHelper mobility; + Ptr positionAlloc = CreateObject (); + positionAlloc->Add (Vector (0.0, 0.0, 0.0)); + positionAlloc->Add (Vector (5.0, 0.0, 0.0)); + mobility.SetPositionAllocator (positionAlloc); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (c); + + InternetStackHelper internet; + internet.Install (c); + + Ipv4AddressHelper ipv4; + NS_LOG_INFO ("Assign IP Addresses."); + ipv4.SetBase ("10.1.1.0", "255.255.255.0"); + Ipv4InterfaceContainer i = ipv4.Assign (devices); + + TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); + Ptr recvSink = Socket::CreateSocket (c.Get (0), tid); + InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80); + recvSink->Bind (local); + recvSink->SetRecvCallback (MakeCallback (&ReceivePacket)); + + Ptr source = Socket::CreateSocket (c.Get (1), tid); + InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80); + source->Connect (remote); + + // Tracing + wifiPhy.EnablePcap ("wifi-simple-adhoc", devices); + + // Output what we are doing + NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss ); + + Simulator::Schedule (Seconds (1.0), &GenerateTraffic, + source, packetSize, numPackets, interPacketInterval); + + Simulator::Run (); + Simulator::Destroy (); + + return 0; +} + diff --git a/examples/wireless/wifi-simple-infra.cc b/examples/wireless/wifi-simple-infra.cc new file mode 100644 index 000000000..5422f6a84 --- /dev/null +++ b/examples/wireless/wifi-simple-infra.cc @@ -0,0 +1,212 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 The Boeing Company + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +// +// This script configures two nodes on an 802.11b physical layer, with +// 802.11b NICs in infrastructure mode, and by default, the station sends +// one packet of 1000 (application) bytes to the access point. The +// physical layer is configured +// to receive at a fixed RSS (regardless of the distance and transmit +// power); therefore, changing position of the nodes has no effect. +// +// There are a number of command-line options available to control +// the default behavior. The list of available command-line options +// can be listed with the following command: +// ./waf --run "scratch/wifi-simple-infra --help" +// +// For instance, for this configuration, the physical layer will +// stop successfully receiving packets when rss drops below -97 dBm. +// To see this effect, try running: +// +// ./waf --run "scratch/wifi-simple-infra --rss=-97 --numPackets=20" +// ./waf --run "scratch/wifi-simple-infra --rss=-98 --numPackets=20" +// ./waf --run "scratch/wifi-simple-infra --rss=-99 --numPackets=20" +// +// Note that all ns-3 attributes (not just the ones exposed in the below +// script) can be changed at command line; see the documentation. +// +// This script can also be helpful to put the Wifi layer into verbose +// logging mode; this command will turn on all wifi logging: +// +// ./waf --run "scratch/wifi-simple-infra --verbose=1" +// +// When you are done, you will notice two pcap trace files in your directory. +// If you have tcpdump installed, you can try this: +// +// tcpdump -r wifi-simple-infra-0-0.pcap -nn -tt +// + +#include "ns3/core-module.h" +#include "ns3/common-module.h" +#include "ns3/node-module.h" +#include "ns3/helper-module.h" +#include "ns3/mobility-module.h" +#include "ns3/contrib-module.h" +#include "ns3/wifi-module.h" + +#include +#include +#include +#include + +NS_LOG_COMPONENT_DEFINE ("WifiSimpleInfra"); + +using namespace ns3; + +void ReceivePacket (Ptr socket) +{ + NS_LOG_UNCOND ("Received one packet!"); +} + +static void GenerateTraffic (Ptr socket, uint32_t pktSize, + uint32_t pktCount, Time pktInterval ) +{ + if (pktCount > 0) + { + socket->Send (Create (pktSize)); + Simulator::Schedule (pktInterval, &GenerateTraffic, + socket, pktSize,pktCount-1, pktInterval); + } + else + { + socket->Close (); + } +} + + +int main (int argc, char *argv[]) +{ + std::string phyMode ("wifib-1mbs"); + double rss = -80; // -dBm + uint32_t packetSize = 1000; // bytes + uint32_t numPackets = 1; + double interval = 1.0; // seconds + bool verbose = false; + + CommandLine cmd; + + cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode); + cmd.AddValue ("rss", "received signal strength", rss); + cmd.AddValue ("packetSize", "size of application packet sent", packetSize); + cmd.AddValue ("numPackets", "number of packets generated", numPackets); + cmd.AddValue ("interval", "interval (seconds) between packets", interval); + cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose); + + cmd.Parse (argc, argv); + // Convert to time object + Time interPacketInterval = Seconds (interval); + + // disable fragmentation for frames below 2200 bytes + Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); + // turn off RTS/CTS for frames below 2200 bytes + Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200")); + // Fix non-unicast data rate to be the same as that of unicast + Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", + StringValue (phyMode)); + + NodeContainer c; + c.Create (2); + + // The below set of helpers will help us to put together the wifi NICs we want + WifiHelper wifi; + if (verbose) + { + wifi.EnableLogComponents (); // Turn on all Wifi logging + } + wifi.SetStandard (WIFI_PHY_STANDARD_80211b); + + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + // This is one parameter that matters when using FixedRssLossModel + // set it to zero; otherwise, gain will be added + wifiPhy.Set ("RxGain", DoubleValue (0) ); + // ns-3 support RadioTap and Prism tracing extensions for 802.11b + wifiPhy.SetPcapFormat (YansWifiPhyHelper::PCAP_FORMAT_80211_RADIOTAP); + + YansWifiChannelHelper wifiChannel ; + wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); + // The below FixedRssLossModel will cause the rss to be fixed regardless + // of the distance between the two stations, and the transmit power + wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss)); + wifiPhy.SetChannel (wifiChannel.Create ()); + + // Add a non-QoS upper mac, and disable rate control + NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", + "DataMode",StringValue(phyMode), + "ControlMode",StringValue(phyMode)); + + // Setup the rest of the upper mac + Ssid ssid = Ssid ("wifi-default"); + // setup sta. + wifiMac.SetType ("ns3::NqstaWifiMac", + "Ssid", SsidValue (ssid), + "ActiveProbing", BooleanValue (false)); + NetDeviceContainer staDevice = wifi.Install (wifiPhy, wifiMac, c.Get(0)); + NetDeviceContainer devices = staDevice; + // setup ap. + wifiMac.SetType ("ns3::NqapWifiMac", "Ssid", SsidValue (ssid), + "BeaconGeneration", BooleanValue (true), + "BeaconInterval", TimeValue (Seconds (2.5))); + NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, c.Get(1)); + devices.Add (apDevice); + + // Note that with FixedRssLossModel, the positions below are not + // used for received signal strength. + MobilityHelper mobility; + Ptr positionAlloc = CreateObject (); + positionAlloc->Add (Vector (0.0, 0.0, 0.0)); + positionAlloc->Add (Vector (5.0, 0.0, 0.0)); + mobility.SetPositionAllocator (positionAlloc); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (c); + + InternetStackHelper internet; + internet.Install (c); + + Ipv4AddressHelper ipv4; + NS_LOG_INFO ("Assign IP Addresses."); + ipv4.SetBase ("10.1.1.0", "255.255.255.0"); + Ipv4InterfaceContainer i = ipv4.Assign (devices); + + TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); + Ptr recvSink = Socket::CreateSocket (c.Get (0), tid); + InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80); + recvSink->Bind (local); + recvSink->SetRecvCallback (MakeCallback (&ReceivePacket)); + + Ptr source = Socket::CreateSocket (c.Get (1), tid); + InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80); + source->Connect (remote); + + // Tracing + wifiPhy.EnablePcap ("wifi-simple-infra", devices); + + // Output what we are doing + NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss ); + + Simulator::Schedule (Seconds (1.0), &GenerateTraffic, + source, packetSize, numPackets, interPacketInterval); + + Simulator::Stop (Seconds (30.0)); + Simulator::Run (); + Simulator::Destroy (); + + return 0; +} + diff --git a/examples/wireless/wifi-simple-interference.cc b/examples/wireless/wifi-simple-interference.cc new file mode 100644 index 000000000..93d2d98e4 --- /dev/null +++ b/examples/wireless/wifi-simple-interference.cc @@ -0,0 +1,259 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 The Boeing Company + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +// +// This script configures three nodes on an 802.11b physical layer, with +// 802.11b NICs in adhoc mode. There is a transmitter, receiver, and +// interferer. The transmitter sends one packet to the receiver and +// the receiver receives it with a certain configurable RSS (by default, +// -80 dBm). The interferer does not do carrier sense and also sends +// the packet to interfere with the primary packet. The channel model +// is clear channel. +// +// Therefore, at the receiver, the reception looks like this: +// +// ------------------time----------------> +// t0 +// +// |------------------------------------| +// | | +// | primary received frame (time t0) | +// | | +// |------------------------------------| +// +// +// t1 +// |-----------------------------------| +// | | +// | interfering frame (time t1) | +// | | +// |-----------------------------------| +// +// The orientation is: +// n2 ---------> n0 <---------- n1 +// interferer receiver transmitter +// +// The configurable parameters are: +// - Prss (primary rss) (-80 dBm default) +// - Irss (interfering rss) (-95 dBm default) +// - delta (microseconds, (t1-t0), may be negative, default 0) +// - PpacketSize (primary packet size) (bytes, default 1000) +// - IpacketSize (interferer packet size) (bytes, default 1000) +// +// For instance, for this configuration, the interfering frame arrives +// at -90 dBm with a time offset of 3.2 microseconds: +// +// ./waf --run "scratch/wifi-simple-interference --Irss=-90 --delta=3.2" +// +// Note that all ns-3 attributes (not just the ones exposed in the below +// script) can be changed at command line; see the documentation. +// +// This script can also be helpful to put the Wifi layer into verbose +// logging mode; this command will turn on all wifi logging: +// +// ./waf --run "scratch/wifi-simple-interference --verbose=1" +// +// When you are done, you will notice a pcap trace file in your directory. +// If you have tcpdump installed, you can try this: +// +// tcpdump -r wifi-simple-interference-0-0.pcap -nn -tt +// reading from file wifi-simple-interference-0-0.pcap, link-type IEEE802_11_RADIO (802.11 plus BSD radio information header) +// 10.008704 10008704us tsft 1.0 Mb/s 2437 MHz (0x00c0) -80dB signal -98dB noise IP 10.1.1.2.49153 > 10.1.1.255.80: UDP, length 1000 +// +// Next, try this command and look at the tcpdump-- you should see two packets +// that are no longer interfering: +// ./waf --run "wifi-simple-interference --delta=30000" + +#include "ns3/core-module.h" +#include "ns3/common-module.h" +#include "ns3/node-module.h" +#include "ns3/helper-module.h" +#include "ns3/mobility-module.h" +#include "ns3/contrib-module.h" +#include "ns3/wifi-module.h" + +#include +#include +#include +#include + +NS_LOG_COMPONENT_DEFINE ("WifiSimpleInterference"); + +using namespace ns3; + +void ReceivePacket (Ptr socket) +{ + Address addr; + socket->GetSockName (addr); + InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr); + NS_LOG_UNCOND ("Received one packet! Socket: " << iaddr.GetIpv4 () << " port: " << iaddr.GetPort ()); +} + +static void GenerateTraffic (Ptr socket, uint32_t pktSize, + uint32_t pktCount, Time pktInterval ) +{ + if (pktCount > 0) + { + socket->Send (Create (pktSize)); + Simulator::Schedule (pktInterval, &GenerateTraffic, + socket, pktSize,pktCount-1, pktInterval); + } + else + { + socket->Close (); + } +} + + +int main (int argc, char *argv[]) +{ +// LogComponentEnable ("InterferenceHelper", LOG_LEVEL_ALL); + + std::string phyMode ("wifib-1mbs"); + double Prss = -80; // -dBm + double Irss = -95; // -dBm + double delta = 0; // microseconds + uint32_t PpacketSize = 1000; // bytes + uint32_t IpacketSize = 1000; // bytes + bool verbose = false; + + // these are not command line arguments for this version + uint32_t numPackets = 1; + double interval = 1.0; // seconds + double startTime = 10.0; // seconds + double distanceToRx = 100.0; // meters + + double offset = 91; // This is a magic number used to set the + // transmit power, based on other configuration + CommandLine cmd; + + cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode); + cmd.AddValue ("Prss", "Intended primary received signal strength (dBm)", Prss); + cmd.AddValue ("Irss", "Intended interfering received signal strength (dBm)", Irss); + cmd.AddValue ("delta", "time offset (microseconds) for interfering signal", delta); + cmd.AddValue ("PpacketSize", "size of application packet sent", PpacketSize); + cmd.AddValue ("IpacketSize", "size of interfering packet sent", IpacketSize); + cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose); + + cmd.Parse (argc, argv); + // Convert to time object + Time interPacketInterval = Seconds (interval); + + // disable fragmentation for frames below 2200 bytes + Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); + // turn off RTS/CTS for frames below 2200 bytes + Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200")); + // Fix non-unicast data rate to be the same as that of unicast + Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", + StringValue (phyMode)); + + NodeContainer c; + c.Create (3); + + // The below set of helpers will help us to put together the wifi NICs we want + WifiHelper wifi; + if (verbose) + { + wifi.EnableLogComponents (); // Turn on all Wifi logging + } + wifi.SetStandard (WIFI_PHY_STANDARD_80211b); + + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + // This is one parameter that matters when using FixedRssLossModel + // set it to zero; otherwise, gain will be added + wifiPhy.Set ("RxGain", DoubleValue (0) ); + wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0) ); + + // ns-3 support RadioTap and Prism tracing extensions for 802.11b + wifiPhy.SetPcapFormat (YansWifiPhyHelper::PCAP_FORMAT_80211_RADIOTAP); + + YansWifiChannelHelper wifiChannel ; + wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); + wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel"); + wifiPhy.SetChannel (wifiChannel.Create ()); + + // Add a non-QoS upper mac, and disable rate control + NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", + "DataMode",StringValue(phyMode), + "ControlMode",StringValue(phyMode)); + // Set it to adhoc mode + wifiMac.SetType ("ns3::AdhocWifiMac"); + NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c.Get (0)); + // This will disable these sending devices from detecting a signal + // so that they do not backoff + wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (0.0) ); + wifiPhy.Set ("TxGain", DoubleValue (offset + Prss) ); + devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (1))); + wifiPhy.Set ("TxGain", DoubleValue (offset + Irss) ); + devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (2))); + + // Note that with FixedRssLossModel, the positions below are not + // used for received signal strength. + MobilityHelper mobility; + Ptr positionAlloc = CreateObject (); + positionAlloc->Add (Vector (0.0, 0.0, 0.0)); + positionAlloc->Add (Vector (distanceToRx, 0.0, 0.0)); + positionAlloc->Add (Vector (-1*distanceToRx, 0.0, 0.0)); + mobility.SetPositionAllocator (positionAlloc); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (c); + + InternetStackHelper internet; + internet.Install (c); + + Ipv4AddressHelper ipv4; + NS_LOG_INFO ("Assign IP Addresses."); + ipv4.SetBase ("10.1.1.0", "255.255.255.0"); + Ipv4InterfaceContainer i = ipv4.Assign (devices); + + TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); + Ptr recvSink = Socket::CreateSocket (c.Get (0), tid); + InetSocketAddress local = InetSocketAddress (Ipv4Address("10.1.1.1"), 80); + recvSink->Bind (local); + recvSink->SetRecvCallback (MakeCallback (&ReceivePacket)); + + Ptr source = Socket::CreateSocket (c.Get (1), tid); + InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80); + source->Connect (remote); + + // Interferer will send to a different port; we will not see a + // "Received packet" message + Ptr interferer = Socket::CreateSocket (c.Get (2), tid); + InetSocketAddress interferingAddr = InetSocketAddress (Ipv4Address ("255.255.255.255"), 49000); + interferer->Connect (interferingAddr); + + // Tracing + wifiPhy.EnablePcap ("wifi-simple-interference", devices.Get (0)); + + // Output what we are doing + NS_LOG_UNCOND ("Primary packet RSS=" << Prss << " dBm and interferer RSS=" << Irss << " dBm at time offset=" << delta << " ms"); + + Simulator::Schedule (Seconds (startTime), &GenerateTraffic, + source, PpacketSize, numPackets, interPacketInterval); + + Simulator::Schedule (Seconds (startTime + delta/1000000.0), &GenerateTraffic, + interferer, IpacketSize, numPackets, interPacketInterval); + + Simulator::Run (); + Simulator::Destroy (); + + return 0; +} + diff --git a/examples/wifi-wired-bridging.cc b/examples/wireless/wifi-wired-bridging.cc similarity index 100% rename from examples/wifi-wired-bridging.cc rename to examples/wireless/wifi-wired-bridging.cc diff --git a/examples/wireless/wscript b/examples/wireless/wscript new file mode 100644 index 000000000..bcb45f2ab --- /dev/null +++ b/examples/wireless/wscript @@ -0,0 +1,36 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('mixed-wireless', ['core', 'simulator', 'mobility', 'wifi', 'point-to-point', + 'internet-stack']) + obj.source = 'mixed-wireless.cc' + + obj = bld.create_ns3_program('wifi-adhoc', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'wifi-adhoc.cc' + + obj = bld.create_ns3_program('wifi-clear-channel-cmu', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'wifi-clear-channel-cmu.cc' + + obj = bld.create_ns3_program('wifi-ap', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'wifi-ap.cc' + + obj = bld.create_ns3_program('wifi-wired-bridging', ['core', 'simulator', 'mobility', 'wifi', 'csma', 'helper', 'bridge']) + obj.source = 'wifi-wired-bridging.cc' + + obj = bld.create_ns3_program('simple-wifi-frame-aggregation', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'simple-wifi-frame-aggregation.cc' + + obj = bld.create_ns3_program('multirate', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'multirate.cc' + + obj = bld.create_ns3_program('wifi-simple-adhoc', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'wifi-simple-adhoc.cc' + + obj = bld.create_ns3_program('wifi-simple-adhoc-grid', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'wifi-simple-adhoc-grid.cc' + + obj = bld.create_ns3_program('wifi-simple-infra', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'wifi-simple-infra.cc' + + obj = bld.create_ns3_program('wifi-simple-interference', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'wifi-simple-interference.cc' diff --git a/examples/wscript b/examples/wscript index c0fb1024d..ebe1590f9 100644 --- a/examples/wscript +++ b/examples/wscript @@ -1,205 +1,21 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- def build(bld): - obj = bld.create_ns3_program('hello-simulator') - obj.source = 'hello-simulator.cc' - - obj = bld.create_ns3_program('first', - ['core', 'simulator', 'point-to-point', 'internet-stack']) - obj.source = 'first.cc' - - obj = bld.create_ns3_program('second', - ['core', 'simulator', 'point-to-point', 'csma', 'internet-stack']) - obj.source = 'second.cc' - - obj = bld.create_ns3_program('third', - ['core', 'simulator', 'point-to-point', 'csma', 'wifi', 'internet-stack']) - obj.source = 'third.cc' - - obj = bld.create_ns3_program('object-names', - ['core', 'simulator', 'csma', 'internet-stack']) - obj.source = 'object-names.cc' - - obj = bld.create_ns3_program('mixed-wireless', - ['core', 'simulator', 'mobility', 'wifi', 'point-to-point', 'internet-stack']) - obj.source = 'mixed-wireless.cc' - - obj = bld.create_ns3_program('dynamic-global-routing', - ['point-to-point', 'csma', 'internet-stack', 'global-routing']) - obj.source = 'dynamic-global-routing.cc' - - obj = bld.create_ns3_program('static-routing-slash32', - ['point-to-point', 'internet-stack', 'global-routing']) - obj.source = 'static-routing-slash32.cc' - - obj = bld.create_ns3_program('global-routing-slash32', - ['point-to-point', 'internet-stack', 'global-routing']) - obj.source = 'global-routing-slash32.cc' - - obj = bld.create_ns3_program('global-injection-slash32', - ['point-to-point', 'internet-stack', 'global-routing']) - obj.source = 'global-injection-slash32.cc' - - obj = bld.create_ns3_program('simple-global-routing', - ['point-to-point', 'internet-stack', 'global-routing']) - obj.source = 'simple-global-routing.cc' - - obj = bld.create_ns3_program('virtual-net-device', - ['point-to-point', 'internet-stack', 'global-routing', 'virtual-net-device']) - obj.source = 'virtual-net-device.cc' - - obj = bld.create_ns3_program('simple-alternate-routing', - ['point-to-point', 'internet-stack', 'global-routing']) - obj.source = 'simple-alternate-routing.cc' - - obj = bld.create_ns3_program('simple-error-model', - ['point-to-point', 'internet-stack']) - obj.source = 'simple-error-model.cc' - - obj = bld.create_ns3_program('csma-one-subnet', - ['csma', 'internet-stack']) - obj.source = 'csma-one-subnet.cc' - - obj = bld.create_ns3_program('csma-bridge', - ['bridge', 'csma', 'internet-stack']) - obj.source = 'csma-bridge.cc' - - obj = bld.create_ns3_program('csma-bridge-one-hop', - ['bridge', 'csma', 'internet-stack']) - obj.source = 'csma-bridge-one-hop.cc' - - obj = bld.create_ns3_program('udp-echo', - ['csma', 'internet-stack']) - obj.source = 'udp-echo.cc' - - obj = bld.create_ns3_program('realtime-udp-echo', - ['csma', 'internet-stack']) - obj.source = 'realtime-udp-echo.cc' - - obj = bld.create_ns3_program('csma-broadcast', - ['csma', 'internet-stack']) - obj.source = 'csma-broadcast.cc' - - obj = bld.create_ns3_program('csma-packet-socket', - ['csma', 'internet-stack']) - obj.source = 'csma-packet-socket.cc' - - obj = bld.create_ns3_program('csma-multicast', - ['csma', 'internet-stack']) - obj.source = 'csma-multicast.cc' - - obj = bld.create_ns3_program( 'mixed-global-routing', - ['point-to-point', 'internet-stack', 'global-routing' , 'csma-cd']) - obj.source = 'mixed-global-routing.cc' - - obj = bld.create_ns3_program('simple-point-to-point-olsr', - ['point-to-point', 'internet-stack', 'olsr']) - obj.source = 'simple-point-to-point-olsr.cc' - - obj = bld.create_ns3_program('nix-simple', - ['point-to-point', 'internet-stack', 'nix-vector-routing']) - obj.source = 'nix-simple.cc' - - obj = bld.create_ns3_program('nms-p2p-nix', - ['point-to-point', 'internet-stack', 'nix-vector-routing']) - obj.source = 'nms-p2p-nix.cc' - - obj = bld.create_ns3_program('tcp-large-transfer', - ['point-to-point', 'internet-stack']) - obj.source = 'tcp-large-transfer.cc' - - obj = bld.create_ns3_program('tcp-nsc-lfn', - ['point-to-point', 'internet-stack']) - obj.source = 'tcp-nsc-lfn.cc' - - obj = bld.create_ns3_program('tcp-nsc-zoo', - ['csma', 'internet-stack']) - obj.source = 'tcp-nsc-zoo.cc' - - obj = bld.create_ns3_program('tcp-star-server', - ['point-to-point', 'internet-stack']) - obj.source = 'tcp-star-server.cc' - - obj = bld.create_ns3_program('star', - ['point-to-point', 'internet-stack']) - obj.source = 'star.cc' - - obj = bld.create_ns3_program('csma-star', - ['csma', 'internet-stack']) - obj.source = 'csma-star.cc' - - obj = bld.create_ns3_program('wifi-adhoc', - ['core', 'simulator', 'mobility', 'wifi']) - obj.source = 'wifi-adhoc.cc' - - obj = bld.create_ns3_program('wifi-clear-channel-cmu', - ['core', 'simulator', 'mobility', 'wifi']) - obj.source = 'wifi-clear-channel-cmu.cc' - - obj = bld.create_ns3_program('wifi-ap', - ['core', 'simulator', 'mobility', 'wifi']) - obj.source = 'wifi-ap.cc' - - obj = bld.create_ns3_program('mesh', - ['core', 'simulator', 'mobility', 'wifi', 'mesh']) - obj.source = 'mesh.cc' - - bld.add_subdirs('stats') - - obj = bld.create_ns3_program('wifi-wired-bridging', - ['core', 'simulator', 'mobility', 'wifi', - 'csma', 'helper', 'bridge']) - obj.source = 'wifi-wired-bridging.cc' - - obj = bld.create_ns3_program('csma-raw-ip-socket', - ['csma', 'internet-stack']) - obj.source = 'csma-raw-ip-socket.cc' - - obj = bld.create_ns3_program('csma-ping', - ['csma', 'internet-stack', 'v4ping']) - obj.source = 'csma-ping.cc' - - obj = bld.create_ns3_program('test-ipv6', - ['point-to-point', 'internet-stack']) - obj.source = 'test-ipv6.cc' - - obj = bld.create_ns3_program('ping6', - ['csma', 'internet-stack']) - obj.source = 'ping6.cc' - - obj = bld.create_ns3_program('simple-routing-ping6', - ['csma', 'internet-stack']) - obj.source = 'simple-routing-ping6.cc' - - obj = bld.create_ns3_program('icmpv6-redirect', - ['csma', 'internet-stack']) - obj.source = 'icmpv6-redirect.cc' - - obj = bld.create_ns3_program('radvd', - ['csma', 'internet-stack']) - obj.source = 'radvd.cc' - - obj = bld.create_ns3_program('radvd-two-prefix', - ['csma', 'internet-stack']) - obj.source = 'radvd-two-prefix.cc' - env = bld.env_of_name('default') - if env['ENABLE_EMU']: - obj = bld.create_ns3_program('emu-udp-echo', ['emu', 'internet-stack']) - obj.source = 'emu-udp-echo.cc' - - obj = bld.create_ns3_program('emu-ping', ['emu', 'internet-stack']) - obj.source = 'emu-ping.cc' - - if env['ENABLE_TAP']: - obj = bld.create_ns3_program('tap-wifi-dumbbell', - ['wifi', 'csma', 'point-to-point', 'tap-bridge', 'internet-stack']) - obj.source = 'tap-wifi-dumbbell.cc' - - obj = bld.create_ns3_program('simple-wifi-frame-aggregation', - ['core', 'simulator', 'mobility', 'wifi']) - obj.source = 'simple-wifi-frame-aggregation.cc' - - obj = bld.create_ns3_program('multirate', - ['core', 'simulator', 'mobility', 'wifi']) - obj.source = 'multirate.cc' + if env['ENABLE_EXAMPLES']: + bld.add_subdirs('csma') + bld.add_subdirs('emulation') + bld.add_subdirs('error-model') + bld.add_subdirs('flowmon') + bld.add_subdirs('ipv6') + bld.add_subdirs('mesh') + bld.add_subdirs('naming') + bld.add_subdirs('realtime') + bld.add_subdirs('routing') + bld.add_subdirs('stats') + bld.add_subdirs('tap') + bld.add_subdirs('tcp') + bld.add_subdirs('tunneling') + bld.add_subdirs('tutorial') + bld.add_subdirs('udp') + bld.add_subdirs('wireless') diff --git a/regression/tests/test-csma-bridge.py b/regression/tests/test-csma-bridge.py index 245f5b6d1..e51c91b5c 100644 --- a/regression/tests/test-csma-bridge.py +++ b/regression/tests/test-csma-bridge.py @@ -11,4 +11,4 @@ def may_run(env, options): else: return "Python bindings not available." -pyscript = os.path.join('examples', 'csma-bridge.py') +pyscript = os.path.join('examples/csma', 'csma-bridge.py') diff --git a/samples/wscript b/samples/wscript index 075cff512..d9cea73a6 100644 --- a/samples/wscript +++ b/samples/wscript @@ -1,6 +1,10 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- def build(bld): + env = bld.env_of_name('default') + if not env['ENABLE_EXAMPLES']: + return; + obj = bld.create_ns3_program('main-attribute-value') obj.source = 'main-attribute-value.cc' diff --git a/src/test/ns3wifi/wifi-interference-test-suite.cc b/src/test/ns3wifi/wifi-interference-test-suite.cc index 1e2b2dab0..9f287ac11 100644 --- a/src/test/ns3wifi/wifi-interference-test-suite.cc +++ b/src/test/ns3wifi/wifi-interference-test-suite.cc @@ -209,7 +209,7 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs Config::Connect ("/NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/EndSync", MakeCallback (&WifiInterferenceTestCase::PrintEndSync, this)); // Tracing - wifiPhy.EnablePcap ("wifi-simple-interference", devices.Get (0)); +// wifiPhy.EnablePcap ("wifi-simple-interference", devices.Get (0)); Simulator::Schedule (Seconds (startTime), &GenerateTraffic, source, PpacketSize, numPackets, interPacketInterval); diff --git a/test.py b/test.py index 4ed6b0b6f..be2de4e43 100755 --- a/test.py +++ b/test.py @@ -43,10 +43,17 @@ interesting_config_items = [ "NS3_MODULE_PATH", "ENABLE_NSC", "ENABLE_REAL_TIME", + "ENABLE_EXAMPLES", ] ENABLE_NSC = False ENABLE_REAL_TIME = False +ENABLE_EXAMPLES = True + +# +# If the user has constrained us to run certain kinds of tests, we can tell waf +# to only build +core_kinds = ["bvt", "core", "system", "unit"] # # A list of examples to run as smoke tests just to ensure that they remain @@ -57,51 +64,76 @@ ENABLE_REAL_TIME = False # hardcoded. # example_tests = [ - ("csma-bridge", "True"), - ("csma-bridge-one-hop", "True"), - ("csma-broadcast", "True"), - ("csma-multicast", "True"), - ("csma-one-subnet", "True"), - ("csma-packet-socket", "True"), - ("csma-ping", "True"), - ("csma-raw-ip-socket", "True"), - ("csma-star", "True"), - ("dynamic-global-routing", "True"), - ("first", "True"), - ("global-injection-slash32", "True"), - ("global-routing-slash32", "True"), - ("hello-simulator", "True"), - ("icmpv6-redirect", "True"), - ("mesh", "True"), - ("mixed-global-routing", "True"), - ("mixed-wireless", "True"), - ("multirate", "False"), # takes forever to run - ("nix-simple", "True"), - ("nms-p2p-nix", "False"), # takes forever to run - ("object-names", "True"), - ("ping6", "True"), - ("radvd", "True"), - ("radvd-two-prefix", "True"), - ("realtime-udp-echo", "ENABLE_REAL_TIME == True"), - ("second", "True"), - ("simple-alternate-routing", "True"), - ("simple-error-model", "True"), - ("simple-global-routing", "True"), - ("simple-point-to-point-olsr", "True"), - ("simple-routing-ping6", "True"), - ("simple-wifi-frame-aggregation", "True"), - ("star", "True"), - ("static-routing-slash32", "True"), - ("tcp-large-transfer", "True"), - ("tcp-nsc-zoo", "ENABLE_NSC == True"), - ("tcp-star-server", "True"), - ("test-ipv6", "True"), - ("third", "True"), - ("udp-echo", "True"), - ("virtual-net-device", "True"), - ("wifi-adhoc", "False"), # takes forever to run - ("wifi-ap --verbose=0", "True"), # don't let it spew - ("wifi-wired-bridging", "True"), + ("csma/csma-bridge", "True"), + ("csma/csma-bridge-one-hop", "True"), + ("csma/csma-broadcast", "True"), + ("csma/csma-multicast", "True"), + ("csma/csma-one-subnet", "True"), + ("csma/csma-packet-socket", "True"), + ("csma/csma-ping", "True"), + ("csma/csma-raw-ip-socket", "True"), + ("csma/csma-star", "True"), + + ("emulation/emu-ping", "False"), + ("emulation/emu-udp-echo", "False"), + + ("error-model/simple-error-model", "True"), + + ("ipv6/icmpv6-redirect", "True"), + ("ipv6/ping6", "True"), + ("ipv6/radvd", "True"), + ("ipv6/radvd-two-prefix", "True"), + ("ipv6/test-ipv6", "True"), + + ("mesh/mesh", "True"), + + ("naming/object-names", "True"), + + ("realtime/realtime-udp-echo", "ENABLE_REAL_TIME == True"), + + ("routing/dynamic-global-routing", "True"), + ("routing/global-injection-slash32", "True"), + ("routing/global-routing-slash32", "True"), + ("routing/mixed-global-routing", "True"), + ("routing/nix-simple", "True"), + ("routing/nms-p2p-nix", "False"), # Takes too long to run + ("routing/simple-alternate-routing", "True"), + ("routing/simple-global-routing", "True"), + ("routing/simple-point-to-point-olsr", "True"), + ("routing/simple-routing-ping6", "True"), + ("routing/static-routing-slash32", "True"), + + ("stats/wifi-example-sim", "True"), + + ("tap/tap-wifi-dumbbell", "False"), # Requires manual configuration + + ("tcp/star", "True"), + ("tcp/tcp-star-server", "True"), + ("tcp/tcp-large-transfer", "True"), + ("tcp/tcp-nsc-lfn", "ENABLE_NSC == True"), + ("tcp/tcp-nsc-zoo", "ENABLE_NSC == True"), + ("tcp/tcp-star-server", "True"), + + ("tunneling/virtual-net-device", "True"), + + ("tutorial/first", "True"), + ("tutorial/hello-simulator", "True"), + ("tutorial/second", "True"), + ("tutorial/third", "True"), + + ("udp/udp-echo", "True"), + + ("wireless/mixed-wireless", "True"), + ("wireless/multirate", "False"), # Takes too long to run + ("wireless/simple-wifi-frame-aggregation", "True"), + ("wireless/wifi-adhoc", "False"), # Takes too long to run + ("wireless/wifi-ap --verbose=0", "True"), # Don't let it spew to stdout + ("wireless/wifi-clear-channel-cmu", "False"), # Requires specific hardware + ("wireless/wifi-simple-adhoc", "True"), + ("wireless/wifi-simple-adhoc-grid", "True"), + ("wireless/wifi-simple-infra", "True"), + ("wireless/wifi-simple-interference", "True"), + ("wireless/wifi-wired-bridging", "True"), ] # @@ -667,10 +699,28 @@ class worker_thread(threading.Thread): def run_tests(): # # Run waf to make sure that everything is built, configured and ready to go - # unless we are explicitly told not to. + # unless we are explicitly told not to. We want to be careful about causing + # our users pain while waiting for extraneous stuff to compile and link, so + # we allow users that know what they''re doing to not invoke waf at all. # - if options.nowaf == False: - proc = subprocess.Popen("./waf", shell=True) + if not options.nowaf: + + # + # If the user is running the "kinds" or "list" options, there is an + # implied dependency on the test-runner since we call that program + # if those options are selected. We will exit after processing those + # options, so if we see them, we can safely only build the test-runner. + # + # If the user has constrained us to running only a particular type of + # file, we can only ask waf to build what we know will be necessary. + # For example, if the user only wants to run BVT tests, we only have + # to build the test-runner and can ignore all of the examples. + # + if options.kinds or options.list or (len(options.constrain) and options.constrain in core_kinds): + proc = subprocess.Popen("./waf --target=test-runner", shell=True) + else: + proc = subprocess.Popen("./waf", shell=True) + proc.communicate() # @@ -746,9 +796,10 @@ def run_tests(): # This translates into allowing the following options with respect to the # suites # - # ./test,py: run all of the suites + # ./test,py: run all of the suites and examples + # ./test.py --constrain=core: run all of the suites of all kinds # ./test.py --constrain=unit: run all unit suites - # ./test,py --suite=some-test-suite: run the single suite + # ./test,py --suite=some-test-suite: run a single suite # ./test,py --example=udp-echo: run no test suites # ./test,py --suite=some-suite --example=some-example: run the single suite # @@ -873,7 +924,7 @@ def run_tests(): # # ./test,py: run all of the examples # ./test.py --constrain=unit run no examples - # ./test.py --constrain=example run all of the examples + # ./test.py --constrain=example run all of the examples # ./test,py --suite=some-test-suite: run no examples # ./test,py --example=some-example: run the single example # ./test,py --suite=some-suite --example=some-example: run the single example @@ -883,22 +934,23 @@ def run_tests(): # if len(options.suite) == 0 and len(options.example) == 0: if len(options.constrain) == 0 or options.constrain == "example": - for test, condition in example_tests: - if eval(condition) == True: - job = Job() - job.set_is_example(True) - job.set_display_name(test) - job.set_tmp_file_name("") - job.set_cwd(TMP_TRACES_DIR) - job.set_basedir(os.getcwd()) - job.set_shell_command("examples/%s" % test) + if ENABLE_EXAMPLES: + for test, condition in example_tests: + if eval(condition) == True: + job = Job() + job.set_is_example(True) + job.set_display_name(test) + job.set_tmp_file_name("") + job.set_cwd(TMP_TRACES_DIR) + job.set_basedir(os.getcwd()) + job.set_shell_command("examples/%s" % test) - if options.verbose: - print "Queue %s" % test + if options.verbose: + print "Queue %s" % test - input_queue.put(job) - jobs = jobs + 1 - total_tests = total_tests + 1 + input_queue.put(job) + jobs = jobs + 1 + total_tests = total_tests + 1 elif len(options.example): # diff --git a/utils/test-runner.cc b/utils/test-runner.cc index fc294c0ed..0c6973378 100644 --- a/utils/test-runner.cc +++ b/utils/test-runner.cc @@ -133,10 +133,11 @@ main (int argc, char *argv[]) // enum defined in test.h converted to lower case. // std::cout << " bvt: Build Verification Tests (to see if build completed successfully)" << std::endl; - std::cout << " unit: Unit Tests (within modules to check basic functionality)" << std::endl; - std::cout << " system: System Tests (spans modules to check integration of modules)" << std::endl; + std::cout << " core: Run all TestSuite-based tests (exclude examples)" << std::endl; std::cout << " example: Examples (to see if example programs run successfully)" << std::endl; std::cout << " performance: Performance Tests (check to see if the system is as fast as expected)" << std::endl; + std::cout << " system: System Tests (spans modules to check integration of modules)" << std::endl; + std::cout << " unit: Unit Tests (within modules to check basic functionality)" << std::endl; return false; } @@ -153,9 +154,10 @@ main (int argc, char *argv[]) TestSuite *suite = TestRunner::GetTestSuite (i); // - // Filter the tests listed by type if requested. + // Filter the tests listed by type if requested. The special typeName + // "core" means any TestSuite. // - if (haveType) + if (haveType && typeName != "core") { TestSuite::TestType type = suite->GetTestType (); if (typeName == "bvt" && type != TestSuite::BVT) diff --git a/wscript b/wscript index f5259f9b8..6c95f99ce 100644 --- a/wscript +++ b/wscript @@ -173,6 +173,13 @@ def set_options(opt): help=('Use sudo to setup suid bits on ns3 executables.'), dest='enable_sudo', action='store_true', default=False) + opt.add_option('--enable-examples', + help=('Build the ns-3 examples and samples.'), + dest='enable_examples', action='store_true', + default=True) + opt.add_option('--disable-examples', + help=('Do not build the ns-3 examples and samples.'), + dest='enable_examples', action='store_false') opt.add_option('--regression', help=("Enable regression testing; only used for the 'check' target"), default=False, dest='regression', action="store_true") @@ -324,6 +331,16 @@ def configure(conf): conf.report_optional_feature("ENABLE_SUDO", "Use sudo to set suid bit", env['ENABLE_SUDO'], why_not_sudo) + if Options.options.enable_examples: + env['ENABLE_EXAMPLES'] = True + why_not_examples = "defaults to enabled" + else: + env['ENABLE_EXAMPLES'] = False + why_not_examples = "option --disable-examples selected" + + conf.report_optional_feature("ENABLE_EXAMPLES", "Build examples and samples", env['ENABLE_EXAMPLES'], + why_not_examples) + # we cannot pull regression traces without mercurial conf.find_program('hg', var='MERCURIAL') @@ -482,7 +499,9 @@ def build(bld): # process subfolders from here bld.add_subdirs('src') - bld.add_subdirs('samples utils examples') + bld.add_subdirs('samples') + bld.add_subdirs('utils') + bld.add_subdirs('examples') add_scratch_programs(bld) @@ -564,7 +583,12 @@ def build(bld): if not regression_traces: raise Utils.WafError("Cannot run regression tests: reference traces directory not given" " (--with-regression-traces configure option)") - regression.run_regression(bld, regression_traces) + + if env['ENABLE_EXAMPLES'] == True: + regression.run_regression(bld, regression_traces) + else: + raise Utils.WafError("Cannot run regression tests: building the ns-3 examples is not enabled" + " (regression tests are based on examples)") # if Options.options.check: # Options.options.compile_targets += ',run-tests'