Simulate network

Started by
5 comments, last by hplus0603 19 years, 3 months ago
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.
reality is only an option
Advertisement
What problem are you trying to solve?
enum Bool { True, False, FileNotFound };
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
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?
reality is only an option
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
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 :)
reality is only an option
std::hash_map<IPAddress,Computer*> seems like it would do the trick.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement