Comments (27)
Although at this moment the simulator only runs teams in a host, the idea is that it should be able to spawn teams in several hosts. So, the answer is: the endpoints can be any (always using IPv4, forget IPv6).
from simulator.
Is it possible that a peer can send chunk to another peer before sending 'hello' message to it ?
from simulator.
Send, not. Receive, yes. Think about the [hello] is lost.
from simulator.
What about a method where every peer is able to calculate the ID of the other peers based on their endpoints? Maybe something like a hash function.
from simulator.
Yes, a hash function that is capable of translating the end-points of the peers to a positive integer of 7 bits, could work.
from simulator.
Can you please explain me what is the scope of this simulator. I Mean, do we want to run the simulator within a machine or between multiple machines (within the network or outside the network) ?
I'm asking this question because to make hash function we need to know address scope of end-points.
from simulator.
So for the moment should I only design the hash function for simulation within the host ? In this case, we just need to map port address to a number.
from simulator.
Not really, we need to map (IP, port) to a number (or string?).
from simulator.
How about maintaining a shared memory to store dictionary ? Can we do that
from simulator.
How about maintaining a shared memory to store dictionary ? Can we do that
Is it really needed? If we use the same "hash function" for all entities it is not necessary to share any information.
Note that I used "hash function" (between quotes) because I think that it could be something different. In our case is not mandatory to avoid (or difficulty) its reconstruction.
from simulator.
I would like that the "hash function" to generate only a 7-bits output for any input (only to have a printable character). Obviously, this has limitations (only 128 peer/team will work without collisions), but this does not matter.
What about if the splitter, when a peer is joining the team, assigns to the incoming peer a different integer id Y
and, these ids are sent with the list of peers? Thus, any peer will know the id of the rest of the peers of the team and when the buffers are printed, we only need to print Y mod 128
, where Y is mapped by a dictionary indexed by the end-points of the peers.
from simulator.
I was thinking the same but what if a new peer arrive, then how would old peer knows about its id ( as old peer are no longer connected via splitter_socket ) then i was thinking we can send that id with [Hello] message but what if [Hello] message get lost.
On simple solution could be if splitter manage all the peer ids and whenever a peer encounter a new end-point it will get its id from splitter and that peer will add this entry to its own dictionary.
from simulator.
Beside, using Hash function would be best idea.
from simulator.
[hello]'s solution (I mean, the incorporation of the ids to the [hello] messages) is OK. As I said, the peer id is only important for printing the evolution of the buffers and we can live with this drawback (the lost of [hello]s). Anyway, if needed, the id could be sent with the chunks, but I don't think so, right now.
from simulator.
A hash function could be made by defining a relation b/w 8 bits blocks of ip address (e.g. x.x.x.x ) and finally with port number as follows:
def hash(addr,port):
blk = addr.split('.')
bk = [int(x) for x in blk]
sh = bk[0]^bk[1]^bk[2]
sh = (sh + bk[3])%127
sh = (sh + port%127)%127
return sh
what do you think ?
from simulator.
I'm not sure about the operation of that function. For example, what if we have these two endpoints (192.168.2.1, 12345) and (192.168.1.2, 12345)? I guess that the same ID is assigned to both of them.
Anyway, it's a good start.
from simulator.
Yes you are right. But it is very difficult to avoid collisions because we are mapping 2^32 (4,294,967,295) addresses into 2^7 (127) address space.
I think the example you given is very least likely to happen in a local network. Because in a local network only host id change while network id remain same.
e.g.
Even though i'm looking for a better solution. :)
from simulator.
it is very difficult to avoid collisions
Yes, I agree.
Because in a local network only host id change while network id remain same
That is true, but the number of bit used by hosts will depend on the class of the network, in your example it is a Class C, so 8 bits are used for hosts. However if it is a Class B, you could use 16 bit for host instead of 8.
from simulator.
Don't you like the idea of the id's assigned by the splitter? If the id's are natural numbers, allocated sequentially (0, 1, 2, ...), collisions will appear only when more than 128 peers are in the team. Moreover, these collisions could be also convenient in the case we want to determine the sender of a chunk.
from simulator.
Don't you like the idea of the id's assigned by the splitter?
I think Splitter method would give very consistent results, and we can also give them sequential names. So representation would be nice. :-)
from simulator.
I have made following improvements to hash function:
def f(x):
return (x*x)%127
def g(x):
return (x*x*x)%127
def hash(addr):
blk = addr[0].split('.')
bk = [int(x) for x in blk]
sh = bk[0]^f(bk[1])
sh = sh^g(bk[2])
sh = (sh + f(bk[3]))%127
sh = (sh + g(addr[1]))%127
return chr(65+sh%26) + chr(48+int(sh/10)%10)
How is it ?
from simulator.
Seems to be a good hash function.
from simulator.
It looks good for me too 😄
from simulator.
Since we have only 128-32-1=95 printable character i was wondering how we would able to represent 128 peers ? 😄
from simulator.
No, it is impossible. However, it does not matter because we usually debug the buffer filling with small teams.
from simulator.
Please review my PR request .
from simulator.
fixed in #32
from simulator.
Related Issues (20)
- Add examples to README.md HOT 1
- Lost data recovery system using error correction codes
- Defining default parameters for the simulator HOT 1
- Feeding the simulator with a real source HOT 33
- Playback control for simulation visualisation HOT 1
- Peer added to the graph again even after removing from the team HOT 12
- Select colormap
- The process to send pending chunks before leaving the team freezes the peer
- PyQT/play.py KeyError when update_buffer was called
- Representation of a half-duplex or a full-duplex link.
- Missing Code in peer_sts.py file HOT 1
- Provide a argsparser to the simulator
- Peers must transmit the stream even if the player is not connected
- A peer should be able to send the chunks to more than one player
- Implementation of a streams merger
- Implementation of a splitters synchronizer
- Implementation of FCS (Free-riding Control Set)
- Implementation of a Vorbis/Theora transcoder for Multiple Description Coding
- Implementation of a Vorbis/Theora transcoder for Scalable Coding
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simulator.