for xi in range(num_nodes_side):
for yi in range(num_nodes_side):
node = ns.network.Node()
work_nodes.append(node)
internet.Install(ns.network.NodeContainer(node))
mobility = ns.mobility.ConstantPositionMobilityModel()
mobility.SetPosition(ns.core.Vector(xi*DISTANCE, yi*DISTANCE, 0))
node.AggregateObject(mobility)
devices = wifi.Install(wifiPhy, wifiMac, node)
ipv4_interfaces = ipv4Addresses.Assign(devices)
work_addresses.append(ipv4_interfaces.GetAddress(0))
for i, node in enumerate(work_nodes):
destaddr = work_addresses[(len(work_addresses) - 1 - i) % len(work_addresses)]
#print i, destaddr
onOffHelper.SetAttribute("Remote", ns.network.AddressValue(ns.network.InetSocketAddress(destaddr, port)))
app = onOffHelper.Install(ns.network.NodeContainer(node))
urv = ns.core.UniformRandomVariable()
app.Start(ns.core.Seconds(urv.GetValue(20, 30)))
for xii in range(num_nodes_side):
for yii in range(num_nodes_side):
#create node
node = ns.network.Node()
#append node to home_nodes array
home_nodes.append(node)
#"install" internet protocols on node
internet.Install(ns.network.NodeContainer(node))
#set node positions
mobility = ns.mobility.ConstantPositionMobilityModel()
mobility.SetPosition(ns.core.Vector(xii*DISTANCE+150, yii*DISTANCE, 0))
node.AggregrateObject(mobility)
devices = wifi.Install(wifiPhy, wifiMac, node)
ipv4_interfaces = ipv4Addresses.Assign(devices)
home_addresses.append(ipv4_interfaces.GetAddress(0))
for i, node in enumerate(home_nodes):
destaddr = home_addresses[(len(home_addresses) - 1 - i) % len(home_addresses)]
#print i, destaddr
onOffHelper.SetAttribute("Remote", ns.network.AddressValue(ns.network.InetSocketAddress(destaddr, port)))
app = onOffHelper.Install(ns.network.NodeContainer(node))
urv = ns.core.UniformRandomVariable()
app.Start(ns.core.Seconds(urv.GetValue(20, 30)))
While network nodes and the applications running on them are already represented explicitly in ns-3, there isn't a notion of a person or user. This would be useful to capture the notion of one user manipulating multiple devices, such as a computer and a phone. (Two-factor authentication, anyone?). I think I would just create my own Agent class derived from Object and put the smarts there.
As for naming, look at the Names interface:
https://www.nsnam.org/docs/release/3.25/doxygen/classns3_1_1_names.html
Peter
I'm trying to create a real-time simulation (via ns3's visualizer and the --viz command). Can I actually do that from the perspective of a "graph"? I was under the assumption that in order to visualize the data transfer between devices that they would have to be created as nodes with the proper internet protocols in order to demonstrate that exchange of information with the visualizer.
As to Object, network nodes, and applications: Are you referring to the modules ns3::Object, ns3::NetDevice, and ns3::Applications respectively?
And with my visualizer goals in mind, would you recommend just deriving a class from Object or would it be more advantageous to create another module to represent an Agent / User?
Obviously you couldn't install protocols on a human, but there must be some way to demonstrate Alice or Bob's physical state as detected by whatever intermediary mobile / network device.
Thank you for pointing me to Names, that definitely answered that particular question.
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/lUtywF0qFQQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
I will create a fresh thread with a more relevant subject line. Thanks for all your help up to this point Tommaso and pdbarnes.
On Thursday, July 21, 2016 at 3:38:20 AM UTC-4, Tim Tolbert wrote:Alright so I followed the bread crumb trail of errors to a laundry list of new errors, many of which I was able to fix myself but I've still got a couple that I'm not quite sure what to do about.One is in my default constructor where I try to add a timestamp as an attribute of Entity:../../scratch/myfirstcustom.cc: In constructor ‘Entity::Entity()’:../../scratch/myfirstcustom.cc:56:18: error: invalid use of non-static member function ‘double ns3::Time::GetSeconds() const’time = Time::GetSeconds;
And the others are where I'm trying to instantiate alice and bob Users in the main method:../../scratch/myfirstcustom.cc: In function ‘int main(int, char**)’:../../scratch/myfirstcustom.cc:116:25: error: conversion from ‘User*’ to non-scalar type ‘User’ requestedUser alice = new User();
../../scratch/myfirstcustom.cc:118:34: error: expected primary-expression before ‘alice’NodeContainer::Add(Ptr< User > alice);
Hello,
I appreciate your response. I'm trying to figure out how to apply your hints to my code. What do you mean by me needing a time instance? I'm trying to create a dynamic time stamp as an attribute (in my Entity class). Is it possible to do that in a default constructor? So far I haven't found an example in the tutorials that would help me accomplish that task, so I'm kind of shooting in the dark.
As far as my "alice" node, I have it instantiated as a User (User alice;), which inherits from Entity(my two custom classes). Entity inherits from Node. I'm unable to Add to the NodeContainer using Add(Ptr <Node> alice) or by using just the name with Add(alice).
My custom classes are set up as:
class Entity : public Node {...}
and
class User : public Entity {...}
Shouldn't it be treated as a node since it inherits directly from it? Or do I need to approach it differently?
Any extra resources you could point me to or tips you could give would be highly appreciated. I do actually have a c++ tutorial open on some of my tabs as well, as I'm still learning the finer points of c++ with this project. I'll go back to the tutorials in the meantime and see if I can figure it out on my own. Thanks again.
Tim