0

単純なネットワーク シミュレーター用のルーティング テーブルを作成したいと考えています。ルーティング テーブルを自動的に作成する必要があります。このテーブルを次のように表示します。

[[destinationInterface, nextHop]
[destinationInterface, nextHop]]

したがって、ルーター エンジンは、destinationInterface 宛てのメッセージを取得すると、それを nextHop に送信します。私がやろうとしているのはこれです:

    for h in self.creator.interfaceList: #checking my all interfaces
        for c in h.connectionList: #checking my interfaces connections
            self.routingTable.append([c,c]) #add connection as reachable via c
            for ic in c.creator.interfaceList: #check all interfeces of c creator
                for i in ic.connectionList: # check all connections of interfaces of c
                    self.routingTable.append([i,c]) #add i as reachable via c, since one of my interfaces is connected to c
                    #and so on...

                    for ij in i.creator.interfaceList: 
                        for j in ij.connectionList:
                            #if self.creator.name=="ap2":
                             #   print j.name
                            self.routingTable.append([j,c])
                            for ih in h.creator.interfaceList: 
                                for y in ih.connectionList:
                                    self.routingTable.append([y,c])

しかし、これはうまくいきません。そして、# を前に置いた行については本当に混乱しています。このコードは、# がある場合とない場合で動作が異なるためです。

4

0 に答える 0