воскресенье, 26 июля 2015 г.

8th Week

Hello!,

Here is small status update after the 8th week of GSoC program.

The main achievement of this week: the implementation of STrPe-DS is almost done!
1. Signature checking
2. Gathering of complains about malicious peers from the team by splitter
3. Excluding peers from the team (with trusted peers)

1. Signature checking

I've implemented the signature checking by peers: each peer construct message and then verify it with its DSA-key. Some code:

def check_message(self, message, sender):
        if sender in self.bad_peers:
            return False
        if not self.is_control_message(message):
            chunk_number, chunk, k1, k2 = struct.unpack(self.message_format, message)
            chunk_number = socket.ntohs(chunk_number)
            sign = (self.convert_to_long(k1), self.convert_to_long(k2))
            m = str(chunk_number) + str(chunk) + str(sender)
            return self.dsa_key.verify(SHA256.new(m).digest(), sign)
        return True

 

2. Gathering of complains about malicious peers from the team by splitter

In STrPe-DS splitter requests info about malicious peers from the team. I've added a new thread 'gather_bad_peers', which requests it from the team every T seconds:

def gather_bad_peers(self):
      while self.alive:
          _print_("gathering bad peers")
          if len(self.peer_list) > 0:
              peer = self.get_peer_for_gathering()
              self.request_bad_peers(peer) # then, we will handle it in 'moderate the team'
          time.sleep(self.GATHER_BAD_PEERS_SLEEP)

As you can see, here we only send request to peer, but don't handle response. We will hadle response in existing 'moderate_the_team' thread:

def process_bad_peers_message(self, message, sender):
    bad_number = struct.unpack("3sH", message)[1]
    for _ in range(bad_number):
        message, sender = self.receive_bad_peer_message()
        x = struct.unpack("ii", message)
        bad_peer = (socket.inet_ntoa(struct.pack('!L', x[0])), x[1])
        if sender in self.trusted_peers:
            _print_("bad peer: " + str(bad_peer))
            self.remove_peer(bad_peer)

First, peer sends number of bad peers in its bad_peer list. Then it sends endpoints of these bad peers one-by-one.

3. Excluding peers from the team (with trusted peers)

Now, splitter can exclude bad peers only with trusted peers. (if trusted peer marked peer as 'bad' then splitter exclude it from the team). The next task is to develop heuristic to exclude malicious peers based on the regular peers. 

To test new version of STrPe-DS you can use these commands:

$ vlc Big_Buck_Bunny_small.ogv --sout "#duplicate{dst=standard{mux=ogg,dst=,access=http}}" &
$ ./splitter.py --source_port 8080 --strpeds "127.0.0.1:56000"
$ ./peer.py --use_localhost --strpeds --port 56000
$ vlc http://localhost:9999
$ ./peer.py --use_localhost --strpeds --port 56000 --player_port 10000
$ vlc http://localhost:10000

Also, you can see all the code here.

Thanks!

Комментариев нет:

Отправить комментарий