Written on 12:27 上午 by Yu Lai
我一聽到mCool有支援Skype, 今天就跑去申請了mCool 299,
申請好後, 也請中華電信把internet APN關掉, 並在Milestone上設定:
APN: emome
Proxy: 10.1.1.1
Port: 8080
一如預期, 設定好後WWW, GMail, Skype都OK,
但是Market, Maps, YouTube都不行.
後來想了解一下為什麼, 於是Google了一個晚上,
發現似乎是Android只有Browser會走APN的proxy.
其他的App好像傻了一樣, 都直接連線, 難怪Android+mCool會有些App不能用.
能用的都是中華電信特別開出來的才能用, 搞得好像Android用的mCool是被閹割過似的.
沒關係, App不走Proxy, 那就找方法強制它走Proxy.
在XDA-Developers上有個人有wifi環境需要走proxy才能用的問題,
於是就去抓了transproxy並配合iptables和voila完成了transparent proxy的功能.
最後還把它打包成APK給大家下載使用, 真是佛心來的.
網址如下: http://forum.xda-developers.com/showthread.php?t=766569
安裝上, 先確認Milestone要先ROOT過, 並且先斷線.
我是抓TransProxy2.04.apk回來安裝,
安裝時還遇到找不到iptable的問題,
於是先到http://code.google.com/p/cmwrap/downloads/list抓回來放在/system/bin下.
安裝完後, 執行它, 在設定裡選HTTP, 10.1.1.1, 8080, 開啟.
設定完再重新連線, 以上設定中有錯誤發生, 請重開機試試吧.
最後把Market或Maps打開試看看, 你就會發現都可以用了.
PS1: 因為這是transparent proxy, 所以當你要用wifi不走mCool時, 請關掉, 不然你會不能用. XD
PS2: 其實emome說mCool不能當數據機給NB上網, 但配合wireless tether+NB的Proxy似乎.... 嘿嘿.
Posted in
技術,
Android,
Network
|
Written on 11:39 上午 by Yu Lai
一般我們在Linux上可以使用arp這個指令來顯示或設定ARP Table。
而在程式中如果要操作系統的ARP Table的話,除了用system()來呼叫
arp指令外,也可以透過socket fd所提供的ioctl命令來達成,共有3種,
分別是SIOCSARP(設定ARP mapping),SIOCDARP(刪除ARP mapping),
SIOCGARP(獲取ARP mapping)。在操作上需配合struct arpreq,
定義如下:
struct arpreq {
struct sockaddr arp_pa; /* protocol address */
struct sockaddr arp_ha; /* hardware address */
int arp_flags; /* flags */
struct sockaddr arp_netmask; /* netmask of protocol address */
char arp_dev[16];
};
其中,arp_pa必須是AF_INET的socket。而指定的network device
也必須填入arp_dev中。而arp_flag的value定義如下:
ATF_COM = Lookup complete
ATF_PERM = Permanent entry
ATF_PUBL = Publish entry
ATF_USETRAILERS = Trailers requested
ATF_NETMASK = Use a netmask
ATF_DONTPUB = Don't answer
使用SIOCSARP命令時,需設定arpreq的arp_pa,arp_ha和arp_flags。
此時若ARP Table己經存在這筆IP位址,它會將它取出更新。若不存在,則新增。
使用SIOCDARP命令時,只需設定arpreq中的arp_pa和arp_dev,kernel會
根據arp_pa的IP位址從ARP Table的hash中取出,並將其state更新為NUD_FAILED。
這樣在下一次ARP GC時就會被清掉。
使用SIOCGARP命令時,只需要設定arpreq中的arp_pa即可。不過一般我們
不會透過SIOCGARP命令,而是使用/proc/net/arp直接讀取。
以下是SIOCSARP的範例程式:
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/if_ether.h>
#include <netinet/in.h>
int set_arp(char * ip, char * mac, char * dev) {
struct arpreq req;
struct sockaddr_in addr;
int sockfd, rc;
unsigned int s_addr;
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if(sockfd < 0) {
return 1;
}
/* Inet sockaddr_in struct */
memset(&addr, 0, sizeof(struct sockaddr_in));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr(ip);
/* ARP arpreq struct */
memset(&req, 0, sizeof(req));
memcpy(&req.arp_pa, &addr, sizeof(struct sockaddr));
memcpy(req.arp_ha.sa_data, mac, 6);
req.arp_flags = ATF_PERM | ATF_COM;
strcpy(req.arp_dev, dev);
rc = ioctl(sockfd, SIOCSARP, &req);
close(sockfd);
return rc;
}
Posted in
C,
Linux,
Network
|
Written on 11:53 上午 by Yu Lai
最近在弄ATM Qos,自然也學到了不少東東,以下是一些相關的資料整理。
依照ATM Forum的Traffic Management Specification Version 4.0規範,ATM的服務類別分為以下的定義:
1. Constant Bit Rate (CBR)
可提供固定速率的服務,對傳輸延遲、傳輸遺失及傳輸跳動等服務品質的要求最為嚴格,適合應用於及時性或需要固定頻寬的服務。適用的應用服務如下:
-交談式視訊服務 (e.g., videoconferencing)。
-交談式音訊服務 (e.g., telephone)。
-分散式視訊 (e.g., television, distributed classroom)。
-分散式音訊 (e.g., radio, audio feed)。
-其他視訊服務 (e.g., video on demand)。
-其他音訊服務 (e.g., audio library)。
2. Real-Time Variable Bit Rate (rt-VBR)
VBR的服務品質提供了對傳輸延遲和傳輸遺失的保證,主要針對影像和對傳輸延遲敏感的服務。另外,根據對延遲要求的不同,又可細分為及時性(VBR-rt)和非及時性(VBR-nrt)兩類。適用的應用服務如下:
-即時應用服務(包含CBR所列)但可容許些微的cell loss率,或是較有效率的網路資源應用(註)。
3. Non-Real-Time (nrt-VBR)
和VBR-rt相比,VBR-nrt可允許較多的傳輸延遲。適用的應用服務如下:
-緊急性的交易程序 (e.g., airline reservations, banking transactions, process monitoring)。
-Frame Relay interworking。
4. Available Bit Rate (ABR)
ABR的服務品質保證了最小傳輸頻寬,適合IP和LAN的服務,ABR需要在ATM層提供流量控制(Flow Control),以避免網路發生壅塞或超載。適用的應用服務如下:
-任何UBR的應用,配合ABR的flow-control可以得到較少的cell lose率。
-緊急性的資料傳輸 (e.g., defense information)。
-超級電腦應用服務。
-需較少的delay行為的傳輸服務 (e.g., remote procedure call, distributed file service, or computer process swap/paging)。
5. Unspecified Bit Rate (UBR)
UBR適合的服務與ABR相同,但無任何服務保證。適用的應用服務如下:
-一般文字/資料/圖片傳送 (e.g., banking transaction, credit card verification, email, telex, fax, news feed, weather sat. pictures, file transfer, library browsing, telecommuting, telnet)
註:
當服務品質的要求愈高時,相對地對傳輸頻寬的需求就愈高,在配置網路頻寬時的彈性也就跟著下降。對CBR而言,因為從頭到尾都必須提供固定的頻寬,根本就沒有多工增益(Multiplexing Gain)可言。但是對VBR-nrt和ABR而言,因為訊務本身具有叢集(Bursty)特性,系統只需要提供介於最高所需頻寬和平均所需頻寬的等效頻寬即可。隨著訊務的叢集特性愈明顯,網路可以容納的用戶數也愈多,多工增益也跟著提高,因此CBR的收費最高,VBR、ABR次之,UBR最低。
Posted in
技術,
ATM,
Network,
QoS
|
Written on 10:44 上午 by Yu Lai
一般我們在使用MSN時, 在傳送檔案時,
MSN都會要我們設定防毒軟體或是使用它們自己的LiveCare.
使用LiveCare是也ok, 但每次都要等它更新完才能掃毒實在有夠久的.
但各家防毒軟體的設定單檔掃描的方式也都不同,
以下是在網路上找到的, 有幾個我自己也沒試過, 參考看看吧.
== Avira AntiVir 9.x 小紅傘 ==
"C:\Program Files\Avira\AntiVir Desktop\avscan.exe" /CFG="C:\Program Files\Avira\AntiVir Desktop\Profile.txt" /PATH=%file%
同時需建立一文字檔Profile.txt於安裝目錄下, 內容如下:
[CFG]
GuiMode=2
ExitMode=3
[SEARCH]
Parameter=0x00000002
Parameter=0x00000020
Parameter=0x00000100
Parameter=0x00000400
Parameter=0x00010000
Parameter=0x00000080
[SCANNER]
BootsektorStart=0
Memory=0
ScanRootkits=0
參數說明:
GuiMode=?
1=顯示完整視窗
2=精簡
3=不顯示
ExitMode=3 (掃描後離開)
BootsektorStart=0 (取消開機磁區掃描)
Memory=0 (取消記憶體掃描)
ScanRootkits=0 (取消Rootkit掃描)
== ESET's NOD32 ==
"C:\Program Files\Eset\nod32.exe" /selfcheck+ /list+ /scroll+ /quit+ /pattern+ /heur+ /scanfile+ /scanboot- /scanmbr- /scanmem- /arch+ /sfx+ /pack+ /mailbox- /adware /unsafe /ah /prompt /all
== Symantec AntiVirus ==
"C:\Program Files\Symantec AntiVirus\Rtvscan.exe" /selfcheck+ /list+ /scroll+ /quit+ /pattern+ /heur+ /scanfile+ /scanboot- /scanmbr- /scanmem- /arch+ /sfx+ /pack+ /mailbox- /adware /unsafe /ah /prompt /all
== Norton AntiVirus ==
"C:\Program Files\Norton Internet Security Professional\Norton AntiVirus\ccIMScan.exe"
== Avast ==
"C:\Program Files\Alwil Software\Avast4\ashQuick.exe"
== Kaspersky ==
"C:\Program Files\Kaspersky Lab\Kaspersky Internet Security 6.0\avp.exe" scan %1
== McAfee 2007 ==
"C:\Program Files\McAfee\VirusScan\mcods.exe"
== PC-cillin ==
"C:\Program Files\Trend Micro\Internet Security 2005\PCCVScan.exe"
Posted in
技術,
Network
|
Written on 4:01 下午 by Yu Lai
其實這篇應該是要接續上一篇寫的,因為用到的方法是和上一篇相同
的,但由於主題比較不太一樣,所以就分開來寫了。
在Linux中,一般要實做新的L3 protocol,大都是從kernel去下手,
效能較好,能存取的資源也比較多。但在開發embedded system下往
往有專案時間壓力以及軟體彈性的需求,去改kernel來達到這些要求
也就有點不太實際。所以我採用了在上一篇中使用的方法,也就是
Raw Socket與LPF(Linux Packet Filter)來完成一個L3 Protocol的
實做。
和Sniffer一樣的,我們使用了Raw Socket與LPF,比較不同的地方在
於LPF所使用的Filter。由於我們的protocol是定義成採用0x1219的
ether type,所以在配合tcpdump生成BPF code時用了以下的指令。
# tcpdump -dd -s 2048 ether proto 0x1219
{ 0x28, 0, 0, 0x0000000c },
{ 0x15, 0, 1, 0x00001219 },
{ 0x6, 0, 0, 0x00000800 },
{ 0x6, 0, 0, 0x00000000 }
以下是部份的實做的程式碼:
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
#include <signal.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <net/if.h>
#include <netinet/in.h>
#include <linux/types.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/filter.h>
#include <linux/sockios.h>
void *mcpV2Handler(void *arg) {
int sock, n;
int rr;
U8 buf[2048];
U8 tmp[8], tmpSlot;
U8 lastBegMac[6];
U32 lastBegTime = 0;
U32 * pGroupKey;
tMcpFrame *frame;
tMcpPacket *packet;
tMcpCardInfo *cardInfo;
pthread_t mcpV2Sender_tid;
pthread_t mcpV2TxRx_tid;
struct sock_fprog filter;
/* Using tcpdump to generate BPF code */
/*
# tcpdump -d -s 2048 ether proto 0x1219
(000) ldh [12]
(001) jeq #0x1219 jt 2 jf 3
(002) ret #2048
(003) ret #0
*/
struct sock_filter bpf_code[]= {
{ 0x28, 0, 0, 0x0000000c },
{ 0x15, 0, 1, 0x00001219 },
{ 0x6, 0, 0, 0x00000800 },
{ 0x6, 0, 0, 0x00000000 }
};
filter.len = sizeof(bpf_code)/sizeof(bpf_code[0]);
filter.filter = bpf_code;
/* set detached thread */
pthread_detach(pthread_self());
if ((sock=socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ALL)))<0) {
perror("socket");
exit(1);
}
/* Attach the bpf filter to the socket */
if (setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter))<0){
perror("setsockopt");
close(sock);
exit(1);
}
/* ----------- Start implement ----------- */
while(1) {
n = recvfrom(sock, buf, sizeof(buf), 0, NULL, NULL);
if(n < 22) { /* 6+6+2+2+4+2+N */
printf("invalid packet\n");
continue;
}
frame = (tMcpFrame *)buf;
if(memcmp(frame->srcAddr, myMac, 6) == 0)
continue;
MCP_LOG("Dump: %02x%02x%02x%02x%02x%02x|"
"%02x%02x%02x%02x%02x%02x|"
"%04x|%04x|%08x|%04x|"
"%02x %02x %02x %02x %02x %02x %02x %02x %02x",
frame->dstAddr[0], frame->dstAddr[1], frame->dstAddr[2],
frame->dstAddr[3], frame->dstAddr[4], frame->dstAddr[5],
frame->srcAddr[0], frame->srcAddr[1], frame->srcAddr[2],
frame->srcAddr[3], frame->srcAddr[4], frame->srcAddr[5],
ntohs(frame->etherType),
ntohs(frame->mcpProtoType),
ntohl(frame->groupKey),
ntohs(frame->dataLength),
frame->data[0], frame->data[1], frame->data[2], frame->data[3],
frame->data[4], frame->data[5], frame->data[6], frame->data[7], frame->data[8]);
if(ntohs(frame->mcpProtoType) == 1 && ntohl(frame->groupKey) == myGroupKey) {
/* blah blah */
/* blah blah */
/* blah blah */
}
}
close(sock);
}
Posted in
技術,
C,
Linux,
Network
|
Written on 1:39 下午 by Yu Lai
在這裡先感謝一下黃仁竑老師,因為這篇其實這是之前唸研究所時,
上課所要交的作業。沒想到最近在工作上也用到了,呵呵。
雖然在Linux下有許多好用的Sniffer工具,如: tcpdump 或 libpcap等。
但若了解如何自己實作Sniffer,對於實作網路相關的protocol會有更深的了解。
在實作sniffer之前,在Linux下有幾個東西我們要先了解。
首先是raw socket,透過raw socket,可以讓我們從Layer 2(Ethernet)
的資料開始解讀,而不是已經被核心處理過的tcp/udp payload。
sock=socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP));
接著是LPF(Linux Packet Filter),在Linux的kernel中,有個LPF的機制
可以預先設定過濾socket讀取到的內容。當然這個在實作sniffer不是必要
的,我們大可在讀取資料後自行filter掉非必要的data。但透過LPF,可以
讓我們專心在實作資料的呈現上。
而LPF的使用,我們可以使用一種pseudo-machine code language叫作BPF。
它是一種用來描述filter的語言,我們可以透過tcpdump這支好用的工具來
產生bpf的sample code。使用方法就是使用tcpdump -d 和
tcpdump -dd 來生出C使用的code。另外,tcpdump所生成的
sample code預設只會抓取96個字元,所以要再加上-s參數來指定抓取的數量。
tcpdump -d -s 2048 tcp and host 140.123.230.166
(000) ldh [12]
(001) jeq #0x86dd jt 10 jf 2
(002) jeq #0x800 jt 3 jf 10
(003) ldb [23]
(004) jeq #0x6 jt 5 jf 10
(005) ld [26]
(006) jeq #0x8c7be6a6 jt 9 jf 7
(007) ld [30]
(008) jeq #0x8c7be6a6 jt 9 jf 10
(009) ret #2048
(010) ret #0
tcpdump -dd -s 2048 tcp and host 140.123.230.166
{ 0x28, 0, 0, 0x0000000c },
{ 0x15, 8, 0, 0x000086dd },
{ 0x15, 0, 7, 0x00000800 },
{ 0x30, 0, 0, 0x00000017 },
{ 0x15, 0, 5, 0x00000006 },
{ 0x20, 0, 0, 0x0000001a },
{ 0x15, 2, 0, 0x8c7be6a6 },
{ 0x20, 0, 0, 0x0000001e },
{ 0x15, 0, 1, 0x8c7be6a6 },
{ 0x6, 0, 0, 0x00000800 },
{ 0x6, 0, 0, 0x00000000 }
把Filter設到socket上。
struct sock_filter BPF_code[]= {
{ 0x28, 0, 0, 0x0000000c },
{ 0x15, 8, 0, 0x000086dd },
{ 0x15, 0, 7, 0x00000800 },
{ 0x30, 0, 0, 0x00000017 },
{ 0x15, 0, 5, 0x00000006 },
{ 0x20, 0, 0, 0x0000001a },
{ 0x15, 2, 0, 0x8c7be6a6 },
{ 0x20, 0, 0, 0x0000001e },
{ 0x15, 0, 1, 0x8c7be6a6 },
{ 0x6, 0, 0, 0x00000060 },
{ 0x6, 0, 0, 0x00000000 }
};
struct sock_fprog Filter;
Filter.len = 11;
Filter.filter = BPF_code;
setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &Filter, sizeof(Filter))
最後是把網卡的promiscuos mode打開,網卡一般會比對dst mac和自己的
Mac Address,若不相同或不是broadcast的封包會被drop掉不處理。
若要實作sniffer,這個mode一定要打開,才能監聽到別人的封包。
strncpy(ethreq.ifr_name,"eth0",IFNAMSIZ);
ioctl(sock,SIOCGIFFLAGS,ðreq);
ethreq.ifr_flags|=IFF_PROMISC;
ioctl(sock,SIOCSIFFLAGS,ðreq);
以下是完整的sample code,不過年代久遠,也沒時間compile測試,
如有錯誤不能compile,請見諒。XD
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <linux/in.h>
#include <linux/if_ether.h>
#include <net/if.h>
#include <linux/filter.h>
#include <sys/ioctl.h>
int main(int argc, char **argv) {
int sock, sock_server, sock_client, n, i;
char buffer[2048];
unsigned char *iphead, *ethhead, *tcphead;
int addr_len;
struct sockaddr_in sa_cli;
struct ifreq ethreq;
FILE* fPtr;
struct sock_filter BPF_code[]= {
{ 0x28, 0, 0, 0x0000000c },
{ 0x15, 8, 0, 0x000086dd },
{ 0x15, 0, 7, 0x00000800 },
{ 0x30, 0, 0, 0x00000017 },
{ 0x15, 0, 5, 0x00000006 },
{ 0x20, 0, 0, 0x0000001a },
{ 0x15, 2, 0, 0x8c7be6a6 },
{ 0x20, 0, 0, 0x0000001e },
{ 0x15, 0, 1, 0x8c7be6a6 },
{ 0x6, 0, 0, 0x00000800 },
{ 0x6, 0, 0, 0x00000000 }
};
struct sock_fprog Filter;
Filter.len = 11;
Filter.filter = BPF_code;
if ((sock=socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP)))<0) {
perror("socket");
exit(1);
}
/* Set the network card in promiscuos mode */
strncpy(ethreq.ifr_name,"eth0",IFNAMSIZ);
if (ioctl(sock,SIOCGIFFLAGS,ðreq)==-1) {
perror("ioctl (SIOCGIFCONF) 1");
close(sock);
exit(1);
}
ethreq.ifr_flags|=IFF_PROMISC;
if (ioctl(sock,SIOCSIFFLAGS,ðreq)==-1) {
perror("ioctl (SIOCGIFCONF) 2");
close(sock);
exit(1);
}
/* Attach the filter to the socket */
if (setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &Filter, sizeof(Filter))<0){
int temp=sizeof(Filter);
printf( "%d" , temp);
perror("setsockopt");
close(sock);
exit(1);
}
/* Open the result file. */
if ((fPtr = fopen("dump.txt", "w")) == NULL) {
perror("fopen");
close(sock);
exit(1);
}
while (1) {
n = recvfrom(sock, buffer, 2048, 0, NULL, NULL);
printf("%d bytes read\n",n);
/* Check to see if the packet contains at least
* complete Ethernet (14), IP (20) and TCP/UDP
* (8) headers.
*/
if (n<42) {
perror("recvfrom():");
printf("Incomplete packet (errno is %d)\n", errno);
close(sock);
exit(0);
}
ethhead = buffer;
printf("Source MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n",
ethhead[0], ethhead[1], ethhead[2], ethhead[3], ethhead[4], ethhead[5]);
printf("Destination MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n",
ethhead[6], ethhead[7], ethhead[8], ethhead[9], ethhead[10], ethhead[11]);
iphead = buffer+14; /* Skip Ethernet header */
if (*iphead==0x45) { /* Double check for IPv4 and no options present */
printf("Source host %d.%d.%d.%d\n",
iphead[12], iphead[13], iphead[14], iphead[15]);
printf("Dest host %d.%d.%d.%d\n",
iphead[16], iphead[17], iphead[18], iphead[19]);
printf("Source,Dest ports %d,%d\n",
(iphead[20]<<8)+iphead[21], (iphead[22]<<8)+iphead[23]);
printf("Layer-4 protocol %d\n",
iphead[9]);
}
tcphead = iphead+20;
if (iphead[9] == 0x06) {
printf("TCP Sequence Number: %x%x%x%x\n",
tcphead[4], tcphead[5], tcphead[6], tcphead[7]);
printf("TCP Acknowledgement Number: %x%x%x%x\n",
tcphead[8], tcphead[9], tcphead[10], tcphead[11]);
printf("TCP Header Length: %d\n",
tcphead[12]>>4);
printf("TCP Control Bits: %02x (UAPRSF)\n",
tcphead[13]);
printf("TCP Window Size: %d\n",
(tcphead[14]<<8)+tcphead[15]);
for(i=4*(tcphead[12]>>4);i<n-14-20;i++) {
printf("%c", tcphead[i]);
}
printf("\n");
}
}
}
Ref:
http://www.linuxjournal.com/article/4659
Posted in
技術,
C,
Linux,
Network
|
Written on 6:49 下午 by Yu Lai
Ref: 酷學園 & PCDVD
NTEL 叫 LINK AGGREGATION
CISCO 叫 FAST ETHERCHANNEL
3COM 叫 PORT TRUNKING
現在國際標準叫 IEEE802.3ad
白話一點叫併頻寬或頻寬聚集
一般用在解決伺服器網路瓶頸或交換器與交換器連接
從硬體的角度來看
INTEL 伺服器等級的網路卡可以設定以下3個模式
1.AFT(Adapter Fault Tolerance)(希望沒有拼錯好像怪怪的)
假設有兩張網卡時一張是PRIMARY另一張是STANDBY
這時候流量只在PRIMARY上跑
當PRIMARY掛掉時STANDBY會自動啟用接手變成PRIMARY
如果原來PRIMARY恢復時會自動變成STANDBY
(因為大家ALB和ALA都包含AFT,所以基本上沒人會單獨設AFT運作)
2.ALB(Adapter Load Balance)
假設將兩張網路卡設成ALB時
進來流量為100M出去流量為200M
這時候無論接往何種交換器或集線器都可支援
同時間ALB包含容錯功能如果一張網卡故障另一張依然運作
現在INTEL可以做到8張網卡併頻寬
3.ALA(Adapter Link Aggregation)
假設將兩張網路卡設成ALA時
進來流量為200M出去流量為200M
這時候需接往支援LINK AGGREGATION的交換器
同時間ALA包含容錯功能如果一張網卡故障另一張依然運作
現在INTEL可以做到8張網卡併頻寬
Intel 的 teaming 叫做 ians Intel(R) Advanced Network Services
intel 分成
1、Adapter Fault Tolerance (AFT)
2、Switch Fault Tolerance (SFT)
3、Adaptive Load Balancing (ALB)
4、Intel Link Aggregation, Cisco*'s Fast EtherChannel* Technology or static 802.3ad (FEC or FEC/LA/802.3ad: static)
intel pro 若只使用 windows 系統提供的驅動程式的話 , 其 teaming mode 只能支援到 RLB , 若要完全使用其他 teaming mode (LA , Cisco FEC ..)的功能 , 除了需要有支援 802.3ad 規格的 switch 配合外 , 還需要安裝 Intel ANS !!
在使用2張 INTEL SERVER ADAPTER 以上時
正常來說會選 ALB 或 ALA
不管選 ALB 或 ALA 這時 AFT 是一定有作用
當你的交換器是一般或早期的請選 ALB
這時主網卡跑雙工其他子網卡跑單工
系統以主網卡為主
假設四張的話就是進去 100 出來 400
當你的交換器支援 FAST ETHERCHANNEL 或 LINK AGGREGATION 或 802.3ad
這時可以啟用 ALA
所有網卡都跑全雙工
系統以代表所有實體網卡的虛擬網卡為主
假設有四張時就是進去 400 出來 400
Posted in
技術,
Network
|
Written on 11:05 上午 by Yu Lai
使用Wireshark時居然發生抓不到VLAN的資訊,
上網找了一下果然是有問題的。
以下為找到的ref: http://blog.rogerz.cn/archives/553
某一些網卡驅動默認會在接收封包的時候過濾vlan tag,使得用wireshark抓到的封包中不含vlan tag,此時需要通過修改註冊表讓驅動保留vlan tag。
對於Intel PRO/1000或PRO/100網卡,需要將註冊表HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\00xx下(以DriverDesc來判定xx值為何)的MonitorModeEnabled改為1,如果不存在則新建這麼一個dword鍵。
對於Broadcom Giga網卡,需要在註冊表裡增加一項PreserveVlanInfoInRxPacket=1,類型為string。位置與TxCoalescingTicks相同,後者可以在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet下搜索到。
修改後需要重啟機器讓它生效。這個修改辦法是在UniCA User Manual中看到的,較新的網卡驅動裡都支持這個設置,原文如下:
Intel PRO/1000 or PRO/100 Ethernet controller which are used in e.g. IBM Notebooks (T40 series and others) do not forward VLAN tags to the upper layers; By default, Intel adapters strip the VLAN tag before passing it up the stack. If you need to see the tag you need to use these driver versions: PRO/100 6.x or 7.x or later base driver, PRO/1000 7.2.17.803 (plain 7.2.17 does not have this feature). To enable, you must go into the registry and either add a registry dword and value (for e100) or change the value of the registry key (for e1000). The registry dword is MonitorModeEnabled (for both). It should be placed at HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class{4D36E972-E325-11CE-BFC1-08002BE10318}\00xx where xx is the instance of the network adapter that you need to see tags on. (Check by opening and viewing the name of the adapter). It should be set to read: MonitorModeEnabled= 1. Note: ControlSet001 may need to be CurrentControlSet or another 00x number
For Broadcom 570x Gigabit adapters (for example in Dell systems); Add a registry key under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet to cause the driver not to strip the 802.1Q VLAN header. In order to set that key, you need to find the right instance of the driver in Registry Editor and set that key for it.
* Run the Registry Editor (regedt32).
* Search for 「TxCoalescingTicks」 under "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet" and ensure this is the only instance that you have.
* Right-click on the instance number (eg. 0008) and add a new string value.
* Enter 「PreserveVlanInfoInRxPacket」 and give it the value 「1〞.
* Save and Reboot
* You may need to install a recent driver (version 8.27) to make this setting effective
Posted in
技術,
Network
|
Written on 3:42 下午 by Yu Lai
今天Intel正式授權FreeBSD可以使用旗下Wireless Chipset的Firmware.
包含: Intel 2100, 2200BG, 2225BG, 2915ABG, and the 3945ABG devices
這是一大福音阿, 尤其嘉惠要在FreeBSD上面做無線網路研究的人,
以前notebook上面跑FreeBSD都得要望centrino興嘆 (不然就是得用
其他方式啟動, 而且不太穩定) 現在有了官方的直接support, 實在太棒了 :D
有網頁有真相: http://www.prweb.com/releases/2007/03/prweb509818.htm
Posted in
技術,
FreeBSD,
Network
|
Written on 9:15 上午 by Yu Lai
最近本來很低調的FTP因為流量越來越大導致不怎麼低調了。
所以只好去Survey了幾個低調的做法。考慮了許多effort因素
最後採用的就是使用Round Robin DNS技術將流量打散在許多
IP上,也是目前蠻常見的低成本負載平衡。至於成效目前還未知
,但我想應該是還不錯的啦。
以下是在Bind上設定Round Robin DNS的一些notes:
;Dynamic FTP by Round Robin DNS
dynftp 0 IN A 192.168.123.101
dynftp 0 IN A 192.168.123.102
dynftp 0 IN A 192.168.123.103
...
其中,dynftp的A-Records即為Round Robin設置,
0為TTL(Time to live),單位為秒。若DNS Server因此
Loading過重,可酌量提高TTL數值。
Posted in
技術,
Network
|
Written on 5:37 下午 by Yu Lai
今天在搞net-snmp所提供的mib2c tool,
用起來說實在的實在有點難用。
大概是我對它還不太熟的關係吧。
以下是今天弄的一些心得:
(因為開發需求,所以設定prefix為/opt/net-snmp。)
1.
首先,在安裝net-snmp時,需在configure時加入以下參數
$ ./configure --prefix=/opt/net-snmp/ --enable-embedded-perl --enable-shared --with-perl-modules
$ make
$ make test
# make install (should be root)
2.
在確定PATH設定好後,執行mib2c時,
通常會遇到訊息說沒有安裝Perl SNMP Module,
這是因為我們在configure時有設了prefix的關係,
導致perl找不到share library。
解決的方法是將net-snmp的lib目錄設定給ldconfig知道即可。
# echo /opt/net-snmp/lib > /etc/ld.so.conf.d/net-snmp.conf
# ldconfig -v
3.
最後就是mib2c操作方法,
據mib2c的manpage裡說明,
mib2c的功用是產生template code給agent來擴充功能使用。
Usage為
mib2c [-h] -c CONFIGFILE [-I PATH] [-f OUTNAME] [-i][q][-S VAR=VAL] MIBNODE
而mib2c的使用方法是以mib node為parameter來開始生成template code。
所以必須先將mib file放置在$HOME/.mibs/或/opt/net-snmp/share/snmp/mibs,
然後在環境變數中設定MIBS,
export MIBS=+NET-SNMP-TUTORIAL-MIB
接著麻煩的在這裡,
你必須依著你的的mib node來選定所產生的template code的CONFIGFILE。
下面是CONFIGFILE所支援的類型:
如果你要寫些scalars所需的code,請用:
mib2c -c mib2c.scalar.conf MIBNODE
如果你要用int scalars,請用:
mib2c -c mib2c.int_watch.conf MIBNODE
一般來講Table是建議採用MDF:
mib2c -c mib2c.mfd.conf MIBNODE
如果Table Data是在外部時:
mib2c -c mib2c.iterate.conf MIBNODE
如果Table Data是在agent裡:
mib2c -c mib2c.create-dataset.conf MIBNODE
承上,如果還需排序時:
mib2c -c mib2c.array-user.conf MIBNODE
如果是要產生Table上任一Column的header時:
mib2c -c mib2c.column_defines.conf MIBNODE
如果是要產生Column上任一Enum的header時:
mib2c -c mib2c.column_enums.conf MIBNODE
4.
結論,大概就是麻煩吧。
Net-SNMP不像其他商用的SNMP套件一樣提供簡易的開發擴充功能的環境,
像在EMANATE中打一個make就ok了,連型態都自動判斷。
不過也許是我對mib2c還不太熟的關係吧,Orz。
Posted in
技術,
Network
|
Written on 3:08 下午 by Yu Lai
最近要搞在Mips的板子上搞Embedded Linux,
要透過網路開機來啟動,所以有了幾下的研究。
其概念為client開機時透過網卡的設定呼叫dhcp或bootp取得ip,
並向server以tftp的方式將boot image檔載入執行開機的動作。
在FreeBSD/Linux上可以透過網路開機,
設定的方法依照機器的網路卡功能的支援不同而有所不一樣。
以下是常見的幾種方式和設定方法:
(PS: 以下設定以Linux為主,FreeBSD則會有些許的不同。)
1. rboot
先介紹rboot
1.1 取得rbootd
如果你的網卡支援rboot開機的話,你必須有台Server來負
責handle boot request,所以首先你必須安裝rbootd。
1.2 設定rbootd
安裝完rbootd後需設定rbootd.conf來設定rbootd。
一般而言rbootd會位於/etc/rbootd.conf
設定範例如下:
# ethernet addr boot file comments
08:00:09:87:e4:8f lifimage_715 # PA/Linux kernel for 715/33
08:00:09:70:04:b6 lifimage_720 # PA/Linux kernel for 720
1.3 安裝boot file
將在rbootd.conf裡設定的boot file置於rbootd的目錄,一般是/var/lib/rbootd。
2. dhcp/tftp
這是最常見的一種方式,也是目前主流的diskless system建置的方法。
2.1 取得dhcp/tftp
先透過rpm或apt-get等方式來安裝server必要的檔案。
rpm: dhcp tftpd
(FreeBSD可以用Ports安裝/usr/ports/net/isc-dhcp3-server即可)
2.2 設定dhcp/tftp
1.修改/etc/inetd.conf或/etc/xinetd.d/tftp
inetd.conf中加入:
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot
xinetd.d/tftp:
service tftp
{
disable = no //yes改成no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -c -s /tftpboot //加上-c參數
per_source = 11
cps = 100 2
flags = IPv4
}
改完後接著重新啟動inetd或xined。
(FreeBSD則是改/etc/inetd.conf並在/etc/rc.conf中啟動inetd。)
這邊要注意的是我們必須將開機用的檔案放置於/tftpboot中。
2. 參考man 5 dhcpd.conf來修改dhcpd.conf,範例如下:
allow bootp;
default-lease-time 600;
max-lease-time 7200;
# This will tell the box its hostname while booting:
use-host-decl-names on;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name "foo.com";
option domain-name-server 192.168.1.4;
}
host tatooine {
hardware ethernet 00:40:05:18:0c:dd;
fixed-address 192.168.1.22;
filename "lifimage-tatooine";
option root-path "/exports/tatooineroot";
}
3. bootp/tftp
這是和dhcp/tftp類似,主要是dhcp已經將bootp的功能包含在一起的關係。
但由於網路架構的關係(e.g. 已有dhcp server),也是個常見的採用方式。
3.1 取得bootp/tftp
先透過rpm或apt-get等方式來安裝server必要的檔案。
rpm: bootp tftpd
(FreeBSD皆已內建其中)
3.2 設定bootp/tftp
1.修改/etc/inetd.conf或/etc/xinetd.d/tftp
inetd.conf中加入:
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot
bootps dgram udp wait root /usr/sbin/bootpd bootpd -i -t 120
xinetd.d/tftp和xinetd.d/bootps:
service tftp
{
disable = no //yes改成no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -c -s /tftpboot //加上-c參數
per_source = 11
cps = 100 2
flags = IPv4
}
service bootps
{
disable = no //yes改成no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/bootpd
server_args = -i -t 120
per_source = 11
cps = 100 2
flags = IPv4
}
改完後接著重新啟動inetd或xined。
(FreeBSD則是改/etc/inetd.conf並在/etc/rc.conf中啟動inetd。)
這邊要注意的是我們必須將開機用的檔案放置於/tftpboot中。
2. 參考man 5 bootptab來修改/etc/bootptab,範例如下:
vodka:hd=/tftpboot:\
:rp=/usr/src/parisc/:\
:ht=ethernet:\
:ha=080069088717:\
:ip=140.244.9.208:\
:bf=lifimage:\
:sm=255.255.255.0:\
:to=7200:
Posted in
技術,
FreeBSD,
Linux,
Network
|
Written on 11:28 上午 by Yu Lai
就在9/11那天所po的"[技術] 在FreeBSD上掛載smbfs"中,其實有個問題沒有被提到,而是最近才解決的,那就是charset的問題。
在那台Linux上是採用zh_TW.Big5的編碼,其檔案系統也是採用Big5來儲存檔名。而在FreeBSD那台是採用zh_TW.UTF-8,自然的透過mount_smbfs來掛載會出現亂碼的問題,在經過測試,發現mount_smbfs -E的選項可說是無效..XD
所幸,解決的方法是根據samba的The Official Samba-3 HOWTO and Reference Guide中的
Chapter 30. Unicode/Charsets裡提到的:
As of Samba-3, Samba can (and will) talk Unicode over the wire. Internally, Samba knows of three kinds of character sets:
unix charset
This is the charset used internally by your operating system. The default is UTF-8, which is fine for most systems and covers all characters in all languages. The default in previous Samba releases was to save filenames in the encoding of the clients for example, CP850 for Western European countries.
display charset
This is the charset Samba uses to print messages on your screen. It should generally be the same as the unix charset.
dos charset
This is the charset Samba uses when communicating with DOS and Windows 9x/Me clients. It will talk Unicode to all newer clients. The default depends on the charsets you have installed on your system. Run testparm -v | grep "dos charset" to see what the default is on your system.
也就是只要將unix charset和display charset皆設為配合系統設定的Big5的CP950,然後在dos charset設為UTF-8,這樣透過mount_smbfs來掛載時就會自動轉成UTF-8的編碼了。而目前的成果自然就是FreeBSD上的pure-ftp (with utf-8 support)可以多很多東西囉。
Posted in
技術,
File System,
Network
|
Written on 7:27 下午 by Yu Lai
雖然不一定有用,但勉強加入看看吧。
http://tracker.so-ga.net/announce
udp://tracker.bitcomet.net:8080/announce
udp://bt.lanspirit.net:2710/announce
http://btfans.3322.org:6969/announce
http://btfans.3322.org:8080/announce
http://tracker.prq.to/announce.php
http://tracker.prq.to:80/announce.php
http://tracker.prq.to/announce
http://tracker.prq.to:80/announce
http://bt.cnxp.com:8080/announce
http://bt.cnxp.com:6969/announce
http://privatetracker.limitedivx.com:2710/announce.php
http://tracker.torrentz.info:42426/announce
http://tracker.torrentportal.com:6969/announce
http://tracker1.desitorrents.com:6969/announce
Posted in
技術,
Network
|
Written on 12:36 上午 by Yu Lai
最近,在弄lab的ftp整合計畫。
要將另一台Linux的資料透過samba的方式來掛載到ftp那台FreeBSD上。
以下則是在弄的過程所得到的一些Notes。
首先,我們可以透過以下的指令來察看有提供連線的資料
smbutil view
掛載時則使用
mount_smbfs //[username]@[host]/[service] [mountpoint]
若要加入 /etc/fstab 使開機後自動mount,請先編輯 /etc/nsmb.conf
加入[host:user]的 section,注意! host及section都必須為"大寫",既使平常輸入的是小寫!
然後在該section加入
password=[encrypted_password] (由smbutil crypt算出)
最後,在 /etc/fstab 裡加上:
//[username]@[host]/[service] [mountpoint] smbfs rw,-I=xxx.xxx.xxx.xxx,-N,-u=[uid],-g=[gid] 0 0
要測試是否成功可以用:
mount -a
來觀看結果。
Posted in
技術,
File System,
FreeBSD,
Network
|
Written on 12:58 上午 by Yu Lai
相信大家都有用到Forward的功能吧,
而一些好文章也都會轉來轉去的吧。
但如果是一堆mail就會按forward再打
mail address等同樣的動作弄到煩吧.. XD
身為懶人的我,找了一下網路,寫了這樣功能的AppleScript。
tell application "Mail"
set theMessages to the selection
repeat with thisMessage in theMessages
set newMessage to make new outgoing message at end of outgoing messages
tell newMessage
set content to thisMessage's content
set subject to thisMessage's subject
make new to recipient with properties {address:"blahblah@blahblah.org"}
end tell
send newMessage
delete thisMessage
end repeat
end tell
Posted in
技術,
Mac OS,
Network
|