2019年12月27日 星期五
ser2net
https://groups.google.com/forum/#!topic/beagleboard/6am1GKyo60s
http://single9.net/2015/07/beaglebone-black-開啟-gpio-上的-uart-接腳/
tmux
tmate
2019年12月7日 星期六
A-law
| Linear input | Compressed code XOR 01010101 | Linear output |
|---|---|---|
| s0000000abcdx | s000abcd | s0000000abcd1 |
| s0000001abcdx | s001abcd | s0000001abcd1 |
| s000001abcdxx | s010abcd | s000001abcd10 |
| s00001abcdxxx | s011abcd | s00001abcd100 |
| s0001abcdxxxx | s100abcd | s0001abcd1000 |
| s001abcdxxxxx | s101abcd | s001abcd10000 |
| s01abcdxxxxxx | s110abcd | s01abcd100000 |
| s1abcdxxxxxxx | s111abcd | s1abcd1000000 |
| 十進位 | 二進位 | seg | EBI 前 | EBI 後 | 解碼 |
|---|---|---|---|---|---|
| 3968~4095 ... 2048~2175 | 011111xxxxxxx ... 010000xxxxxxx | 111 | 11111111 ... 11110000 | 10101010 (0xAA) ... 10100101 (0xA5) | 4032 ... 2112 |
| 1984~2047 ... 1024~1087 | 0011111xxxxxx ... 0010000xxxxxx | 110 | 11101111 ... 11100000 | 10111010 (0xBA) ... 10110101 (0xB5) | 2016 ... 1056 |
| 992~1023 ... 512~543 | 00011111xxxxx ... 00010000xxxxx | 101 | 11011111 ... 11010000 | 10001010 (0x8A) ... 10000101 (0x85) | 1008 ... 528 |
| 496~511 ... 256~271 | 000011111xxxx ... 000010000xxxx | 100 | 11001111 ... 11000000 | 10011010 (0x9A) ... 10010101 (0x95) | 504 ... 264 |
| 248~255 ... 128~135 | 0000011111xxx ... 0000010000xxx | 011 | 10111111 ... 10110000 | 11101010 (0xEA) ... 11100101 (0xE5) | 252 ... 132 |
| 124~127 ... 64~67 | 00000011111xx ... 00000010000xx | 010 | 10101111 ... 10100000 | 11111010 (0xFA) ... 11110101 (0xF5) | 126 ... 66 |
| 62, 63 ... 32, 33 | 000000011111x ... 000000010000x | 001 | 10011111 ... 10010000 | 11001010 (0xCA) ... 11000101 (0xC5) | 63 ... 33 |
| 30, 31 ... 0, 1 | 000000001111x ... 000000000000x | 000 | 10001111 ... 10000000 | 11011010 (0xDA) ... 11010101 (0xD5) | 31 ... 1 |
| -0, -1 ... -30, -31 | 100000000000x ... 100000001111x | 000 | 00000000 ... 00001111 | 01010101 (0x55) ... 01011010 (0x5A) | -1 ... -31 |
| -32, -33 ... -62, -63 | 100000010000x ... 100000011111x | 001 | 00010000 ... 00011111 | 01000101 (0x45) ... 01001010 (0x4A) | -33 ... -63 |
| -64~-67 ... -124~-127 | 10000010000xx ... 10000011111xx | 010 | 00100000 ... 00101111 | 01111010 (0x7A) ... 01110101 (0x75) | -66 ... -126 |
2019年12月1日 星期日
Network Slicing
使用 4G 網路主要終端設備是手機,網路部份包括無線接入網路 (RAN) 和核心網路 (Core Network),採用專用設備。為了做網路切片,需要網路功能虛擬化 (NFV,Network Function Virtualization),將 RAN 和 Core Network 專用設備的軟硬體轉移到商用虛擬主機 (VM),RAN 的部份叫邊緣雲 (Edge Cloud),核心網部分叫核心雲 (Core Cloud)。這些 VM 透過 SDN 互通。
針對不同應用的切片
手機切片:核心雲放 IMS
高解析影片切片:邊緣雲可能需要儲存設備暫存,經過核心雲上影片提供者網路
物聯網切片:不需要移動管理
車聯網切片:為了減低延遲,許多功能都放到邊緣雲。
RAN 佈建因基地台遠近等因數可能有好幾階 (tier),但延遲考量會使用越接近基地台的 VM,甚至擺到基地台裡。
SDN Controller 控制 SDN,SDN 需要保證切割的頻寬又不能造成太多延遲。
- OTN (optical transport network) and Wavelength Slicing (Hard slicing):依據波長共用光纖網路 (DWDM、ROADM)。
- Flexible Ethernet (FlexE) (Soft slicing):透過 TDM 方式減少延遲來提供動態頻寬。
- Service Provisioning (L3 slicing): Segment Routing (TE) and Enhanced VPN:透過集中的 path computation element (PCE) 使用 source-based routing。
user plane functions (UPFs)、multi-access edge computing(MEC)、eCPRI、Time Sensitive Networking(TSN)、Telecom Infra Project (TIP) fronthaul
參考:
- 5G這把瑞士軍刀,如何網路切片?
- https://www.ecitele.com/wp-content/uploads/2019/03/Network-slicing-WP-F.pdf
- https://www.2cm.com.tw/2cm/zh-tw/market/FEB3C8CEEC624761B9F9276F9D93ABB6
- http://www.telecom-marketforum.com/2019/exhibition16.html
- http://www.ieee802.org/1/files/public/docs2018/detnet-tsn-wang-for-servcice-provider-networks-1118-v01.pdf
- https://www.fujitsu.com/us/Images/New-Transport-Network-Architectures-for-5G-RAN.pdf
- https://www.itu.int/dms_pub/itu-t/opb/tut/T-TUT-HOME-2018-PDF-E.pdf
2019年11月29日 星期五
Cut-through Switching
而 Cut through 收到封包的 Destination MAC 就馬上開始進行轉送,減少接收剩下資料的延遲,但沒檢查 CRC 錯誤的封包沒丟棄。延遲計算是收到第一個 bit 到送出第一的 bit 的時間。
Fragment free
應用:需要很低延遲的應用。
Adaptive switching 是動態切換 cut-throught 或 store-and-forward。
Wormhole switching:封包切成 flits (flow control units)。通常第一個 flit (header flit) 有位址資訊建立到輸出口的連線,剩下 flits 沿用直到最後 flit (tail flits) 關閉連線。出口 buffer 滿了,後送 "back-pressure" 告知來源暫停傳送。
參考
- https://hlchang.com/2010/08/cut-through-捲土重來/
- https://en.wikipedia.org/wiki/Cut-through_switching
- https://en.wikipedia.org/wiki/Wormhole_switching
2019年11月23日 星期六
OpenWrt REVISION
用途
- base-files VERSION 一部分
- VERSION_SED 取代 %R:用在 /etc/banner, /etc/openwrt_version, /etc/openwrt_release, /etc/device_info, /etc/opkg/distfeeds.conf
- repositories.conf
- mac80211 編譯 compat_version
- netgear-dni、tplink-safeloader
ssh client
有個方便的用處是,當 ssh 伺服器不是使用預設通訊埠時,可以寫在設定檔裡,這樣 ssh 連線時就不用再額外指定通訊埠。此外也可以設定別名。
連線到伺服器有些情況會有 locale 問題,可以關掉 SendEnv。但由於 SendEnv 是累加的,不是不設 SendEnv 或將 SendEnv 設為空白就可以,如果 /etc/ssh/ssh_config 有設 SendEnv,也需要移除。
問題:no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
- 加參數 -oKexAlgorithms=+diffie-hellman-group1-sha1
- 設定加入連線加密方法
- 參考
指令參數
- -N:不執行遠端指令
- -nNT:不開 tty
- -f:背景執行
- -L:local port forwarding
- -D:dynamic port forwarding
- -R:remote port forwarding
- -X:X11 Forwarding
SSH tunnel
local port forwarding
ssh client 近端一個 port 透過 SSH 通到 ssh server,然後存取遠端 remotehost:remoteport:
ssh -L localport:remotehost:remoteport user@example.com
連 ssh client 的 localport,相當於連到遠端的 remotehost:remoteport,SSH server 會去解析 remotehost。遠端位置可能是 Web Server、RDP Server、VNC Server 等。
dynamic port forwording
同 local port forwarding,但最終位置不指定,改依 L5 SOCKS 協定的 handshake 得知。可用於任何 TCP/UDP socket 連線。provide a local SOCKS 4/4A/5 proxy on a local port
ssh -D localport user@example.com
所有連 ssh client 的 localport,都會連到 SSH server 再去進行連線到最終位置。例如 Firefox 等瀏覽器可設定 SOCKS proxy 為 SSH client 的 localport,網頁就會透過 SSH server 去連線。參考:https://linuxize.com/post/how-to-setup-ssh-socks-tunnel-for-private-browsing/
remote port forwarding
遠端 ssh server 的一個 port 透過 SSH 通到 ssh client,然後存取近端的 localhost:port:
ssh -R 9000:localhost:3000 user@example.com
SSH server 預設不允許 remote port forwarding,啟用需要在 /etc/ssh/sshd_config 加
GatewayPorts yes
然後重啟
sudo service ssh restart
連遠端 ssh server 的 port,相當於連到近端的 localhost:port。
ssh client
| PuTTY | pieTTY | Xshell | FireSSH | zterm | |
| 安裝 | 可免安裝 | 可免安裝 | 需要安裝,個人用免費 | JavaScript 版,給 Firefox 使用 | Java 版,用於各式瀏覽器,需要 Java 執行環境 |
|---|---|---|---|---|---|
| 拖曳傳擋 | 有 (sftp,需要輸入密碼、選目錄) | 有 (sftp) | |||
| Tab | 有 | ||||
| 中文 | 有 | ||||
| 判斷字元自動輸入 | 有 | ||||
| 其它說明 | 基於 PuTTY,但沒隨時跟上更新 | 有 |
選項設定
ssh 依照下列優先來源取得設定:
- command-line options
- 個人設定檔:~/.ssh/config
- 系統設定檔:/etc/ssh/ssh_config
設定檔包含 host 規範的 section,只要符合指令行的主機名稱就有效 (見 CanonicalizeHostname)。由於每個參數使用第一個取得的值,越 host 特殊的宣告應該要放在前面,越通用的放後面。
設定檔包含 keyword-argument 對,每對一行。# 開始的行和空白行是註解。argument 可用双引號包起來,為了包含空白。Configuration options may be separated by whitespace or optional whitespace and exactly one ‘=’; the latter format is useful to avoid the need to quote whitespace when specifying configuration options using the ssh, scp, and sftp -o option.
keyword argument
keyword=argument
keyword =arguemnt
keyword 不分大小寫,argument 分大小寫。
- Host
接下來設定區塊 (到下個的 Host 或 Match 為止) 適用的 host,多個用 whitespace 分隔。「*」表示所有 host。The host is usually the hostname argument given on the command line (見 CanonicalizeHostname).
A pattern entry may be negated by prefixing it with an exclamation mark (‘!’). If a negated entry is matched, then the Host entry is ignored, regardless of whether any other patterns on the line match. Negated matches are therefore useful to provide exceptions for wildcard matches.
See PATTERNS for more information on patterns.
- Match
接下來設定區塊 (到下個的 Host 或 Match 為止) 適用的條件,可多個,前置驚嘆號否定。
all: 都符合。必須單獨使用或緊接著 canonical 或 final 之後。
canonical:遠端 hostname 有 canonicalization 時額外套用。
final:最後額外套用。
exec 指令:在 shell 在執行指令回 0 時。指令有 whitespace characters 要quoted,接受 token %%、%h、%i、%L、%l、%n、%p、%r、和 %u。
The other keywords' criteria must be single entries or comma-separated lists and may use the wildcard and negation operators described in the PATTERNS section.
host hostname:比對 Hostname 或 CanonicalizeHostname 轉換過後 hostname 符合。
originalhost hostname:比對指令行原始 hostname 符合。
user user:比對遠端帳號符合。
localuser user:比對本地帳號符合。在系統設定檔較有用。
- BatchMode
- 如果設為 yes,user interaction such as password prompts and host key confirmation requests will be disabled. In addition, the ServerAliveInterval option will be set to 300 seconds by default (Debian-specific). This option is useful in scripts and other batch jobs where no user is present to interact with ssh(1), and where it is desirable to detect a broken network swiftly. The argument must be yes or no (the default).
- CanonicalizeHostname
- 控制是否進行 hostname canonicalization。參考:https://sleeplessbeastie.eu/2020/08/24/how-to-perform-hostname-canonicalization/
預設 no:使用系統 resolver 處理 hostname lookups。
設為 yes:不用 ProxyCommand 或 ProxyJump 的連線,嘗試使用 CanonicalDomains 後綴和 CanonicalizePermittedCNAMEs 規則來canonicalize 指令行的 hostname。
設為 always:也用在 proxied 的連線。
設為 enabled:the configuration files are processed again using the new target name to pick up any new configuration in matching Host and Match stanzas.
- CheckHostIP
-
預設是 yes,額外檢查 known_hosts 檔的 host IP 位址,無論 StrictHostKeyChecking 的設定都會加 host 位址到 ~/.ssh/known_hosts,用來偵測 host key 是否因為 DNS spoofing 而改變。
If the option is set to no, the check will not be executed.
- Hostname
- 實際要登入的 host name,可以是 nicknames or abbreviations,接受 token %% and %h,可以是數字 IP (both on the command line and in Hostname specifications). The default is the name given on the command line.
- KexAlgorithms
- 指定可用的 KEX (Key Exchange) 演算法. Multiple algorithms must be comma-separated. If the specified list begins with a ‘+’ character, then the specified methods will be appended to the default set instead of replacing them. If the specified list begins with a ‘-’ character, then the specified methods (in‐ cluding wildcards) will be removed from the default set instead of replacing them. If the specified list begins with a ‘^’ char‐ acter, then the specified methods will be placed at the head of the default set. The default is: curve25519-sha256,curve25519-sha256@libssh.org, ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256 The list of available key exchange algorithms may also be ob‐ tained using "ssh -Q kex".
- NumberOfPasswordPrompts
- 密碼嘗試次數,預設是 3。
- PasswordAuthentication
- 是否使用密碼認證,yes (預設) 或 no。
- Port
- 遠端 port,方便不是預設的 22。
- PreferredAuthentications
- 嘗試認證方式的順序,預設是 gssapi-with-mic,hostbased,publickey,keyboard-interactive,password。
- ServerAliveInterval
- Sets a timeout interval 秒數 after which if no data has been received from the server, ssh 會送 message to request a response from the server. The default is 0, indicating that these messages will not be sent to the server, or 300 if the BatchMode option is set (Debian-spe‐ cific). ProtocolKeepAlives and SetupTimeOut are Debian-specific compatibility aliases for this option.
- StrictHostKeyChecking
-
預設是 ask,新 host 的 key 在使用者同意後加入 ~/.ssh/known_hosts。host key 改變會拒絕連線。
設為 accept-new,自動加新 host 的 key。host key 改變會拒絕連線。
設為 yes,使用者必須手動加入新 host 的 key。host key 改變會拒絕連線。提供 man-in-the-middle (MITM) 攻擊最大的保護, though it can be annoying when the /etc/ssh/ssh_known_hosts file is poorly maintained or when connections to new hosts are frequently made.
設為 no 或 off,自動加新 host 的 key。host key 改變會檢查,除了一些限制外,仍允許連線。
- User
- 指定登入帳號。
- UserKnownHostsFile
-
Specifies one or more files to use for the user host key database, separated by whitespace. 預設是「~/.ssh/known_hosts ~/.ssh/known_hosts2」。
設為 UserKnownHostsFile=/dev/null
- VerifyHostKeyDNS
-
Specifies whether to verify the remote key using DNS and SSHFP resource records.
設為 yes, the client will implicitly trust keys that match a secure fingerprint from DNS. Insecure fingerprints will be handled as if this option was set to ask.
設為 ask, information on fingerprint match will be displayed, but the user will still need to confirm new host keys according to the StrictHostKeyChecking option.
預設是 no。
See also VERIFYING HOST KEYS in ssh(1).
PATTERNS
pattern 是 0 或更多 non-whitespace characters
*:代表 0 或更多 characters
?:代表 1 個 character
pattern-list 是逗號分隔的 pattern 列表。裡面的 pattern 可以前置驚嘆號來否定。要注意的是否定符合本身不會變成正面的符合結果,例如下列結果 host3 並不符合:
from="!host1,!host2"
一種解決方式是包含一項達到正面符合,如 wildcard:
from="!host1,!host2,*"
TOKENS
有些 keyword 的 argument 可用 token,意思如下:
| %% | % |
| %C | Hash of %l%h%p%r。 |
| %d | 自己的家目錄。 |
| %h | 遠端 hostname。 |
| %i | 自己 user ID。 |
| %L | 自己 hostname。 |
| %l | 自己 hostname, including the domain name。 |
| %n | 原始指令行的遠端 hostname。 |
| %p | 遠端 port。 |
| %r | 遠端 username。 |
| %T | 請求 tunnel forwarding 指定的 tun 或 tap 網路界面,無則 "NONE"。 |
| %u | 自己 username。 |
CertificateFile accepts the tokens %%, %d, %h, %i, %l, %r, and %u.
ControlPath accepts the tokens %%, %C, %h, %i, %L, %l, %n, %p, %r, and
%u.
IdentityAgent and IdentityFile accept the tokens %%, %d, %h, %i, %l, %r,
and %u.
LocalCommand accepts the tokens %%, %C, %d, %h, %i, %l, %n, %p, %r, %T,
and %u.
ProxyCommand accepts the tokens %%, %h, %n, %p, and %r.
RemoteCommand accepts the tokens %%, %C, %d, %h, %i, %l, %n, %p, %r, and
%u.
問題
參考
- http://stackoverflow.com/questions/7332124/gitolite-with-non-default-port
- man ssh
- 基於 sftp 的 sshfs。
- http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
- Bash ssh 由歷史資料來自動補齊主機名稱
- man ssh_config
SEE ALSO
scp(1), ssh-add(1), ssh-agent(1), ssh-argv0(1), ssh-keygen(1),ssh-keyscan(1), tun(4), ssh-keysign(8), sshd(8)
待讀
https://www.bitvise.com/remote-desktop
http://www.howtogeek.com/114812/5-cool-things-you-can-do-with-an-ssh-server/
http://www.linuxjournal.com/content/more-secure-ssh-connections?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+linuxjournalcom+%28Linux+Journal+-+The+Original+Magazine+of+the+Linux+Community%29
http://www.cyberciti.biz/faq/install-ssh-identity-key-remote-host/
[Linux 透過 SSH SOCKS 連線 來 使用 Firefox / Pidgin(MSN, GTalk..)](https://blog.longwin.com.tw/2010/01/linux-ssh-socks-firefox-pidgin-2010/)
2019年11月16日 星期六
sftp
指令格式
sftp [-46aCfpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
[-D sftp_server_path] [-F ssh_config] [-i identity_file] [-l limit]
[-o ssh_option] [-P port] [-R num_requests] [-S program]
[-s subsystem | sftp_server] hostsftp [user@]host[:file ...] #取得特定檔案sftp [user@]host[:dir[/]] #指定遠端起始目錄sftp -b batchfile [user@]host #自動 session因為有些用法使用分號區隔主機名稱和檔名路徑,IPv6 位址需要用方括號來區別。
參數:見 man sftp。
指令:類似 ftp 用的指令,不分大小寫,有 space 的檔名路徑需要加 quotes,pathname 的特殊字元 (見 glob() 函數) 需要 backslashes (‘\’) 跳脫。見 man sftp。
參考:
- man sftp
- sshfs
SIP header Via
所有 SIP 訊息 都要有 Via,縮寫 v。一開始的 UAC 和後續途經的每個 proxy 都會疊加一個 Via 放傳送的位址,依序作為回應的路徑。 格式 sent-protocol sent-by [ ;branch= branch ][ ; 參數 ...] s...
-
驅動程式除了 read()/write() 外,通常可以透過 ioctl() 系統呼叫進行一些控制或設定,如鎖門、退片、回報錯誤、改變 baud rate、或 self destruct 等。 在 user space 格式如下: #include <sys/ioctl...
-
74HC595 74 系列的移位暫存器 IC 基本上都有序列輸入 (serial-input, SI) 及序列輸出 (serial-output, SO) 功能,有些有加上並列輸入 (parallel-input, PI) 或並列輸出 (parallel-output...
-
網路界面驅動程式有兩種接收封包的方式 -- 中斷驅動和 NAPI。傳統是用中斷驅動,在中斷服務程式裡接收封包,但封包量大時會有中斷次數太多而效能變差的問題。NAPI (意思是 New API) 改成中斷服務程式只通知有封包,Kernel 再排程一次接收多個封包來提昇效能。 中...