p2ptao

Implementazione Python del protocollo TAO per comunicazione P2P, sviluppato da Giovanni Novelli.

Caratteristiche Principali

Struttura del Progetto

pytao/src/p2ptao/py/
β”œβ”€β”€ protocol/
β”‚   β”œβ”€β”€ TAOProtocol.py
β”‚   β”œβ”€β”€ TAOFSM.py
β”‚   └── pksimul.py
β”œβ”€β”€ parsing/
β”‚   └── TAOParser.py
β”œβ”€β”€ encoding/
β”‚   β”œβ”€β”€ TAOCodec.py
β”‚   └── rsa.py
β”œβ”€β”€ tunneling/
β”‚   └── (moduli di tunneling)
β”œβ”€β”€ events/
β”‚   └── TAOSkypeEvents.py
β”œβ”€β”€ logging/
β”‚   └── TAOLogger.py
└── utilities/
    └── Enumerate.py

Architettura

1. Class Diagram β€” Struttura del Sistema

Gerarchia di ereditarietΓ : BasicNode β†’ CORENode β†’ Relay/Client/Server/SkypeCommunication. CORENode funge da hub centrale collegando l'interfaccia di rete virtuale (Ethernet/TAP) con i relay fisici o Skype.

classDiagram direction TB class IBasicNode { +String Hostname +String Name +Guid GUID +CreateNode() +Run() +HandleData() } note for IBasicNode "Interface" class ICORENode { +String IP +String Netmask +UpdateAddressData() } note for ICORENode "Interface" class ISender { +Send(ICopyable data) } note for ISender "Interface" class IDataHandler { +HandleData(MemBlock b, ISender ret, object state) } note for IDataHandler "Interface" class BasicNode { #String _hostname #String _name #Guid _guid +CreateNode() +HandleData()* } note for BasicNode "Abstract class" class SimpleSource note for SimpleSource "Base class" class CORENode { #String _ip #String _netmask +Ethernet Ethernet +byte[] MACAddress +Relay _relay +CORENode(string name, string tap) +setRelay(Relay relay) +HandleData() } class Relay { +int packetLossProbability #CORENode coreNode #Stream s #StreamReader sr #StreamWriter sw +Relay(CORENode aNode) +Send(ICopyable data) #Send2TAP(string message) } note for Relay "Abstract class" class Client { -TcpClient _client +Client(CORENode aNode, string hostname, int p) } class Server { -TcpListener listener -Socket _soc +Server(CORENode aNode, int p) +Service() } class SkypeCommunication { +Ethernet Ethernet -ConnectionStates state -Skype skype +InviteOpponent() +AcceptGame() +Send() } IBasicNode <|.. BasicNode BasicNode <|-- CORENode ICORENode <|.. CORENode IDataHandler <|.. CORENode SimpleSource <|-- Relay ISender <|.. Relay Relay <|-- Client Relay <|-- Server SimpleSource <|-- SkypeCommunication ISender <|.. SkypeCommunication IDataHandler <|.. SkypeCommunication CORENode "1" <--> "1" Relay : Gestisce CORENode *-- "1" Ethernet : Contiene SkypeCommunication *-- "1" Ethernet : Contiene

2. State Diagram β€” SkypeCommunication

Macchina a stati per la gestione della connessione Skype. Transizioni tra stati: UNKNOWN β†’ SKYPE_CONNECTED β†’ SENDING_INVITATION β†’ WAITING_ACCEPT β†’ STREAMING. Gestisce inviti, accettazioni, rifiuti e terminazione sessione.

stateDiagram-v2 [*] --> UNKNOWN UNKNOWN --> SKYPE_CONNECTED : Attach Success UNKNOWN --> SKYPE_FAILED : Attach Failed state SKYPE_CONNECTED { [*] --> Idle Idle --> OPENING_CONNECTION : InviteOpponent() Idle --> INVITATION_ACCEPTED : Receive INVITE } OPENING_CONNECTION --> SENDING_INVITATION : Stream Created SENDING_INVITATION --> WAITING_ACCEPT : Receive INVITE_ACK SENDING_INVITATION --> SKYPE_CONNECTED : Receive DECLINE WAITING_ACCEPT --> STREAMING : Receive ACCEPT WAITING_ACCEPT --> SKYPE_CONNECTED : Receive DECLINE INVITATION_ACCEPTED --> STREAMING : AcceptGame() INVITATION_ACCEPTED --> SKYPE_CONNECTED : DeclineGame() STREAMING --> SKYPE_CONNECTED : StopGame() / End SKYPE_FAILED --> [*] note right of STREAMING : Scambio pacchetti P2P attivo note right of SKYPE_FAILED : Impossibile connettersi a Skype

3. Sequence Diagram β€” Flusso Dati CORENode

Logica di instradamento in CORENode.HandleData(): pacchetti dall'interfaccia virtuale (Ethernet/TAP) vengono inoltrati al Relay (rete P2P); pacchetti dal Relay vengono iniettati nell'interfaccia TAP verso il SO.

sequenceDiagram participant OS as Sistema Operativo participant TAP as TAP Interface participant ETH as Ethernet Virtual participant CN as CORENode participant REL as Relay / Socket Note over CN: HandleData() routing logic rect rgb(230, 245, 255) Note over OS,REL: OUTBOUND: PC β†’ Rete P2P OS->>TAP: Scrive pacchetto IP TAP->>ETH: Forward ETH->>CN: HandleData(MemBlock, src=Ethernet) CN->>CN: Check _relay != null CN->>REL: _relay.Send(MemBlock) REL->>REL: Serialize + Socket.Write() end rect rgb(255, 240, 230) Note over OS,REL: INBOUND: Rete P2P β†’ PC REL->>CN: HandleData(MemBlock, src=Relay) CN->>CN: Check src != Ethernet CN->>ETH: Ethernet.Send(MemBlock) ETH->>TAP: Inject packet TAP->>OS: Pacchetto disponibile end

Installazione

cd pytao/src
python setup.py install

Utilizzo

Esempio di avvio del client:

python main.py --mode client --config config.yaml