2009/4/13 Luca Dionisi <[email protected]>:
> 2009/4/8 Luca Dionisi <[email protected]>:
>> This post is strictly intended for italian speaking people.
>> There are no relevant news for english speaking users.
>>
>> Ciao a tutti
>>
>> Di recente ho passato del tempo a studiare il codice di netsukuku per
>> provare in seguito a dare una mano più efficacemente al debugging e
>> allo sviluppo.
>>
>> Mentre studiavo il codice prendevo appunti. Il mio primo scopo era di
>> tenere una traccia per me, ma fin dall'inizio ho tenuto conto del
>> fatto che il risultato poteva essere un aiuto per altri sviluppatori
>> che si avvicinano al codice di netsukuku per la prima volta.
>>
>> La strada che ho seguito è stata quella di leggere dal svn la prima
>> versione python del codice e studiarla, e poi vedere nel tempo quali
>> modifiche sono state apportate e tenere traccia del perché.
>>
>> Qualche giorno fa ho terminato, nel senso che sono arrivato all'ultima
>> revisione del svn. Oltre a quello che avevo scritto fino allora ho
>> aggiunto una o due pagine di commento più "panoramico" sulla
>> architettura del codice.
>>
>> Ora sto trascrivendo queste annotazioni sul wiki lab.dyne.org. Per il
>> momento sono alle prime pagine, ci vorrà qualche giorno per finire di
>> trascrivere.
>>
>> Volevo sapere prima di tutto se questo uso del wiki è corretto, cioè
>> se è il posto giusto per condividere queste note.
>>
>> Chi legge queste pagine senza avere alcuna esperienza del codice di
>> netsukuku potrebbe commentare in mailing list, dicendo se
>> l'esposizione è abbastanza chiara, se è di aiuto per navigare sul
>> codice e capirlo, ecc.
>> Dagli sviluppatori sarei ben lieto di ricevere qualche autorevole
>> correzione alle mie deduzioni qualora fossero errate.
>>
>> Per il momento le pagine sono in italiano. Quando siamo sicuri che ci
>> sono informazioni corrette si può pensare di tradurle.
>>
>> La pagina iniziale è http://lab.dyne.org/Netsukuku/ita/notes
>>
>> Ribadisco ancora che mi ci vorranno alcuni giorni per finire di
>> trascrivere. Prima di correggere direttamente sul wiki i miei errori
>> lasciatemi finire, casomai commentate in mailing list.
>>
>> Grazie
>> --Luca
>>
>
> Quello che avevo di scritto l'ho finito di trascrivere sul wiki.
> Probabilmente continuero' a migliorare il contenuto, ma fin d'ora se
> qualcuno volesse aggiungere/modificare le pagine per migliorarle puo'
> farlo.
> In particolare, jnz, se vuoi dare un'occhiata alla pagina sul P2P vai pure.
>
> Ciao
> --Luca
>
Vorrei qualche commento dagli sviluppatori sulle note prese riguardo
la classe Etp.
Qui:
http://lab.dyne.org/Netsukuku/ita/ModuloQSPN
In particolare sulla parte di processazione di un ETP (etp_exec)
Vi sollecito a dare un'occhiata perché mi pare che il codice abbia
parecchi problemi. Ho anche iniziato a fare una test-suite per
verificare la correttezza delle operazioni fatte in etp_exec e vedo
risultati non corretti.
Prima di mettere mano al codice vorrei capire se sto sbagliando tutto
e il codice è in realtà funzionante ma io lo sto interpretando male.
Allego il file che uso come testsuite. Ho cercato di commentare quello
che faccio e con quale intento lo faccio, ma potrebbe non essere di
facile lettura.
--Luca
# -*- coding: iso-8859-1 -*-
##
# This file is part of Netsukuku
# (c) Copyright 2009 Luca Dionisi
#
# This source code is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
# This source code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Please refer to the GNU Public License for more details.
#
# You should have received a copy of the GNU Public License along with
# this source code; if not, write to:
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
#
# Tests for ntk.core.qspn
#
import unittest
import sys
sys.path.append('..')
############## To avoid using tasklets in the test-suite
import functools
def fake_microfunc(is_micro=False, is_atomic=False):
def decorate(func):
@functools.wraps(func)
def launch(*data):
func(*data)
return launch
return decorate
import ntk.lib.micro
ntk.lib.micro.microfunc = fake_microfunc
##################
############# To avoid using sockets in the test-suite
class fake_TCPClient:
def __init__(self,
host='localhost',
port=269,
net=None,
me=None,
sockmodgen=None,
xtimemod=None):
pass
import ntk.lib.rpc
ntk.lib.rpc.TCPClient = fake_TCPClient
###########################
import ntk.core.radar as radar
import ntk.core.route as maproute
import ntk.core.qspn as qspn
import ntk.wrap.xtime as xtime
def print_etp(etp):
print 'R ='
R = etp[0]
for i in xrange(3, -1, -1):
print ' L', i
Li = R[i]
if len(Li) == 0:
print ' Empty'
for j in xrange(len(Li)):
tuplej = Li[j]
print ' dst =', tuplej[0], ', rem =', tuplej[1].value
print 'TPL ='
TPL = etp[1]
for i in xrange(len(TPL)):
block = TPL[i]
lvl = block[0]
TP = block[1]
print ' Level', lvl
for j in xrange(len(TP)):
pair = TP[j]
hop = pair[0]
rem = pair[1]
print ' hop =', hop, ', rem =', rem.value
print 'flag_of_interest =', etp[2]
class TestEtp(unittest.TestCase):
def setUp(self):
self.levels = 4
self.gsize = 256
self.radar = radar.Radar(self, xtime) #passing self instead of bcastclient, to replace the remote calls to equivalent local methods
self.maproute = maproute.MapRoute(self.levels, self.gsize, [1, 1, 168, 192])
self.etp = qspn.Etp(self.radar, self.maproute)
def fake_etp_forward(self, etp, exclude):
print 'I will forward this ETP'
print_etp(etp)
print 'to all neighbours except',
for excluding in exclude:
print self.maproute.ip_to_nip(self.radar.neigh.id_to_ip(excluding)),
print
def fake_etp_exec(self, sender_nip, R, TPL, flag_of_interest):
print sender_nip, R, TPL, flag_of_interest
def testEtpExec(self):
'''Test etp propagation'''
# I am 192.168.1.1 and have this neighbour 192.168.1.15
self.maproute = maproute.MapRoute(self.levels, self.gsize, [1, 1, 168, 192])
ip_neigh = self.maproute.nip_to_ip([15, 1, 168, 192])
self.radar.neigh.netid_table[ip_neigh] = -1
ip_table = {}
devs_neigh = [('eth0', 123)]
ip_table[ip_neigh] = radar.Neigh(bestdev=devs_neigh[0], devs=dict(devs_neigh))
self.radar.neigh.store(ip_table)
self.radar.neigh.ntk_client[ip_neigh] = self # instead of rpc.TCPClient(ip_to_str(key), xtimemod=self.xtime)
self.etp = qspn.Etp(self.radar, self.maproute)
self.etp.etp_forward = self.fake_etp_forward
#self.etp.etp_exec = self.fake_etp_exec
print 'maproute.me'
print self.maproute.me
print 'maproute.bestroutes_get()'
print self.maproute.bestroutes_get()
# Preparing a first etp. It will "be sent" to me from my neighbour 192.168.1.15
L0 = [(4, maproute.Rtt(100))]
# This route towards host with ID 4 of level 0, that is 192.168.1.4, ...
R = [L0, [], [], []] # is the only known route for host 15.
flag_of_interest=1
TP = [(15, maproute.NullRem())] # the etp is sent to me from 192.168.1.15
first_etp = (R, [(0, TP)], flag_of_interest)
sender_nip = [15, 1, 168, 192]
print 'ETP coming from', sender_nip, ':'
print_etp(first_etp)
self.etp.etp_exec(sender_nip, *first_etp)
print 'maproute.bestroutes_get()'
print self.maproute.bestroutes_get()
if __name__ == '__main__':
unittest.main()
_______________________________________________
Netsukuku mailing list
[email protected]
http://lists.dyne.org/mailman/listinfo/netsukuku