# Simulate network

This topic is 4943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I don't know if this is the right forums but i hope so. I have this simplified computer, "node" class containing files, folders and whatnot. Now i'm wondering how i should design the network these nodes would be talking to eachother with. I've been thinking about just letting them send all packages to all other computers and just actually notify the node if it has the right adress, the con is it's very inefficient. The other thought i had would be to send the packages to a top-node that know what the ips are of the nodes in that particular network, so you would send the package to all the top-nodes. If anybody got any suggestions, ideas or comments to help me think a bit it would be appreciated.

##### Share on other sites
What problem are you trying to solve?

##### Share on other sites
I think he is discussing a way to distribute a file system across a computer network and how to reference those files without prior knowledge of where the root is.

I use a file naming scheme where the symbols $,{ and } have special meanings. Whatever is within brackets needs a variable lookup, and a$ in front means using environment variables. This is roughly the equivalent of 'sed' or 'm4' in the Unix world. For example, the file:

"${HOME}/mydocs/myapp.{EXT}" could be interpreted as "/usr/people/mike/mydocs/myapp.so" on my Linux machine and as "C:/mydocs/myapp.dll" on my PC. The '${HOME}' is replaced with the contents of the 'HOME' environment variable, and {EXT} is replaced to the proper string using some local registry lookup table.

Hope this is the right way to understand the problem.

-cb

##### Share on other sites
Apparently my first post wasn't that good so i'll make another attempt.

I have class A that is basicly a simplified computer with hdd, files and folders, programs and some other things computers have. Now i'm thinking of how to add "internet" to my simulated computer, so programs running on these computers can talk to each other thru this network.

My problem is that i don't know how to structure/design the network part. Should i have a class B that know all the ips and just send it to the correct one (lookup-time increasing with each new node) or some other strucutre?

##### Share on other sites
I assume your simulated applications have access to some form of API of your making. It's a matter of adding one more API for these application to have extended capabilities, be it socket-based communication or otherwise.

Another way would be to map devices to files, much like Unix. "/nfs/machineA" could be a communication link from the currently simulated computer to your other computer on the simulated net. Just open up the file from Node A and you'd see B's file system or something the like. As new simulations are added, the respective file systems of all the simulated computers are added a "/nfs/machine{X}" file automatically.

You could also map default files as pre-bound sockets. For example, the file "/device/mysql" could be pre-bound to your MySQL server and your simulated application could issue SQL calls in text form.

Hope this helps.

-cb

##### Share on other sites
I am terribly sorry, it seems i really can't make myself clear.

Say a program on node a runs send("foo","2.43.5") which should send "foo" to 2.43.5. What i want help with is how to design the network itself. How node a sending "foo" knows to which node out of a list {b,c,d,e} to send the packets to if they are just going to 2.43.5.

Should it send to all nodes and they only recieve it if the ip-adresses match(easy but ineffecient), or some more efficient solution?

Interesting idea with the automatic-file adding thou, will ponder on that one later, thanks alot :)

##### Share on other sites
std::hash_map<IPAddress,Computer*> seems like it would do the trick.

1. 1
Rutin
26
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631757
• Total Posts
3002135
×