2010年10月28日 星期四

利用 ICMP 模擬 G.729 語音封包來測試 VoIP 品質

G.729 語音壓縮的標準,是採用週期性的方式每 20 ms 產生一個 20 bytes 的語音封包 (Voice Payload),之後當語音封包封裝成IP 格式,其實在裡面已經增加了 3 個 header,分別是 RTP (12 bytes), UDP (8 bytes), IP (20 bytes),共 60 bytes 所以在設定參數如下:

-s size 參數設定為 52 (ICMP 自己會加上 8bytes 在 header , 所以最後大小為 60 bytes)
-i interval 設定為 0.02 (G.729 預設為 20 ms)
-c count 設定為 100 , 即送 100 個封包,此處可視情況增減

需先切換為 root
su -
再下 ping 指令
ping -s 52 -i 0.02 -c 100 Destination IP

如果 ping 的統計結果有出現 packet loss 的情況,可能即為該線路頻寬不足 (小於1M/64k)、不良(雜訊)或者是內部流量過大等情形,即使用者打 VoIP 會有通話斷斷續續的情況。


2010年10月26日 星期二

在Uboot下使用ckermit透過com port來download image file

u-boot的官方網站已經說很清楚了。看這裡:
http://www.denx.de/wiki/view/DULG/UBootCmdGroupDownload#Section_5.9.5.3.

minicom is another popular serial communication program. Unfortunately, many users have reported problems using it with U-Boot and Linux, especially when trying to use it for serial image download. It's use is therefore discouraged.



* 下載 cku211.tar.gz 

* 解壓縮後 編譯: make linux;make install



* 編譯完成後執行 : kermit 


* Kermit的配置範例(可設定於~/.kermrc):
set line /dev/ttyS0
set speed 115200
set carrier-watch off
set handshake none
set flow-control none
robust
set file type bin
set file name lit
set rec pack 1000
set send pack 1000
set window 5


* 連上板子 : connect or c


*  切換 : 按下Ctrl + \  , 再按C 可以跳回kermit; 若欲跳回console可以再輸入c or connect。

* uboot上輸入 :  eraseall b

*  傳送檔案 send /path/filename



 補充:搭配minicom使用

*使用minicom -s,到"檔案傳輸協定"或"File Transfer protocols"裡的G和H,

     G設定為/usr/local/bin/kermit -i -l %f -b %b -s           Y U Y N N,

     H設定為/usr/local/bin/kermit -i -l %f -b %b -r           N D Y N N。

* 開始傳檔
執行Ctrl+A -> S,接著選完檔案後即可開始傳送檔案了

2010年10月25日 星期一

2010年10月22日 星期五

Fedora 12以root用戶登錄的方法

首先以用戶賬號進入終端,允許root賬號登陸:
  $ su
  $ vi /etc/pam.d/gdm
  刪除其中的一行auth required pam_succeed_if.souser != root quiet
  :wq保存並退出。
  $ vi /etc/pam.d/gdm-passwaord
  刪除其中的一行auth required pam_succeed_if.souser != root quiet
  :wq保存並退出。
  這樣就可以使用root進行GUI登陸了。
  還可以修改/etc/gdm/custom.conf文件,增加下面幾行,啟用root自動登陸
  [daemon]
  AutomaticLoginEnable=true
  AutomaticLogin=user_name
  Fedora 12的網絡服務不能自動啟動,同樣需要修改
  chkconfig --level 35 network on
  如果使用GUI界面去修改網絡配置,貌似那個修改程序有BUG,子網掩碼改完了再打開就變成了192.168.1.1
  同樣,可以在文件中直接修改。
  文件位置:/etc/sysconfig/network-scripts/ifcfg-eth0

MII, GMII, RGMII

基本上,這三個的作用是一樣的
同樣都是連結MAC層和PHY層的介面區別在於編碼、速度、使用的腳位數、I/O clock的頻率不同。

MII:這是IEEE 802.3u制定出來,應用在Fast Ethernet上,連
接Data link layer中的MAC層和Physical Layer中的PHY層的溝通介面。全名為(Media Independent Interface)。
(這樣的說法有點瑕庛,因為Data link layer有分為MAC層和LLC層,但Physical Layer沒有分其它的層別,統稱為PHY層)

MII使用8B/10B之編碼。所以運作在125Mbps時,可以傳送包含檔頭的100Mbps的資料。
(想成有八條水管,同時有125Mbps的資料流進來,通過了一個闡道,要流到十條水管裡去,這十條水管的平均流速就是125Mbps*8/10=100Mbps。)

IC對PHY做讀寫的時候用一組訊號:MDC(Management Data Control)與MDIO(Management Data Input/Output)。
輸出和輸入各有四個bit的匯流排: Tx[0:3]、Rx[0:3](輸出是指IC到PHY、輸入是指PHY到IC)

MII對於Data Sampling reference用的兩組clock,頻率為25MHz
這兩個訊號為Tx_CLK和Rx_CLK。(Ethernet頻率為2.5MHz)

通知對方準備輸入資料的輸出和輸入的啟動訊號為:Tx_EN、Rx_EN
輸出、輸入訊號的錯誤通知訊號為:Tx_ER、Rx_ER
得到有效輸入資料的通知訊號為:RX_DV
網路上出現擁塞的Colision訊號為:Col作為carrier回覆用的訊號為:CRS(請參考CSMA/CD)
MII實作的電路電壓可用+5V或是+3.3V

GMII: Gigabit Media Independent Interface,可支授到1Gbps,不同於MII,輸出和輸入各有8bit
Tx:GTXCLK、TxCLK、TxD[0:7]、TxEN、TxER
Rx:RxCLK、RxD[0:7]、RxDV、RxER、COL、CRS、MDC、MDIO

RGMII: Reduced Gigabit Media Independent Interface,顧名思義就是GMII的縮小版(因為減少了PIN腳位數)
和GMII一樣可以支援10/1O0/1000Mbps,只有定義12個訊號,比GMII還少一半:RxC、RxD[0:3]、Rx_CTL、TxC、TxD[0:3]、Tx_CTL

IC控制訊號一樣是透過MDC、MDIO

2010年10月20日 星期三

EtherType for some common protocols

EtherType Protocol
0x0800 Internet Protocol, Version 4 (IPv4)
0x0806 Address Resolution Protocol (ARP)
0x0842 Wake-on-LAN Magic Packet, as used by ether-wake and Sleep Proxy Service
0x1337 SYN-3 heartbeat protocol (SYNdog)
0x8035 Reverse Address Resolution Protocol (RARP)
0x809B AppleTalk (Ethertalk)
0x80F3 AppleTalk Address Resolution Protocol (AARP)
0x8100 VLAN-tagged frame (IEEE 802.1Q)
0x8137 Novell IPX (alt)
0x8138 Novell
0x86DD Internet Protocol, Version 6 (IPv6)
0x8808 MAC Control
0x8809 Slow Protocols (IEEE 802.3)
0x8819 CobraNet
0x8847 MPLS unicast
0x8848 MPLS multicast
0x8863 PPPoE Discovery Stage
0x8864 PPPoE Session Stage
0x886F Microsoft NLB heartbeat [3]
0x8870 Jumbo Frames
0x888E EAP over LAN (IEEE 802.1X)
0x8892 PROFINET Protocol
0x889A HyperSCSI (SCSI over Ethernet)
0x88A2 ATA over Ethernet
0x88A4 EtherCAT Protocol
0x88A8 Provider Bridging (IEEE 802.1ad)
0x88AB Ethernet Powerlink
0x88CC LLDP
0x88CD SERCOS III
0x88D8 Circuit Emulation Services over Ethernet (MEF-8)
0x88E1 HomePlug
0x88E5 MAC security (IEEE 802.1AE)
0x88F7 Precision Time Protocol (IEEE 1588)
0x8902 IEEE 802.1ag Connectivity Fault Management (CFM) Protocol / ITU-T Recommendation Y.1731 (OAM)
0x8906 Fibre Channel over Ethernet
0x8914 FCoE Initialization Protocol
0x9100 Q-in-Q
0xCAFE Veritas Low Latency Transport (LLT)

2010年10月14日 星期四

Z Shell (zsh) 的特色 與 安裝



特色:

  1. Acts extremely similar to bash.
  2. Typo correction.
  3. Phenomenally intelligent tab completion.
安裝:

$ sudo yum install zsh
$ curl http://stuff.mit.edu/~jdong/misc/zshrc > ~/.zshrc
$ chsh -s /bin/zsh
 
P.S 須調整時區 將 .zshrc 中的 TZ 設為 Asia/Taipei 即可. 
 
REBOOT
 

2010年10月13日 星期三

Kismet

Kismet is an 802.11 layer2 wireless network detector, sniffer, and intrusion detection system. Kismet will work with any wireless card which supports raw monitoring (rfmon) mode, and (with appropriate hardware) can sniff 802.11b, 802.11a, 802.11g, and 802.11n traffic. Kismet also supports plugins which allow sniffing other media such as DECT.

Kismet identifies networks by passively collecting packets and detecting standard named networks, detecting (and given time, decloaking) hidden networks, and infering the presence of nonbeaconing networks via data traffic.

Kismet 是一個 802.11 layer2 的無線網路偵測、嗅探及入侵偵測系統,只要是 Linux 支援的無線網卡,幾乎都可以用。Kismet 可以 sniff 的封包有 802.11b/a/b/g/n。 




2010年10月6日 星期三

U-Boot Porting Guide

[Based on messages by Jerry Van Baren in the U-Boot-Users mailing
list, October 2002]


int main (int argc, char *argv[])
{
    sighandler_t no_more_time;

    signal (SIGALRM, no_more_time);
    alarm (PROJECT_DEADLINE - toSec (3 * WEEK));

    if (available_money > available_manpower) {
        pay consultant to port U-Boot;
        return 0;
    }

    Download latest U-Boot source;

    Subscribe to u-boot-users mailing list;

    if (clueless) {
        email ("Hi, I am new to U-Boot, how do I get started?");
    }

    while (learning) {
        Read the README file in the top level directory;
        Read http://www.denx.de/twiki/bin/view/DULG/Manual ;
        Read the source, Luke;
    }

    if (available_money > toLocalCurrency ($2500)) {
        Buy a BDI2000;
    } else {
        Add a lot of aggravation and time;
    }

    Create your own board support subdirectory;

    Create your own board config file;

    while (!running) {
        do {
            Add / modify source code;
        } until (compiles);
        Debug;
        if (clueless)
            email ("Hi, I am having problems...");
    }
    Send patch file to Wolfgang;

    return 0;
}

void no_more_time (int sig)
{
      hire_a_guru();
}

2010年10月5日 星期二

WinPcap

WinPcap是Windows平臺下一個專業網路資料包捕獲開發包,是為Libpcap在 Windows平臺下實現資料包的捕獲而設計的。在設計WinPcap時參照了Libpcap,使用方法與LibPcap相似。使用WinPcap開發 包,可以把在Linux下基於Libpcap的程式很容易地移植到Windows平臺下。WinPcap是在BSD許可證下發佈地,它主要由加利福尼亞地 Lawrence Berkeley Laboratory開發。WinPcap地下載網址為:http://winpcap.polito.it/ 。目前有不少軟體都使用了WinPcap開發包,其中最為著名的是Ethereal。它是一個免費的網路通訊協定分析軟體,其對資料包解析的細緻程度甚至 高於業界著名的Sniffer和WildPackets;

WinPcap有三個模組構成:
第一個模組NPF(Netgroup Packet Filter),是一個虛擬裝置驅動程式檔。它的功能是過濾資料包,並把這些資料包原封不動地傳給使用者態模組,這個過程中包括了一些作業系統特有的代 碼。
第二個模組packet.dll是一組用戶級的函式程式庫,為win32平臺提供了一個公共的介面。不同版本的Windows系統都有自己的 內核模組和使用者層模組。Packet.dll用於解決這些不同。調用Packet.dll的程式可以運行在不同版本的Windows平臺上,而無需重新 編譯。
第三個模組資料包高級驅動程式庫(wpcap.dll)與作業系統無關,它提供了更加高層、抽象的函數,含有諸如產生篩檢程式,用戶級緩衝 等高級功能。

Libnet

Libnet是一個專業的網路資料包構造和發送開發包,它是一個高層次的API函式程式庫,允許開發者構造和發送網路資料包。Libnet提供了一個對底 層網路資料包進行構造、修改和發送的高級介面。它隱藏了很多底層細節,省去了很多麻煩,如多路技術、緩衝區管理、網路資料包頭資訊、位元組流順序、作業系 統相容性,以及校驗和計算問題等。Libnet主要提供了在IP層和鏈路層構造網路資料包的功能和一些非常有用的協助工具。使用Libnet可以非常輕 鬆、快捷地構造任何形式的網路資料包,開發各種各樣的網路安全應用程式,甚至非常複雜的程式。Libnet主要用C語言寫成,提供了低層網路資料包的構 造、處理和發送功能.他的主要特點是:

.高層介面:Libnet主要用C語言寫成
.資料包構造:Libnet提供了一系列的 TCP/IP資料包文的構造函數以方便使用者使用。
.資料包的處理:Libnet提供了一系列的輔助函數,利用這些輔助函數,説明使用者簡化那些 煩瑣的事務性的程式設計工作
.資料包發送:Libnet允許用戶在兩種不同的資料包發送方法中選擇。
另外Libnet允許程式獲得對資料 包的絕對的控制,其中一些是傳統的網路程式介面所不提供的。
Libnet提供兩種將資料包發送到網路的介面:原始通訊端(raw socket)介面和鏈路層(Link Layer)介面。本文選取的是鏈路層介面進行設計的。

2010年10月4日 星期一

OPENVPN Server enable NAT routing

Here you should can connect with OpenVPN server thru VPN. However general web browsing will be accomplished with direct connections that bypass the VPN.
If you want to browse web thru VPN , please continue to follow the steps below.

1. Add the following directive to the server configuration file 'server.conf'
push "redirect-gateway def1"
push "dhcp-option DNS 168.95.1.1"

2. Setting NAT routing for VPN client on server
#vi /etc/openvpn/start-nat.sh
   #!/bin/bash

   ipt="/sbin/iptables"

   # Clean the all rules
   $ipt -F
   $ipt -X
   $ipt -t nat -F
   $ipt -t nat -X

   # Enable ip_forward
   echo "1" > /proc/sys/net/ipv4/ip_forward

   # For NAT routing
   $ipt -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
   $ipt -t nat -L

#cd /etc/openvpn
#./start-nat.sh


2010年10月1日 星期五

OPENVPN Client issue for Windows

在建立connection時,出現

NOTE: could not get adapter index for \DEVICE\TCPIP_{9A17EDDE-8CCC-474E-ABE6-8DBE7DAB42CB}, status=55 : 指定的網路資源或裝置無法再使用。 

原來是因為安裝Commview的關係,只要將TAP-Win32 Adapter中的 Commview相關元件 uncheck即可.

How to use simple speedtest in RaspberryPi CLI

  pi@ChunchaiRPI2:/tmp $  wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py --2023-06-26 10:4...