松園v5 01 ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...android •ルータ...

81
© 2019 National Institute of Information and Communications Technology 2019 8 22 ⽇(⽊) 16 ICN 研究会ワークショップ Cefore の基本機能と導⼊⼿順 2019/8/22(⽊) 16ICN研究会ワークショップ ハンズオン

Upload: others

Post on 19-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

2019年8⽉22⽇(⽊)

第16回ICN研究会ワークショップ

Ceforeの基本機能と導⼊⼿順

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 2: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

⽬次nCeforeの基本機能nCeforeの導⼊⼿順

1. Ceforeのインストール2. cefnetdとcsmgrdの起動3. Ceforeのツールを⽤いた通信

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 3: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

Ceforeの基本機能

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 4: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

Ceforeの概要軽量かつ汎⽤的な CCN ソフトウェア実装

l リソースの乏しいセンサーノードでは軽量構成(下図①)l 最⼩機能以外はプラグインまたは外部機能

として機能拡張可能(下図②・③)

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

①最⼩機能構成(フォワーディング機能と 基本オペレーションのみ)

• センサー・Raspberry Pi

• Mac, Linux, Android

• ルータ

②Transport プラグインでストリーミング通信をサポート

③キャッシュ機能を追加

軽量

⾼機能

cefnetd

Transportplugin

Cacheplugin

Mobilityplugin

Cefore 基本構成

Page 5: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

Ceforeの機能構成n cefnetd: フォワーディングデーモン

l FIB (Forwarding Information Base)とPIT (Pending Interest Table)によるICNパケット転送機能をサポート

l 軽量なローカルキャッシュもサポート可能に(0.8.1)

n csmgrd: コンテンツストアデーモンl CS (Content Store) によるキャッシュ機能をサポート

nプラグイン機能nツール・ユーティリティ群n関連ソフトウェア

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

cefnetd csmgrd

キャッシュフォワーディング

ファイル送受信、ストリーミング通信、ネットワーク管理、etc.

ツール・ユーティリティ

cefpyco、Cefore-Emu

関連ソフトウェアPlugin

cache

Page 6: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

CeforeによるICN通信n cefnetdは全てのノードで稼働n csmgrdはキャッシュを利⽤する場合のみ稼働

l 下図の例では⾚枠内のcefnetdでコンテンツストアを共有する

パブリッシャ

cefnetd csmgrdcsmgrd

cefnetd

cefnetd

cefnetd

cefnetd

スマホ・タブレット

PC

センサ

cefnetd

cefnetd

cefnetd

cefnetd

cefnetd csmgrd

ルータ

CCNネットワーク TCPネットワーク

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 7: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

Ceforeの仕様n開発⾔語︓C⾔語nOS

l Linux(ubuntu 14.04 or 16.04)l MacOSl Raspbianl Android(未公開)

nCCNx-1.0のパケットフォーマットに準拠[1]l Type-Length-Value(TLV)フォーマットl Cefore独⾃のプロトコル拡張はOptional Hop-by-hop

ヘッダに記述nTCP/IP上でICN通信を⾏う

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

[1] “CCNx Messages in TLV Format”, https://tools.ietf.org/html/rfc8609

Page 8: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

cefnetdの概要n Ceforeの⼟台となるシンプルなフォワーディングデーモンで

あり、全ノード(送受信者・ルーター)で稼働n実装機能

l フォワーディング機能l Staticルーティング機能l Security機能l Plugin interface

• キャッシュ、モビリティ、経路制御などプラグインのためのインタフェース

• cefnetd本体を改造することなく柔軟に機能を組み込み可能• サンプルとしてNDNパケット転送プラグインが存在• 使⽤しない機能はビルドしないので軽量

l ローカルキャッシュ機能• cefnetd のメモリ上で動く軽量版のCS機能• csmgrd のようにプラグインで拡張することはできない

cefnetd

X plugin Y pluginZ plugin

Cefore plugin interface

Module

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 9: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

csmgrdの概要n⾼負荷なキャッシュ機能はcsmgrdとしてcefnetdから分離n cefnedとcmsgrd間はローカルソケットまたはTCPにて接続

l 1つのcsmgrdに対して複数のcefnetdの接続が可能• 設定ファイル(csmgrd.conf)にて接続可能なcefnetdを指定

l ローカル接続ではUNIXドメインソケットを使⽤、リモート接続ではTCP接続を使⽤

Node A

cefnetd

Node B

cefnetd

csmgrd

Node C

cefnetd

UNIXドメインソケット接続

TCP接続

TCP接続

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 10: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

Ceforeプラグインn機能追加・拡張のためのプラグインライブラリ

l cefnetdの拡張機能追加プラグインl csmgrdのキャッシュ⽅式プラグイン

• キャッシュデータ保存⽅式・キャッシュ選択/置換⽅式

n所定のコールバック関数を⽤いて実装する[2]

l 必要なプラグインを必要に応じて開発し、着脱も可能• 軽微なMakefileの変更とリコンパイルで機能追加可能• 追加した各機能はplugin.confにてON/OFF可能

l 異なるプラグインライブラリ間で機能拡張・追加の影響を与えない

[2] “第9回ICN研究会ワークショップ Ceforeチュートリアル”, http://www.ieice.org/~icn/wp-content/uploads/2017/08/Cefore-tutorial.pdf

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 11: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

キャッシュプラグインcsmgrdは設定ファイルで使⽤するキャッシュプラグインを指定

l Cache plugin: キャッシュデータ保存⽅式l Cache algorithm: キャッシュ選択/置換アルゴリズム

csmgrd File System Cache

Memory Cache

Cache Plugin X

Cache Plugin Y

Cache Plugin

LRU

Cache algorithm X

Cache algorithm

LFU

FIFO

各Cache Pluginは、初期処理時に指定されたCache algorithm (共有ライブラリ)をダイナミックロードする

csmgrdは起動時に、csmgrd.confで指定されたCache Plugin(共有ライブラリ)をダイナミックロードする

開発者は独⾃のCache Plugin/Algorithmを実装可能

cefnetd

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 12: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

ツール・ユーティリティnコンテンツの配信、取得

l Named Cobのアップロード・ダウンロード• cefputfile/cefgetfile

l 特定のContent Objectのダウンロード• cefgetchunk

l ストリーム配信・受信• cefputstream/cefgetstream

nネットワーク管理ツールl コンテンツがキャッシュされているノードの特定

• cefpingl コンテンツまでの経路、キャッシュされているコンテンツの詳

細取得• ccninfo

nその他l Wireshark

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 13: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

関連ソフトウェアn cefpyco

l Ceforeアプリ開発⽤のPythonパッケージl C⾔語より容易にCeforeアプリを開発可能

nCefore-Emul Cefore⽤のネットワークエミュレーターl 軽量かつ拡張性の⾼いコンテナ⽅式

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 14: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

Ceforeの導⼊⼿順

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 15: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

Ceforeの導⼊⼿順1. Ceforeのインストール2. cefnetdとcsmgrdの起動3. Ceforeのツールを⽤いた通信

l cefgetfileとcefputfileを⽤いたファイル交換

nスライドの種類(スライドの左上に表記)l 説明スライドl 実践スライド(実際に⼿を動かす)l ⾼度な内容スライド(主に今回使⽤しない参考情報)

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

Advanced

表記無し

Page 16: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

1.Ceforeのインストール

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 17: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

Ceforeのインストール⼿順① ソースコードとマニュアルのダウンロード② ビルドとインストール③ インストールされる機能について

l デフォルトでインストールされる機能l インストール時にオプション指定が必要な機能

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

無線LAN接続⽅法• ESSID: icnevent• セキュリティの種類: WPA2-PSK• セキュリティキー: hotspotair001• IPアドレス: DHCPのみ

Page 18: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

①ダウンロード

nソースコードl Download> source code

(cefore-0.8.1.zip)

nユーザマニュアルl Instruction> User Manual

https://cefore.net/からソースコードとユーザマニュアルをダウンロード

ここをクリック

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

ここをクリック

Page 19: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

②ビルドとインストール(Ubuntu)

nライブラリのインストール

nCeforeのビルド$ unzip cefore-0.8.1.zip

$ cd cefore-0.8.1

$ autoconf

$ automake

$ ./configure --enable-csmgr --enable-cache

$ make

$ sudo make install

$ sudo ldconfig

$ sudo apt-get install libssl-dev automake

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

# 任意のディレクトリでアーカイブを解凍

# csmgr、ローカルキャッシュを有効化

# /usr/local/bin, sbin にインストールされる

# (必要に応じて実行)

Page 20: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

②ビルドとインストール(MacOS)n ライブラリのインストール(homebrew使⽤時)

n Ceforeのビルド

n ~/.bash_profileに以下を追加

$ brew install openssl automake

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

$ unzip cefore-0.8.1.zip$ cd cefore-0.8.1$ autoconf$ automake$ export PATH="/usr/local/sbin:/usr/local/opt/openssl/bin:$PATH"$ ./configure --enable-csmgropssl_header_path=/usr/local/opt/openssl/include/ LDFLAGS=’-L/usr/local/opt/openssl/lib’ CPPFLAGS=’-I/usr/local/opt/openssl/include/’

$ make$ sudo make install

# 任意のディレクトリにアーカイブを解凍

⼀⾏で⼊⼒して実⾏※⻑いので打ち間違いに注意

(m a c p o r t sの場合は“ / u s r / l o c a l /o p t /o p e n s s l ”を“ /o p t / l o c a l ”に置き換える)

export PATH="/usr/local/sbin:/usr/local/opt/openssl/bin:$PATH"

Pract ice

Page 21: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

トラブルシューティングn autoconfに失敗する

l →aclocalを実⾏する• brewでaclocalが失敗する場合は”brew doctor; brew brune”を試す

n Macl cefctrlやcsmgrdが⾒つからないというエラーが出る

• →PATHに/usr/local/sbinが⼊っているか確認するl configureに失敗する

• →オプションを打ち間違いしていないか確認する• × openssl_header_path 〇opssl_header_path• × LDFLAGS=`-L…` (バッククオート)• 〇 LDFLAGS=’-L…’ (シングルクオート)

• configureのオプションを.bash_profileに追加すれば毎回の⼊⼒を省略可能

• .bash_profile に以下を書き込む(要端末再起動)

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

$ export PATH="/usr/local/sbin:/usr/local/opt/openssl/bin/:$PATH"$ export LDFLAGS="-L/usr/local/opt/openssl/lib"$ export CPPFLAGS="-I/usr/local/opt/openssl/include"$ export opssl_header_path="/usr/local/opt/openssl/include"

Page 22: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

③インストールされる機能(デフォルト)

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

機能 形態 説明cefnetd daemon フォワーディングデーモン

cefnetdstart utility フォワーディングデーモン起動ユーティリティ

cefnetdstop utility フォワーディングデーモン停⽌ユーティリティ

cefstatus utility cefnetdのstatus標準出⼒ユーティリティ

cefroute utility FIB操作ユーティリティ

cefputfile tool 任意のファイルをNamed Cobに変換しcefnetdへ⼊⼒する

cefgetfile tool cefnetdを介して取得したコンテンツをファイルとして出⼒する

cefgetchunk tool 指定されたNamed Cobを取得し、ペイロードを標準出⼒する

cefputstream tool 標準⼊⼒をNamed Cobに変換しcefnetdへ⼊⼒する

cefgetstream tool cefnetdを介して取得したコンテンツを標準出⼒する

Page 23: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

n configure実⾏時にオプション指定が必要な機能l 例: csmgrdとcefpingを有効化する場合

• ./configure --enable-csmgr --enable-cefpingl configure変更後はmakeを再実⾏

③インストールされる機能(要オプション)

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

機能 形態 option 説明(cefnetdローカルキャッシュ) function --enable-cache cefnetdのローカルキャッシュを有効化(CS_MODE=1)

csmgrd daemon --enable-csmgr コンテンツストア管理デーモン (CS_MODE=2)

csmgrdstart utility --enable-csmgr csmgrd起動ユーティリティ

csmgrdstop utility --enable-csmgr csmgrd停⽌ユーティリティ

csmgrstatus utility --enable-csmgr csmgrdのstatus標準出⼒ユーティリティ

csmgrecho tool --enable-csmgr csmgr接続確認ツール

cefping tool --enable-cefping ネットワーク管理ツールcefping

Sample Transport plugin --enable-samptp Sample Transport プラグイン

NDN Plugin plugin --enable-ndn NDNプラグイン

Page 24: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

インストールディレクトリの指定⽅法

n環境変数”$CEFORE_DIR”でインストール先を指定可能l ”$CEFORE_DIR”のデフォルトは”/usr/local”l daemon機能は”$CEFORE_DIR/sbin”l utilityとtool機能は”$CEFORE_DIR/bin”l 設定ファイルは”$CEFORE_DIR/cefore”

nインストールディレクトリを変更した場合は、configure実⾏前にautoconfとautomakeを再実⾏

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Advanced

Page 25: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

2.cefnetdとcsmgrdの起動

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 26: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

cefnetdとcsmgrdの起動⼿順① 動作確認

l (1-1) バッファチューニングl (1-2) cefnetdの起動確認と停⽌l (1-3) csmgrdの起動確認と停⽌

② ceforeの設定ファイルの説明l (2-1) cefnetd.confの設定l (2-2) cefnetd.fibの設定l (2-3) csmgrd.confの設定

③ 設定ファイルの変更l (3-1) ルーティングテーブルの設定(cefnetd.fib)l (3-2) cefnetdがキャッシュを利⽤するように設定

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 27: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

(1-1) バッファチューニングn Linux OS

nMac OS

nPC再起動時にパラメータが初期化されるので、再実⾏しやすいようスクリプト化するのを推奨

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

$ sudo sysctl –w net.core.rmem_default=10000000

$ sudo sysctl –w net.core.wmem_default=10000000

$ sudo sysctl –w net.core.rmem_max=10000000

$ sudo sysctl –w net.core.wmem_max=10000000

$ sudo sysctl –w net.local.stream.sendspace=2000000

$ sudo sysctl –w net.local.stream.recvspace=2000000

Pract ice

Page 28: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

n cefnetdの起動・起動確認・停⽌コマンド

n 動作例

(1-2) cefnetdの起動確認

$ sudo cefnetdstart$ cefstatus$ sudo cefnetdstop

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

# cefnetdを起動# cefnetdのステータスを確認# cefnetdを停止

cefore:~/cefore-0.8.1$ sudo cefnetdstart2019-08-22 15:13:00.123 [cefnetd] INFO: [client] Config directory is /usr/local/Cefore...2019-08-22 15:13:00.123 [cefnetd] INFO: Not use Content Store2019-08-22 15:13:00.456 [cefnetd] INFO: Runningcefore:~/cefore-0.8.1$ cefstatus2019-08-22 15:13:05.123 [cefctrl] INFO: [client] Config directory is /usr/local/cefore...Port : 9896Rx Frames : 0Tx Frames : 0Cache Mode : NoneFaces :faceid = 4 : IPv4 Listen face (udp)faceid = 0 : Local facefaceid = 16 : Local facefaceid = 5 : IPv6 Listen face (udp)faceid = 6 : IPv4 Listen face (tcp)faceid = 7 : IPv6 Listen face (tcp)

FIB :Entry is empty

PIT :Entry is empty

cefore:~/cefore-0.8.1$ sudo cefnetdstop2019-08-22 15:13:10.456 [cefctrl] INFO: [client] Config directory is /usr/local/Cefore...2019-08-22 15:13:10.789 [cefnetd] INFO: Stop

Pract ice

Page 29: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

n csmgrdの起動・起動確認・停⽌コマンド

n 動作例

(1-3) csmgrdの起動確認

$ sudo csmgrdstart$ csmgrstatus$ sudo csmgrdstop

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

# csmgrdを起動# csmgrdのステータスを確認# csmgrdを停止

cefore:~/cefore-0.8.1$ sudo csmgrdstart2019-08-22 15:14:00.123 [csmgrd] INFO: Config directory is /usr/local/cefore....2019-08-22 15:14:00.123 [csmgrd] INFO: Loading csmgrd.conf ... OK2019-08-22 15:14:00.123 [csmgrd] INFO: Running

cefore:~/cefore-0.8.1$ sudo csmgrstatus ccn:/

Connect to 127.0.0.1:97992019-08-22 15:14:05.456 [csmgrd] INFO: Open TCP peer: 127.0.0.1:37920, socket : 5***** Connection Status Report *****All Connection Num : 1

***** Cache Status Report *****Number of Cached Contents : 0

2019-08-22 15:14:00.456 [csmgrd] INFO: Close TCP peer: 127.0.0.1:37920

cefore:~/cefore-0.8.1$ sudo csmgrdstop2019-08-22 15:14:10.123 [csmgrd] INFO: Open TCP peer: 127.0.0.1:37922, socket : 52019-08-22 15:14:10.123 [csmgrd] INFO: csmgrdstop from root2019-08-22 15:14:10.789 [csmgrd] INFO: Stop

Pract ice

※現⾏版(0.8.1)ではPCのメモリ4GB以上推奨(2GB以下の場合は起動しないでください)

Page 30: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

②ceforeの設定n /usr/local/ceforeに設定ファイルが存在*1

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

*1: 環境変数$CEFORE_DIRを変更してインストールした場合は”$CFEORE_DIR/cefore”下に存在

ファイル名 説明cefnetd.conf cefnetdの設定ファイル

cefnetd.fib cefnetdのFIBエントリの設定ファイル

csmgrd.conf csmgrdの設定ファイル

• cefnetd.key• ccore-public-key• default-public-key• default-private-key

InterestとContet ObjectのValidationに使⽤する公開鍵と秘密鍵の設定ファイル、およびデフォルトで使⽤する公開鍵と秘密鍵

• plugin.conf• plugin/

プラグインの設定ファイルとディレクトリ(プラグイン使⽤時のみ使⽤)

今回はcefnetd.conf・cefnetd.fib・csmgrd.confを設定

Page 31: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

(2-1) cefnetd.confの設定n設定ファイルcefnetd.confの内容

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

cefore:~/cefore-0.8.1$ cat /usr/local/cefore/cefnetd.conf## cefnetd.conf#

## Port number used by cefnetd.# This value must be higther than 1024 and lower than 65536.##PORT_NUM=9896

## Socket ID used by cefnetd.# This value is the string type, not the integer type.##LOCAL_SOCK_ID=0…

“#” で始まる⾏はコメント⾏

インストール直後の雛形ではすべてのパラメータがコメントアウトされている(雛形のコメントに書かれている値は

各パラメータのデフォルト値)

Page 32: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

n「parameter=value」の書式で記述するl 例: キャッシュ無しモードからcsmgrd使⽤モードに

変更する場合• CS_MODE=2

nキャッシュを使⽤する場合に設定すべきパラメータ

cefnetd.confの主なパラメータ

パラメータ 説明 デフォルト 値の範囲・意味

CS_MODE CSの動作モード 00︓CSを使⽤しない1︓cefnetdのローカルキャッシュ2︓csmgrd

BUFFER_CAPACITY cefnetdの最⼤Cobバッファサイズ 30000 0 ≦ n < 65536

CSMGR_NODE cefnetdが接続するcsmgrdのIPアドレス localhost

CSMGR_PORT cefnetdが接続するcsmgrdのTCPポート番号 9799 1024 < p < 65536

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 33: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

cefnetd.confの詳細パラメータ

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

パラメータ 説明 デフォルト 値の範囲・意味

LOCAL_CACHE_CAPACITY

cefnetdのローカルキャッシュの最⼤cobキャッシュ数(CS_MODE=1の場合に使⽤) 65535 1 < n < 8M

PIT_SIZE 最⼤PITエントリ数 2048 1 < n < 65536

FIB_SIZE 最⼤FIBエントリ数 1024 1 < n < 65536

PORT_NUM cefnetdが使⽤するポート番号(単⼀のPC上でcefnetdを複数起動する場合等に設定) 9896 1024 < p < 65536

LOCAL_SOCK_ID UNIXドメインソケットのID⽂字列(単⼀のPC上でcefnetdを複数起動する場合等に設定) 0

CEF_LOG_LEVEL出⼒ログの詳細度([0] Error のみ表⽰、[1] Warning+Error、 [2] Error+Watning+Info) 0 0 ≦ n ≦ 2

CEF_DEBUG_LEVEL

デバッグ⽤ログの詳細度(configure時に”--enable-debug”を指定する必要有) 0

0 ≦ n ≦ 3(3にするとパケットダンプまで表⽰されるので注意)

Advanced

Page 34: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

(2-2) cefnetd.fibの設定n静的なFIBエントリの設定ファイル

l 書式︓name (udp|tcp) ip_address[:port] …l 設定例

• ccn:/ udp 10.0.1.1• ccn:/cinema tcp 10.0.2.1:8888 10.0.2.2:9999• ccn:/news/today udp 10.0.3.1 10.0.3.2:8765 10.0.3.3:9876※経路を複数指定した場合でも、現在のFIB戦略では利⽤可能な最初のノードにのみ転送するので注意

n動的なFIBエントリの設定はcefrouteで⾏うl 追加: cefroute add name (udp|tcp) ip_addressl 削除: cefroute del name ip_address

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 35: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

(2-3) csmgrd.confの設定n書式やファイルの場所はcefnetd.confと同じ

l 「parameter=value」の形式で記述l “#”で始まる⾏はコメントl /usr/local/ceforeに配置

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

cefore:~/cefore-0.8.1$ cat /usr/local/cefore/csmgrd.conf## csmgrd.conf#

## Port number used by csmgrd.# This value must be higher than 1024 and lower than 65536.##PORT_NUM=9799

## Socket ID used by csmgrd and cefnetd.# This value is the string type, not the integer type.##LOCAL_SOCK_ID=0…

Page 36: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

csmgrd.confの主なパラメータ

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

パラメータ 説明 デフォルト 値の範囲・意味

CACHE_TYPE csmgrdが使⽤するPlugin名称(⽂字列) filesystem• filesystem• memory(詳細は後述)

CACHE_INTERVALcsmgrdの期限切れコンテンツチェック間隔(単位︓ミリ秒)

10,000(10秒毎)

1,000 < n < 86,400,000(1秒〜24時間)

CACHE_DEFAULT_RCT

Cobのデフォルトのキャッシュ期限(Recommended Cache Time; RCT)(RCTが指定された場合はそちらを優先)(単位︓ミリ秒)

600,000(10分間)

1,000 < n < 3,600,000(1秒〜24時間)

CACHE_ALGORITHM キャッシュ置換アルゴリズムライブラリ libcsmgrd_lru

• None• libcsmgrd_lru• libcsmgrd_lfu• libcsmgrd_fifo

CACHE_PATHファイルシステムキャッシュのキャッシュ保存⽤ディレクトリ(ファイルシステムキャッシュ使⽤時は必須)

/usr/local/cefore

CACHE_CAPACITY キャッシュ容量(単位︓cob数) 65,535 1 < n < 819,200

Page 37: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

csmgrd.confの詳細パラメータ

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

パラメータ 説明 デフォルト 値の範囲PORT_NUM csmgrdが使⽤するポート番号 9799 1024 < p < 65536

ALLOW_NODE

• csmgrdへの接続を許可するホストのIPアドレス• リモートでのcsmgrdへの接続を許可する場合のみ設

定(デフォルトではローカルホストのみ接続可能)• " ALL"と記述すると、全ての接続を許可• 「, (カンマ)」区切りで複数指定可能• 複数⾏に分けての指定も可能• サブネットを使⽤した指定も可能• 設定例

• ALLOW_NODE=192.168.1.1,192.168.1.2• ALLOW_NODE=192.168.2.0/24

localhost

CEF_LOG_LEVEL 出⼒ログの詳細度([0] Error のみ表⽰、[1] Warning+Error、 [2] Error+Watning+Info) 0 0 ≦ n ≦ 2

CEF_DEBUG_LEVEL

デバッグ⽤ログの詳細度(configure時に”--enable-debug”を指定する必要有) 0 0 ≦ n ≦ 3

LOCAL_SOCK_ID UNIXドメインソケットのID⽂字列(単⼀のPC上でcsmgrdを複数起動する場合等に設定) 0

Advanced

Page 38: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

③設定ファイルの変更l (3-1) ルーティングテーブルの設定

• cefnetd.fibを変更してFIBエントリを追加• cefstatusでFIBエントリの更新を確認

l (3-2) cefnetdがcsmgrdを利⽤するように設定• cefnetd.confで”CS_MODE=2”に設定• csmgrd.confでキャッシュの挙動を設定• csmgrdstart・cefnetdstartの順で起動後、動作確認

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

Page 39: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

(3-1) ルーティングテーブルの設定n cefnetd.fibに以下を⼊⼒

n cefnetdを起動し、FIBエントリを確認

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

ccn:/hoge udp 10.0.0.1

$ cefnetdstart$ cefstatus

Version : f0Port : 9896Rx Frames : 0Tx Frames : 0Cache Mode : NoneFaces :

faceid = 4 : IPv4 Listen face (udp)faceid = 0 : Local facefaceid = 17 : Local facefaceid = 5 : IPv6 Listen face (udp)faceid = 16 : address = 10.0.0.1:9896 (udp)faceid = 6 : IPv4 Listen face (tcp)faceid = 7 : IPv6 Listen face (tcp)

FIB :ccn:/hoge/

Faces : 16 (-s-) PIT :

Entry is empty

FIBエントリが追加されている

Pract ice

Page 40: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

(3-2) cefnetdのキャッシュ利⽤設定①n cefnetd.confで”CS_MODE=2”に設定

n cefnetd上のローカルキャッシュを使う場合は“CS_MODE=1”に設定

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

…## Content Store used by cefnetd# 0 : No Content Store# 1 : Use cefnetd's Local cache# 2 : Use external Content Store (use csmgrd)#CS_MODE=0CS_MODE=2…

追加

cefnetd.conf

Pract ice

Page 41: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

(3-2) cefnetdのキャッシュ利⽤設定②n csmgrd.confでキャッシュの挙動を設定(任意)

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

…## Type of CS space used by csmgrd.# filesystem : UNIX filesystem# memory : Memory##CACHE_TYPE=filesystemCACHE_TYPE=memory

## Type of cache policy by cache plugin.##CACHE_ALGORITHM=libcsmgrd_lruCACHE_ALGORITHM=libcsmgrd_fifo…

csmgrd.conf

追加

追加

• filesystem:• ファイルにキャッシュデータを保存• CACHE_PATHパラメータで

キャッシュディレクトリを変更可• memory:

• メモリ上にキャッシュデータを保存

• libcsmgrd_fifo: First-In First-Out• libcsmgrd_lru: Least Recently Used• libcsmgrd_lfu: Least Frequently Used• None: 置換を⾏わない

(⼀杯になったらキャッシュを停⽌)

Pract ice

Page 42: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

(3-2) cefnetdのキャッシュ利⽤設定③n csmgrdstart・cefnetdstartの順で起動後、動作確認

l cefnetdからcsmgrdへ接続を⾏うため、最初にcsmgrdを起動する

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

$ sudo csmgrdstart

$ sudo cefnetdstart

$ csmgrstatus ccn:/

$ echo hello > test

$ cefputfile ccn:/test

$ csmgrstatus ccn:/

# 任意のディレクトリにアーカイブを解凍

# この時点ではキャッシュが無い

# ファイルtestを作成してアップロード

# ccn:/testがキャッシュされたのを確認

Pract ice

Page 43: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

csmgrstatusを⽤いたキャッシュ確認

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

cefore:~/cefore-0.8.1$ csmgrstatus ccn:/

Connect to 127.0.0.1:97992018-08-24 13:48:13.518 [csmgrd] INFO: Open TCP peer: 127.0.0.1:37960, socket : 6***** Connection Status Report *****All Connection Num : 1

***** Cache Status Report *****Number of Cached Contents : 1

[0]Content Name : ccn:/test/Content Size : 6 BytesAccess Count : 0Freshness : 293 SecElapsed Time : 6 Sec

2018-08-24 13:48:13.519 [csmgrd] INFO: Close TCP peer: 127.0.0.1:37960

cefore:~/cefore-0.8.1$ csmgrstatus ccn:/

Connect to 127.0.0.1:97992018-08-24 13:47:56.844 [csmgrd] INFO: Open TCP peer: 127.0.0.1:37958, socket : 6***** Connection Status Report *****All Connection Num : 1

***** Cache Status Report *****Number of Cached Contents : 0

キャッシュが無い場合

キャッシュ(ccn:/test)が有る場合

キャッシュ済みコンテンツの情報が表⽰される

Pract ice

Page 44: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

トラブルシューティングn csmgrdstartコマンドが⾒つからない。

l →configure実⾏時に”--enable-csmgr ”を付けているか確認する。• オプション指定にミスがあると無視されるので、打ち間違いに要注意。

n configureのオプション指定を変更すると、makeに失敗する。l “make clean“を実⾏してからmakeをやり直す。

n csmgrdstart実⾏時に” [csmgrd] ERROR: libcsmgrd_plugin.so: cannot open shared object file: No such file or directory”と表⽰される。l →Ubuntuの場合、”sudo ldconfig ”を実⾏する。l →MacOSの場合、以下を実⾏する(~/.bash_profileにも要追記)。

• export PATH=“/usr/local/sbin:/usr/local/opt/openssl/bin:$PATH“

n cefnetd・csmgrdが起動しないl 「(1-1) バッファチューニング」を⾏ったかどうか確認する。

• バッファチューニングはPCを再起動すると設定が初期化されるので要注意。

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 45: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

3.Ceforeのツールを⽤いた通信cefgetfileとcefputfileを⽤いたファイル交換

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 46: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

ICN通信⽤ネットワーク構成

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

192.168.0.2192.168.0.1

10.0.2.2 〜 10.0.2.15

10.0.2.1/2410.0.1.1/24

10.0.1.2 〜 10.0.1.15

SSID: icntest01PASS: icntest01

SSID: icntest02PASS: icntest02

AP: icntest01 AP: icntest02

Page 47: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

①ICN通信⽤ネットワークへログインn名簿(順不同)に従ってAPに接続

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

※SSIDと名前(カッコ内のローマ字表記)に基づいてコンテンツ名を決めます

SSID: icntest01 SSID: icntest02yamamotoS (⼭本信⼀) yamamotoK (⼭本健⼈)kanai yamazawakaron (ニ カロン) higuchimasuda takemasakatto koizumiooka matsuznokominami asaedahasegawa ata

Page 48: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

②csmgrd・cefnetd起動1. 無線APをデフォルトゲートウェイに設定

l cefnetd.fib にFIBエントリを追記• 例: 無線LAN icntest01 に接続する場合• ccn:/ udp 10.0.1.1

2. cefnetd.confで”CS_MODE=2”に設定3. バッファチューニング4. sudo csmgrdstart

5. sudo cefnetdstart

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

Page 49: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

③cefputfileでファイルアップロード1. 簡単な⾃⼰紹介⽂を書いたintro.txtを作成する

l 例︓「私は[所属]の[名前]です。」

2. コンテンツには以下の規則で名前をつけるl 例︓無線LAN icntest01に接続するaliceさんの場合

3. intro.txtをアップロードする

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

c c n : / i c n te s t 0 1 /a l i c e / [ファイル名 ]

無線LANのSSID ⾃⾝の名前(名簿のPublisher識別⼦)

$ cefputfile ccn:/icntest01/alice/intro.txt –e 7200 –t 7200

キャッシュ期限オプション(2時間)上記規則に従い⾃分のコンテンツ名を決定

Pract ice

Page 50: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

cefputfileの動作例

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

cefore:~/cefore-0.8.1$ cefputfile ccn:/icntest01/alice/intro.txt -e 7200 -t 7200[cefputfile] Start[cefputfile] Parsing parameters ... OK[cefputfile] Init Cefore Client package ... OK[cefputfile] Conversion from URI into Name ... OK[cefputfile] Checking the input file ... OK[cefputfile] Connect to cefnetd ... OK[cefputfile] URI = ccn:/icntest01/alice/intro.txt[cefputfile] File = intro.txt[cefputfile] Rate = 5.000 Mbps[cefputfile] Block Size = 1024 Bytes[cefputfile] Cache Time = 7200 sec[cefputfile] Expiration = 7200 sec[cefputfile] Start creating Content Objects[cefputfile] Unconnect to cefnetd ... OK[cefputfile] Terminate[cefputfile] Tx Frames = 1[cefputfile] Tx Bytes = 6[cefgetfile] Duration = 0.004 sec[cefputfile] Thorghput = 18140 bpscefore:~/cefore-0.8.1$ csmgrstatus ccn:/Connect to 127.0.0.1:9799…

Content Name : ccn:/icntest01/alice/intro.txt/Content Size : 6 BytesAccess Count : 0Freshness : 7193 SecElapsed Time : 4 Sec

ファイルがキャッシュされている(キャッシュされていない場合は

cefnetd .confでUSE_CACHE=1になっているかどうかを確認)

Page 51: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

④cefgetfileでファイルダウンロードn名簿を参考に他の⼈のintro.txtをダウンロードする

l 例︓icntest02のBobのintro.txtをダウンロードしてbob.txtとして保存する

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

$ cefgetfile ccn:/icntest02/bob/intro.txt –f bob.txt

$ cat bob.txt

保存先ファイル名をオプションで指定

AP: icntest01 AP: icntest02

csmgrd

ccn:/icntest02/bob/intro.txt

cefnetd

cefnetd

Alice Bob

cefnetd

cefnetd$ cefgetfi le

Page 52: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

cefgetfileの動作例

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

cefore:~/cefore-0.8.1$ cefgetfile ccn:/icntest02/bob/intro.txt -f bob.txt[cefgetfile] Start[cefgetfile] Parsing parameters ... OK [cefgetfile] Init Cefore Client package ... OK[cefgetfile] Conversion from URI into Name ... OK[cefgetfile] Checking the output file ... OK[cefgetfile] Connect to cefnetd ... OK[cefgetfile] URI=ccn:/icntest02/bob/intro.txt[cefgetfile] Start sending Interests[cefgetfile] Complete[cefgetfile] Unconnect to cefnetd ... OK[cefgetfile] Terminate[cefgetfile] Rx Frames = 1[cefgetfile] Rx Bytes = 26[cefgetfile] Duration = 0.000 sec[cefgetfile] Jitter (Ave) = 0 us[cefgetfile] Jitter (Max) = 0 us[cefgetfile] Jitter (Var) = 0 uscefore:~/cefore-0.8.1$ cat bob.txt私はNICTのBobです。

コンテンツをダウンロードしてbob.txtに保存できている

Page 53: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

その他のツールの使⽤n cefgetfile/cefputfileのオプションを確認しよう

l ユーザマニュアル6.1節、6.2節l ⼤きなサイズのファイルを作ってアップロード速度や

ダウンロード速度を計測してみよう• cefputfileはアップロードレートが調整可能(rオプション)• cefgetfileは取得パイプライン数が調整可能(sオプション)

n cefgetchunkで複数のチャンクから成るコンテンツの特定のチャンクだけ取得してみようl ユーザマニュアル6.3節

n cefpingやcefinfoをconfigureで有効にして遅延などのネットワーク情報を観測してみようl ユーザマニュアル6.6節、6.7節l --enable-cefping, --enable-cefinfoのつけ忘れに注意

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract iceAdvanced

Page 54: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

おわりにnCeforeのメーリングリスト

n ceforeやドキュメントは今後もアップデート予定l HPを要チェック

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

ここをクリック

登録フォーム

Page 55: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology 2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Page 56: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

2019年8⽉22⽇(⽊)

第16回 ICN研究会ワークショップ

Ceforeアプリ開発ツールcefpyco

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

56

Page 57: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

⽬次n cefpycoの概要n cefpycoのインストールn cefpycoを⽤いた通信

l cefnetdへの接続l Dataパケットの送信*1

l Interestパケットの送信l パケットの受信l 簡易Consumerアプリの作成l 簡易Producerアプリの作成

nサンプルアプリCefApp

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

*1: 本スライドではCob(Content Object)をDataまたはDataパケットと呼称

57

Page 58: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology 2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

cefpycoの概要n cefpyco (CEFore PYthon COmpact package)

l ceforeアプリ開発⽤のpythonパッケージl C⾔語で開発するより記述が楽

• 例︓ Interest を送るコード1 #include <stdio.h>2 #include <stdlib.h>3 #include <unistd.h>4 #include <ctype.h>5 #include <cefore/cef_define.h>6 #include <cefore/cef_client.h>7 #include <cefore/cef_frame.h>8 #include <cefore/cef_log.h>910 int main(int argc, char *argv[]) {11 CefT_Client_Handle fhdl;12 CefT_Interest_TLVs params_i;13 int res;14 cef_log_init ("cefpyco");15 cef_frame_init();16 res = cef_client_init(port_num, conf_path);17 if (res < 0) return -1;18 fhdl = cef_client_connect();19 if (fhdl < 1) return -1;20 memset(&params_i, 0, sizeof(CefT_Interest_TLVs));21 res = cef_frame_conversion_uri_to_name("ccn:/test", params_i.name);22 if (res < 0) return -1; // Failed to convert URI to name.;23 params_i.name_len = res;24 params_i.hoplimit = 32;25 params_i.opt.lifetime_f = 1;26 params_i.opt.lifetime = 4000ull; /* 4 seconds */27 params_i.opt.symbolic_f = CefC_T_OPT_REGULAR;28 params_i.chunk_num_f = 1;29 params_i.chunk_num = 0;30 cef_client_interest_input(fhdl, &params_i);31 if (fhdl > 0) cef_client_close(fhdl);32 return 0;33 }

C⾔語版 Python版

1 import cefpyco23 with cefpyco.create_handle() as h:4 h.send_interest("ccn:/test", 0)

33⾏→4⾏

58

Page 59: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

cefpycoのダウンロードnhttps://cefore.net/download > Utilities > cefpyco

l マニュアル(README.html)付属*1

*1: 2018/8/30現在は⽇本語マニュアルのみ

ここをクリック

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice 59

Page 60: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

ライブラリのインストールnライブラリのインストール(Ubuntu)

l python3 環境を推奨

nライブラリのインストール(Mac)

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

$ sudo apt-get install cmake python-pip

$ sudo pip install setuptools click numpy

$ brew install cmake pyenv

$ pyenv install 3.7.3

$ pyenv global 3.7.3 # pyenv local … なら実⾏ディレクトリでのみ有効化$ pyenv init -

$ pyenv versions # インストールversionの確認$ sudo easy_install pip # macportsではpy-pip

$ python –m pip install setuptools click numpy

$ echo 'eval "$(pyenv init -)“'a>> .bash_profile # 任意

60

Page 61: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

ビルドとインストールn cefpycoのビルド

$ unzip cefpyco-0.4.2.zip

$ cd cefpyco.release

$ cmake .

$ sudo make install

$ cd test

$ sudo python

>> import cefpyco

>> (Ctrl-D)

# 任意のディレクトリにアーカイブを解凍

# “.”のつけ忘れに注意

# pythonでインポートして起動確認

# エラーが起きなければ正常

# Ctrl-D を押して終了

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice 61

Page 62: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

(再掲)バッファチューニングn Linux OS

nMac OS

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

$ sudo sysctl –w net.core.rmem_default=10000000

$ sudo sysctl –w net.core.wmem_default=10000000

$ sudo sysctl –w net.core.rmem_max=10000000

$ sudo sysctl –w net.core.wmem_max=10000000

$ sudo sysctl –w net.local.stream.sendspace=2000000

$ sudo sysctl –w net.local.stream.recvspace=2000000

Pract ice 62

Page 63: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

cefpycoを⽤いた通信① cefnetdへの接続

l create_handle()メソッド② Dataパケットの送信

l send_data(name chunk_num, payload)メソッド③ Interestパケットの送信

l send_interest(name, chunk_num)メソッド④ パケットの受信

l receive()メソッド⑤ 簡易Consumerアプリの作成⑥ 簡易Producerアプリの作成

l register(name)メソッド

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

63

Page 64: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

①cefnetdへの接続1. 以下の内容のpythonファイルtest1.pyを作成

2. cefnetdを起動して実⾏(エラーが無ければ正常)

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

import cefpyco

with cefpyco.create_handle() as handle:

pass # ブロック開始時にcefnetdへ接続、終了時に切断

test1.py

cefore:~/cefpyco-0.4.2$ sudo csmgrdstart # if neededcefore:~/cefpyco-0.4.2$ sudo cefnetdstartcefore:~/cefpyco-0.4.2$ sudo python test1.py2019-08-22 15:14:00.123 [cefpyco] INFO: [client] Config directory is /usr/local/cefore2019-08-22 15:14:00.123 [cefpyco] INFO: [client] Local Socket Name is /tmp/cef_9896.02019-08-22 15:14:00.123 [cefpyco] INFO: [client] Listen Port is 9896

Pract ice 64

Page 65: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology 2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

n C⾔語等のセミコロンや括弧の代わりにインデントで⽂・ブロックを表現

n with構⽂︓煩雑な開始/終了/例外処理を省略できる⽂法l 代表例︓ファイルオープン・クローズ

補⾜︓pythonの⽂法

# a=1, b=1のときはbと表⽰# a=1, b≠1のときはaと表⽰# a≠1のときは何もしないif a == 1:

if b == 1:print(“b“)

else:print(“a“)

i f a = = 1 :p r i n t ( “ c o r r e c t “ )

e l s e :p r i n t ( ” e r r o r ” )

p r i n t ( “ e r r o r “ )Tab⽂字

エラー例• 空⽩4⽂字と空⽩2⽂字• 空⽩4⽂字とタブ1⽂字

ブロックの範囲を⼀⽬で⾒分けられる

インデント幅が揃っていないとバグ扱いなので要注意

print(“Begin.“)try:

h = cefpyco.CefpycoHandle()h.begin()print(“Do something.“)

except Exception as e:print(e)# 例外処理

finally:h.end()

print(“End.“)

with構⽂無しの場合

print(“Begin.“)with cefpyco.create_handle() as h:

print(“Do something.“)print(“End.“)

with構⽂を⽤いた場合

65

Page 66: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

②Dataパケットの送信1. 以下の内容のpythonファイルtest2.pyを作成

2. csmgrd・cefnetdを起動して実⾏

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

import cefpyco

with cefpyco.create_handle() as handle:# ccn:/testというコンテンツ名・チャンク番号0で

# helloというテキストコンテンツをDataパケットとして送信handle.send_data("ccn:/test", "hello", 0)

test2.py

cefore:~/cefpyco-0.4.2$ sudo csmgrdstartcefore:~/cefpyco-0.4.2$ sudo cefnetdstartcefore:~/cefpyco-0.4.2$ sudo python test2.py…cefore:~/cefpyco-0.4.2$ csmgrstatus ccn:/…***** Cache Status Report *****Number of Cached Contents : 1[0]

Content Name : ccn:/test/Content Size : 5 Bytes Access Count : 0

csmgrdにDataが

アップロードされる

Pract ice 66

Page 67: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

③Interestパケットの送信1. 以下の内容のpythonファイルtest3.pyを作成

2. (test2.py実⾏後に)test3.pyを実⾏

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

import cefpyco

with cefpyco.create_handle() as handle:# ccn:/testというコンテンツの0番目のチャンクを

# 要求するInterestパケットを送信handle.send_interest("ccn:/test", 0)

test3.py

# (test2.pyのシナリオを実行)cefore:~/cefpyco-0.4.2$ sudo python test3.py…cefore:~/cefpyco-0.4.2$ csmgrstatus ccn:/…***** Cache Status Report *****Number of Cached Contents : 1[0]

Content Name : ccn:/test/Content Size : 5 Bytes Access Count : 1

Access Countが1だけ増加

Pract ice 67

Page 68: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

④パケットの受信

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

n以下のコードでパケットを受信可能

n receive()メソッドl 実⾏後、約4秒の間 パケットを待ち受ける

• 成功するまで受信したい場合はwhileループ等が必要l CcnPacketInfoオブジェクトを返す

• 受信の成否やInterest/Dataに依らない• プロパティ⼀覧は次ページで説明

import cefpyco

with cefpyco.create_handle() as handle:handle.send_interest(“ccn:/test”, 0) # Dataパケットを受信したい場合# handle.register(“ccn:/test”) # Interestパケットを受信したい場合info = handle.receive()

68

Page 69: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

CcnPacketInfoのプロパティ

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

プロパティ名 型 説明

is_succeeded, is_failed bool パケット受信の成否フラグ

is_interest, is_data bool 受信したパケットがInterest/Dataか否かを表すフラグ(受信失敗時には両⽅ともFalseとなる)

name string URI形式(ccn:/~)の名前

name_len int URI形式の名前の⻑さ(name TLV⻑ではない)

chunk_num int チャンク番号

payload bytes (Dataパケットの場合)コンテンツのデータ

payload_s string (Dataパケットの場合)コンテンツのデータ(⽂字列として取得、バイナリデータの場合は無効)

payload_len int (Dataパケットの場合)コンテンツのデータのバイト⻑

version int 受信パケットのバージョン値

type int 受信パケットのタイプ値

actual_data_len int 受信したパケットのヘッダを含むバイト⻑

end_chunk_num int コンテンツの最後のチャンク番号(指定時のみ有効)

69

Page 70: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

from time import sleepimport cefpyco

with cefpyco.create_handle() as handle:while True:

handle.send_interest("ccn:/test", 0)info = handle.receive()if info.is_succeeded and (info.name == "ccn:/test“) and (info.chunk_num == 0):

print("Success")print(info)break

sleep(1)

⑤簡易Consumerアプリの作成n以下の内容のpythonファイルconsumer.pyを作成

l チャンクが1個しかないコンテンツccn:/testを受信l 受信に成功するまでreceiveメソッドを繰り返す

n⽳埋め問題︓l受信したCcnPacketInfoを⾒て受信に成功したか否かを検証するif⽂を完成させよう

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

consumer.py

70

Page 71: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

⑤簡易Consumerアプリの作成︓解答n以下の内容のpythonファイルconsumer.pyを作成

l チャンクが1個しかないコンテンツccn:/testを受信l 受信に成功するまでreceiveメソッドを繰り返す

n⽳埋め問題︓l受信したCcnPacketInfoを⾒て受信に成功したか否かを検証するif⽂を完成させよう

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

from time import sleepimport cefpyco

with cefpyco.create_handle() as handle:while True:

handle.send_interest("ccn:/test", 0)info = handle.receive()if info.is_succeeded and (info.name == "ccn:/test“) and (info.chunk_num == 0):

print("Success")print(info)break

sleep(1)

consumer.py

71

Page 72: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

consumer.pyの動作例

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

cefore:~/cefpyco-0.4.2$ sudo csmgrdstart…cefore:~/cefpyco-0.4.2$ sudo cefnetdstart…cefore:~/cefpyco-0.4.2$ echo hello > test; cefputfile ccn:/test…cefore:~/cefpyco-0.4.2$ sudo python consumer.py [cefpyco] Configure directory is /usr/local/cefore2019-08-22 15:16:00.123 [cefpyco] INFO: [client] Config directory is /usr/local/cefore2019-08-22 15:16:00.123 [cefpyco] INFO: [client] Local Socket Name is /tmp/cef_9896.02019-08-22 15:16:00.123 [cefpyco] INFO: [client] Listen Port is 98962019-08-22 15:16:00.123 [cefpyco] INFO: Send interest (name: ccn:/test, #chunk: 0)SuccessInfo: Succeeded to receive Data packet with name 'ccn:/test' (#chunk: 0) and payload 'hello' (6 Bytes)

ccn:/testという名前のコンテンツの0番⽬のチャンクの

取得に成功

72

Page 73: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

トラブルシューティングnProducerがInterestを受け取れない

l cefnetdのバッファやcsmgrdのキャッシュにヒットしている可能性がある• /usr/local/cefore/cefnetd.confで”CS_MODE=0”として

csmgrdを停⽌する• cefnetdの場合はしばらく待つ

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

73

Page 74: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

import cefpyco

with cefpyco.create_handle() as handle:handle.register("ccn:/test")while True:

info = handle.receive()if info.is_succeeded and (info.name == "ccn:/test“) and (info.chunk_num == 0):

handle.send_data("ccn:/test", "hello", 0)# break # Uncomment if publisher provides content once

⑥簡易Producerアプリの作成n以下の内容のpythonファイルproducer.pyを作成

l Interestを受信するにはregisterメソッドを⽤いる• register(prefix): cefnetdがInterestを受信した際に、

Interestの名前とprefixが⼀致する場合はアプリに送るように登録するためのメソッド

n⽳埋め問題︓l ”ccn:/test”宛のInterestを受け取ったら”hello”という⽂字列を返すifブロックを完成させよう

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

producer.py

74

Page 75: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

⑥簡易Producerアプリの作成︓解答n以下の内容のpythonファイルproducer.pyを作成

l Interestを受信するにはregisterメソッドを⽤いる• register(prefix): cefnetdがInterestを受信した際に、

Interestの名前とprefixが⼀致する場合はアプリに送るように登録するためのメソッド

n⽳埋め問題︓l ”ccn:/test”宛のInterestを受け取ったら”hello”という⽂字列を返すifブロックを完成させよう

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

import cefpyco

with cefpyco.create_handle() as handle:handle.register("ccn:/test")while True:

info = handle.receive()if info.is_succeeded and (info.name == "ccn:/test“) and (info.chunk_num == 0):

handle.send_data("ccn:/test", "hello", 0)# break # Uncomment if publisher provides content once

producer.py

75

Page 76: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

producer.pyの動作例n csmgrdを無効にしてから、2つの端末で以下を実⾏

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract ice

cefore:~/cefpyco-0.4.2$ sudo cefnetdstart…cefore:~/cefpyco-0.4.2$ sudo python producer.py[cefpyco] Configure directory is /usr/local/cefore2019-08-22 15:19:00.123 [cefpyco] INFO: [client] Config directory is /usr/local/cefore2019-08-22 15:19:00.123 [cefpyco] INFO: [client] Local Socket Name is /tmp/cef_9896.02019-08-22 15:19:00.123 [cefpyco] INFO: [client] Listen Port is 9896

端末1(producer)

cefore:~/cefpyco-0.4.2$ sudo python consumer.py[cefpyco] Configure directory is /usr/local/cefore2019-08-22 15:19:10.123 [cefpyco] INFO: [client] Config directory is /usr/local/cefore2019-08-22 15:19:10.123 [cefpyco] INFO: [client] Local Socket Name is /tmp/cef_9896.02019-08-22 15:19:10.123 [cefpyco] INFO: [client] Listen Port is 98962019-08-22 15:19:10.123 [cefpyco] INFO: Send interest (name: ccn:/test, #chunk: 0)SuccessInfo: Succeeded in receiving Data packet with name 'ccn:/test' (#chunk: 0) and payload 'hello' (5 Bytes)

端末2(consumer)

コンテンツ配布開始

csmgrd無しで取得に成功

76

Page 77: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

CefpycoHandle API

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Advanced

CefpycoHandleメソッド名

引数・返り値(key=valueはデフォルト値のある省略可能引数)

説明

begin • ceforedir=None: cefnetd.confの⼊ったディレクトリパス• portnum=9896: cefnetd のポート番号

cefnetdへの接続を開始する。with構⽂を利⽤する場合は⾃動で呼ばれる。

end 無し cefnetdへの接続を修了する。with構⽂を利⽤する場合は⾃動で呼ばれる。

send_interest

• name: コンテンツ名 (ccn:/…)• chunk_num=0: チャンク番号(負の数の場合はチャンク番号無し)• symbolic_f=INTEREST_TYPE_REGULAR: Interestのタイプを指定• hop_limit=32: ホップ数• lifetime=4000: Interest ライフタイム(現在の時刻からのミリ秒)

指定した名前のコンテンツを要求するInterestパケットを⽣成して送信する。

send_data

• name: コンテンツ名 (ccn:/…)• payload: Dataパケットのペイロード• chunk_num=-1: チャンク番号(負の数の場合はチャンク番号無し)• end_chunk_num=-1:コンテンツの最後のチャンク番号(負の数の場合は省略)

• hop_limit=32: 最⼤ホップ数• expirty=36000000: コンテンツ期限(現在の時刻からのミリ秒)• cache_time=-1: 推奨キャッシュ時間(負の数の場合は省略)

指定した名前とペイロードに基づいてDataパケットを⽣成して送信する。

receive• error_on_timeout=false: タイムアウト時にエラーを投げるか否か• timeout_ms=4000: 受信開始からタイムアウトまでの時間(ミリ秒)• 返り値: CcnPacketInfo (別スライド参照)

InterestまたはDataパケットを指定した時間だけ待ち受け(デフォルト4秒)、受信パケットの情報を返す。

register • name: 受信したいInterestのプレフィックス名を指定受信したい Interest のプレフィックス名をcefnetd に登録し、 receive で Interest を受け取れるようにする。

deregister • name: 登録を解除したい名前を指定 register で登録した名前を解除する。

send_symbolic_interest chunk_numとsymbolic_fが無い以外はsend_interestと同様 通常の Interest の代わりに Symbolic Interest(Cefore 独⾃機能)を送信する。

77

Page 78: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

サンプルアプリ CefApp

n cefpyco/cefappディレクトリ内の2つのアプリl cefappconsumer.py: Consumerアプリl cefappproducer.py: Producerアプリ

n特徴l 先ほどの簡易アプリと異なり、複数チャンクから成る

コンテンツの送受信に対応l ⼊出⼒はインライン・標準⼊出⼒・ファイルの3種類l cefappconsumerはパイプライン処理を実装

n詳細な使⽤法はREADME 5章参照

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

78

Page 79: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

CefApp動作例

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

cefore:~/cefpyco-0.4.2$ sudo cefnetdstart…cefore:~/cefpyco-0.4.2$ ./cefappproducer.py ccn:/test hello[cefpyco] Configure directory is /usr/local/ceforeYYYY-MM-DD hh:mm:ss.xxx [cefpyco] INFO: [client] Config directory is /usr/local/ceforeYYYY-MM-DD hh:mm:ss.xxx [cefpyco] INFO: [client] Local Socket Name is /tmp/cef_9896.0YYYY-MM-DD hh:mm:ss.xxx [cefpyco] INFO: [client] Listen Port is 9896[cefapp] Receiving Interest...

端末1(producer)

cefore:~/cefpyco-0.4.2$ sudo ./cefappconsumer.py ccn:/test[cefpyco] Configure directory is /usr/local/ceforeYYYY-MM-DD hh:mm:ss.xxx [cefpyco] INFO: [client] Config directory is /usr/local/ceforeYYYY-MM-DD hh:mm:ss.xxx [cefpyco] INFO: [client] Local Socket Name is /tmp/cef_9896.0YYYY-MM-DD hh:mm:ss.xxx [cefpyco] INFO: [client] Listen Port is 9896YYYY-MM-DD hh:mm:ss.xxx [cefpyco] INFO: Send interest (name: ccn:/test/meta, #chunk: 0)YYYY-MM-DD hh:mm:ss.xxx [cefpyco] INFO: Send interest (name: ccn:/test, #chunk: 0)[cefapp] Succeed to receive.hello

端末2(consumer)

コンテンツ配布開始

コンテンツ取得に成功

79

Page 80: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology

発展課題n複数チャンクの送受信を試してみよう

l send_interestやsend_dataをチャンク数に応じて複数回実⾏するしてみよう

l end_chunk_numを指定して取得すべきチャンク数だけ要求を出すようにしてみよう

n cefgetfile/cefputfileと同等の機能を作ってみようl ファイルを読み書きして送受信できるようにしようl ⼤きなファイルに対応するためのパイプライン処理を

作ってみよう• CefAppのコード等を参考

n cefpyco/c_src/cefpyco.cやceforeのツールを参考に、C⾔語でアプリを作ってみよう

2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン

Pract iceAdvanced

80

Page 81: 松園v5 01 Ceforeハンズオン資料 v0 0 3icn/wp-content/uploads/2019/08/...Android •ルータ ②Transportプラグインで ストリーミング通信をサポート ③キャッシュ機能を追加

© 2019 National Institute of Information and Communications Technology 2019/8/22(⽊)第16回 ICN研究会ワークショップ ハンズオン