2019年12月25日水曜日

TCP技術入門を読んだ

とりあえず読みました。
キーワードだけでも抽出しました。その後深堀していく予定。
この本のメインは輻輳制御アルゴリズム。


TCP入門

UDPについて
 HTTP over QUIC
TCPの基礎
 RUDP UDPの信頼性機能追加
 WTCP 携帯特化のTCP
 SCTP 信頼性の高い順序データ配信。メッセージ指向、マルチホーミング、マルチストリーミング、生存確認(ハートビート)、イニシエーションの改善。
 DCCP UDPの輻輳緩和目的

TCP/IPの変遷

 ARPANETの歴史から輻輳制御アルゴリズム導入。インターネット、無線、モバイル、クラウド、IoT LPWAなど。

TCPとデータ転送

ヘッダフォーマット。
コネクション管理。確立、切断
フロー制御、ウィンドウ制御
輻輳制御
再送制御
初期のアルゴリズム
 Tahoe
 Reno
 NewReno
 Vegas


輻輳制御アルゴリズム

輻輳制御の考え方  
輻輳制御の有限オートマトン
  状態
   open
   disorder
   recovery
   CWR   
   Loss
アルゴリズム
Lossbase 、Delaybase 、Hybrid
 NewReno
 AIMD
 Vegas
 Westwood
 HighSpeed
 Veno
 BIC
 HTCP
 Hybla
 Illinois
 YeAH

CUBIC

Linux標準の輻輳アルゴリズム
BICの輻輳ウィンドウサイズ増加関数を三次関数に置き換え。
擬似コードで確認

BBR

Googleが開発したアルゴリズム。
Delaybase輻輳制御
GCPでも使用。
擬似コードで確認

TCPの最新動向

通信端末の多様化
 センサー
 スマートデバイス
 M2M
接続先の変化 
 クラウド
 エッジ
 マルチアクセスエッジコンピューティング
5G
 eMBB 8Kなど
 mMTT IoT
 URLLC 自動運転、ROS
 ミリ波帯
 マルチパスTCP
IoT
 LWIG
 CoCoA
 NIDD
データセンター
 DCTCP
自動運転
 輻輳制御が必須




2019年11月9日土曜日

rasberrypiにstackをインストールしてビルドできるようにする

rasberrypi3 にhaskellのビルドツールstackをインストールして、ビルドできるようにする。
過去の情報は色々あったのですが、古い情報であったので、2019年版としてまとめておきます。

> curl -sSL https://get.haskellstack.org/ | sh
> stack new sample
> stack build
エラー発生
No setup information found for ghc-8.6.5 on your platform.
This probably means a GHC bindist has not yet been added for OS key 'linux-armv7'.
Supported versions: ghc-7.10.2, ghc-7.10.3, ghc-8.0.1, ghc-8.0.2, ghc-8.2.1, ghc-8.2.2, ghc-8.6.3

ghc-8.6.3に変更して、再度ビルド したが、別のエラーが発生した。
armの命令が不足しているとエラーが出力される。
[1 of 2] Compiling Main             ( /home/pi/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /home/pi/.stack/setup-exe-src/setup-mPHDZzAJ.o )
/tmp/ghc20362_0/ghc_6.s: Assembler messages:

/tmp/ghc20362_0/ghc_6.s:43:0: error:
     Error: selected processor does not support `movw r7,:lower16:stg_bh_upd_frame_info' in ARM mode
   |
43 |         movw    r7, :lower16:stg_bh_upd_frame_info

stack ghc でコンパイルしてみるが、同様のエラーが出る。
 コンパイルオプションでアーキテクチャ指定していないためエラーが出ているっぽい。 アーキテクチャ指定してビルドする。
ghc -opta-march=armv7-a Main.hs
ビルド成功。 stack buildでも同様にコンパイルオプションでアーキテクチャを指定できるようにする。 $HOME/.stack/config.yaml あたりをいじってみたが。。。いまいち反映されない。 ~/.stack/programs/arm-linux/ghc-8.6.3/bin/ghc-8.6.3 のスクリプトを修正する。
cat ~/.stack/programs/arm-linux/ghc-8.6.3/bin/ghc-8.6.3

#!/bin/sh
exedir="/home/xx/.stack/programs/arm-linux/ghc-8.6.3/lib/ghc-8.6.3/bin"
exeprog="ghc-stage2"
executablename="$exedir/$exeprog"
datadir="/home/xx/.stack/programs/arm-linux/ghc-8.6.3/share"
bindir="/home/xx/.stack/programs/arm-linux/ghc-8.6.3/bin"
topdir="/home/xx/.stack/programs/arm-linux/ghc-8.6.3/lib/ghc-8.6.3"
executablename="$exedir/ghc"
exec "$executablename"  -opta-march=armv7-a -B"$topdir" ${1+"$@"}
#exec "$executablename" -B"$topdir" ${1+"$@"}
この変更でビルドしたら成功した。
多分本来はglobalの設定で反映できるのだろうが、今のところこれで運用する。


2019年1月18日金曜日

mqtt-hsを使う時の注意点

stack でmqtt-hsを使おうとした時につまずいた点をまとめておく。
haskell初心者のため、正しい対処かどうかが不明です。


https://github.com/k00mi/mqtt-hs/blob/master/examples/subscribe.hs
のサンプルを動かしてみる。
package.yamlに下記を追加。


  dependencies:
      - mqtt-hs
      - stm

stack buildしたが、


Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for mqtt-sample2-0.1.0.0:
    mqtt-hs needed, but the stack configuration has no specified version  (latest matching version is 1.0.2)
needed since mqtt-sample2 is a build target.

Some different approaches to resolving this:

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be
    convenient when dealing with many complicated constraint errors, but results may be unpredictable.

  * Recommended action: try adding the following to your extra-deps in /Users/xxxxx/git/yyyy/mqtt-sample2/stack.yaml:

mqtt-hs-1.0.2@sha256:db49cf78d8fb9dbffc01c2bc8cb4f8657b796865fdb7c4711ed59cddd8418f87

Plan construction failed.

extra-depsに追加しろと言われたので、追加。



extra-deps:
    - mqtt-hs-1.0.2

またエラーが出た。


Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for mqtt-hs-1.0.2:
    base-4.12.0.0 from stack configuration does not match >=4.6 && <4 .12="" span="">  (latest matching version is 4.11.1.0)
    network-2.8.0.0 from stack configuration does not match >=2.0 && <2 .7="" span="">  (latest matching version is 2.6.3.6)
    singletons-2.5.1 from stack configuration does not match >=0.9 && <2 .5="" span="">  (latest matching version is 2.4.1)
    stm-2.5.0.0 from stack configuration does not match >=2.4 && <2 .5="" span="">  (latest matching version is 2.4.5.1)
needed due to mqtt-sample2-0.1.0.0 -> mqtt-hs-1.0.2

Some different approaches to resolving this:

  * Set 'allow-newer: true' in /Users/xxxx/.stack/config.yaml to ignore all version constraints and build anyway.

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be
    convenient when dealing with many complicated constraint errors, but results may be unpredictable.

  * Build requires unattainable version of base. Since base is a part of GHC, you most likely need to use a different GHC version with the
    matching base.

Plan construction failed.

allow-newer:trueにするのは嫌なので、stack solverを実行してみる。
しかしこれでも怒られる。


Using configuration file: stack.yaml
Using cabal packages:
- ./

Using resolver: lts-13.3

Warning: Installed version of cabal-install (2.2.0.0) is newer than stack has been tested with.  If you run into difficulties, consider downgrading.
         
Using compiler: ghc-8.6.3
Asking cabal to calculate a build plan...
Trying with packages from lts-13.3 and 1 external packages as hard constraints...
Attempt failed.

>>>> Cabal errors begin
Warning: Unknown/unsupported 'ghc' version detected (Cabal 2.2.0.1 supports
'ghc' version < 8.5):
/Users/xxxx/.stack/programs/x86_64-osx/ghc-8.6.3/bin/ghc is version 8.6.3
Warning: cannot determine version of /usr/bin/strip :
""
CallStack (from HasCallStack):
  die', called at ./Distribution/Client/Install.hs:238:21 in main:Distribution.Client.Install
cabal: Could not resolve dependencies:
[__0] trying: mqtt-sample2-0.1.0.0 (user goal)
[__1] trying: mqtt-hs-1.0.2 (dependency of mqtt-sample2)
[__2] next goal: base (dependency of mqtt-sample2)
[__2] rejecting: base-4.12.0.0/installed-4.1... (conflict: mqtt-hs =>
base>=4.6 && <4 .12="" span="">
[__2] rejecting: base-4.12.0.0 (constraint from non-upgradeable package
requires installed instance)
[__2] rejecting: base-4.11.1.0, base-4.11.0.0, base-4.10.1.0, base-4.10.0.0,
base-4.9.1.0, base-4.9.0.0, base-4.8.2.0, base-4.8.1.0, base-4.8.0.0,
base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, base-4.6.0.1, base-4.6.0.0,
base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, base-4.4.0.0, base-4.3.1.0,
base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, base-4.2.0.0, base-4.1.0.0,
base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 (constraint from main config
/private/var/folders/q1/rf5gg7zj7h9c07hn60_m1tcr0000gn/T/cabal-solver31325/cabal.config
requires ==4.12.0.0)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base (30), mqtt-hs (5), mqtt-sample2
(3)

<<<< Cabal errors end

Could not parse cabal-install errors:

>>>> Cabal errors begin
Warning: Unknown/unsupported 'ghc' version detected (Cabal 2.2.0.1 supports
'ghc' version < 8.5):
/Users/xxxxxxx/.stack/programs/x86_64-osx/ghc-8.6.3/bin/ghc is version 8.6.3
Warning: cannot determine version of /usr/bin/strip :
""
CallStack (from HasCallStack):
  die', called at ./Distribution/Client/Install.hs:238:21 in main:Distribution.Client.Install
cabal: Could not resolve dependencies:
[__0] trying: mqtt-sample2-0.1.0.0 (user goal)
[__1] trying: mqtt-hs-1.0.2 (dependency of mqtt-sample2)
[__2] next goal: base (dependency of mqtt-sample2)
[__2] rejecting: base-4.12.0.0/installed-4.1... (conflict: mqtt-hs =>
base>=4.6 && <4 .12="" span="">
[__2] rejecting: base-4.12.0.0 (constraint from non-upgradeable package
requires installed instance)
[__2] rejecting: base-4.11.1.0, base-4.11.0.0, base-4.10.1.0, base-4.10.0.0,
base-4.9.1.0, base-4.9.0.0, base-4.8.2.0, base-4.8.1.0, base-4.8.0.0,
base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, base-4.6.0.1, base-4.6.0.0,
base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, base-4.4.0.0, base-4.3.1.0,
base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, base-4.2.0.0, base-4.1.0.0,
base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 (constraint from main config
/private/var/folders/q1/rf5gg7zj7h9c07hn60_m1tcr0000gn/T/cabal-solver31325/cabal.config
requires ==4.12.0.0)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base (30), mqtt-hs (5), mqtt-sample2
(3)

<<<< Cabal errors end

CallStack (from HasCallStack):
  error, called at src/Stack/Solver.hs:131:25 in stack-1.9.3-AFEUqDV1V61AarVAbZ7WId:Stack.Solver

ghcのバージョンが問題らしいログ。
package.yamlのresolverが結構新しいし、mqtt-hsでテストがpassしているバージョンではないらしい。


resolver: lts-13.3

テストの通っているghcのバージョンに合わせる。

resolver: lts-11.22

無事buildができた。