0

3 つ以上のノードがあり、各ノード間の RSSI に基づいた各ノード間の距離の推定を使用してローカリゼーションを実行したいと考えています。

これを行うために、受信した RSSI の各ノードにリストを作成し、これらのリストをすべてのノード間で共有しようとしています。リストのサブリストに受信および送信ノードとともにすべての RSSI をキャプチャする Python スクリプトがあります。

コードは次のとおりです。

import subprocess

def matching_line(lines, keyword):
    """Returns the first matching line in a list of lines. See match()"""
    for line in lines:
        matching=match(line,keyword)
        if matching!=None:
            return matching
    return None

def match(line,keyword):
    """If the first part of line (modulo blanks) matches keyword,
    returns the end of that line. Otherwise returns None"""
    line=line.lstrip()
    length=len(keyword)
    if line[:length] == keyword:
        return line[length:]
    else:
        return None

neighbour = [] #list of local node and neighbour's addresses
scanned = {}    # dictionary containing iwlist scan results Address: RSSI
single_localisation = [[],[],[]] #list of iwlist scan results at a single node. Node's address, transmitting node's address, RSSI 
all_localisation = [[],[],[]] #list of iwlist scan results from all nodes. Receiving node's address, transmitting node's address, RSSI 

#Save batctl o to file - batctl o shows all the nodes nearby participating in the mesh
Proc=subprocess.Popen("batctl o > bato.txt", shell=true)
Proc.wait()

#Populate neighbour list with addresses of neighbouring nodes
with open("bat.txt") as fd:
    fd.readline() #skip column headings
    for line in fd:
        neighbour.append(line.split()[0])

#Add local node's Address to neighbour list for later comparison
neigbour.append( subprocess.check_output("ip link show wlan0 | grep link | awk '{print $2}'",shell=True).strip())

#Scan wlan2 and save to file
Proc=subprocess.Popen("iwlist wlan2 scan | awk '/ESSID/ {print $1} /level/ {print $3}' > rssi.txt", shell=true)
Proc.wait()

#Populate scanned list with all MAC addresses and RSSIs from file
cells=cells[1:]

with open("rssi.txt") as fd:
    for line in fd:
        cell_line = match(line,"Cell ")
        if cell_line != None:
            cells.append([])
            line = cell_line[-27:]
        cells[-1].append(line.rstrip())


for cell in cells:
    level.append(matching_line(cell,"Quality=").split()[2].split('=')[1])
    address.append(matching_line(cell,"Address: "))

scanned=dict(zip(address, level))

#Test if MAC address in scanned list matches MAC address in neighbour list (and is therefore a meshed node)
for s in scanned:
    if s in neighbour:
    #if it does make an entry in localisation for it
        localisation[0].append( subprocess.check_output("ip link show wlan0 | grep link | awk '{print $2}'",shell=True).strip())
        localisation[1].append(s)
        localisation[2].append(scanned[s])

そう

  • localisation[0] には、ローカル ノードの MAC が含まれます
  • localisation[1] には送信ノードの MAC が含まれます
  • ローカリゼーション [2] には、[0] によって [1] から受信した信号強度が含まれています

すべてのノードのすべてのローカリゼーション リストをマージして、各ノードが持つ 1 つの大きなリストを作成したいと考えています。

paramiko (または代替) を使用して SSH 経由で生成されたリストを共有できる方法はありますか?

4

1 に答える 1

0

paramiko (または代替) を使用して SSH 経由で生成されたリストを共有できる方法はありますか?

はい、ご利用いただけますparamikoソース ディストリビューションから、 API docsdemo_sftp.pyと一緒にその方法を説明する必要があります。さまざまなホストでホスト キーと承認済みキーを適切にセットアップすると、各リモート ホストは を作成してそれを呼び出すだけで済みます。SFTPClientput

これが最適な設計であるかどうかは、ネットワークの設定方法とロジックの外観に完全に依存します。可能であれば、最も簡単な解決策は、すべてのホストがアクセスできるネットワーク ファイル システム (NFS、SMB など) にデータを保存することです。または、ソケットサーバーや 0MQ などをセットアップして、各ホストがデータを最初にファイルに保存する代わりに直接アップロードできるようにすることもできます (これは、データの受信時にターゲットを直接トリガーできることも意味します)。ファイルシステムの監視などを設定する必要はありません)。というか…本当に選択肢はたくさんあります。

また、クライアント/サーバー システム (全員が 1 つの「マスター」にアップロードし、更新をすべての「スレーブ」ホストに送信するシステム) を構築しようとしているか、p2p システム (全員が他の全員にアップロードするシステム) を構築しようとしているのかを検討する必要があります。 . 後者の場合は、全員を同期させようとするのではなく、単純な DHT 設計を使用した方がよい場合があります。

于 2013-04-04T21:03:33.483 に答える