導航:首頁 > 源碼編譯 > linuxtc源碼

linuxtc源碼

發布時間:2022-08-23 05:58:54

linux內核中配置tc命令

只需要修改iproute2應用層的makefile就可以了,編譯tc並把tc拷貝到執行目錄里

② linux中nat+tc怎麼做

用linux做nat服務,用tc限制流量 作者:用linux做nat服務,用tc限制流量 最近有同事用bt和電驢瘋狂下載,我們上網打cs受到極大影響,所以對nat上網做了流量控制,將一點經驗介紹給網友,希望對cs fans 有所幫助. 我們上網環境如下: eth0 外網ip :a.b.c.d eth1 內網ip1:192.168.0.0/24 給老闆和bt eth2 內網ip2:192.168.1.0/24 給我和csfans 用linux 做nat 命令如下: echo 1 > /proc/sys/net/ipv4/ip_forward iptables -F iptables -t nat -F ----清除舊規則 iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to a.b.c.d ---為內網ip1 做nat iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j SNAT -- to a.b.c.d ---為內網ip2 做nat ------------為流量控製做基於fw過濾器的標記 iptables -I PREROUTING -t mangle -p tcp -s 192.168.0.0/24 -j MARK --set-mark 1 iptables -I PREROUTING -t mangle -p tcp -s 192.168.1.0/24 -j MARK --set-mark 2 ------------為上傳速率做流量控制 tc 要求內核2.4.18以上,所以不夠的要升級 tc 只能控制網卡發送包的速率,所以上傳速率的限制要在eth0上做 ----刪除舊有隊列

③ 求解TC小型計算器C語言源代碼

#include<stdio.h>
main()
{
int a,b;
char ch;
printf("請輸入表達式如:1+2 \n");
scanf("%d%c%d",&a,&ch,&b);
if(ch=='/' && b==0)
printf("被除數為0請檢查表達式是否出錯?");
else
{ switch(ch)
{
case '+': printf("%d+%d=%d\n",a,b,a+b);break;
case '-': printf("%d-%d=%d\n",a,b,a-b);break;
case '*': printf("%d*%d=%d\n",a,b,a*b);break;
case '/': printf("%d/%d=%d\n",a,b,a/b);break;
}
}
}

④ Linux下帶寬限制命令TC

用iptables 試試,應該比tc簡單吧

⑤ 如何通過TC實現基於Linux系統的流量管理

接收包從輸入介面(Input Interface)進來後,經過流量限制(Ingress Policing)丟棄不符合規定的數據包,由輸入多路分配器(Input De-Multiplexing)進行判斷選擇:如果接收包的目的是本主機,那麼將該包送給上層處理;否則需要進行轉發,將接收包交到轉發塊(Forwarding Block)處理。轉發塊同時也接收本主機上層(TCP、UDP等)產生的包。轉發塊通過查看路由表,決定所處理包的下一跳。然後,對包進行排列以便將它們傳送到輸出介面(Output Interface)。一般我們只能限制網卡發送的數據包,不能限制網卡接收的數據包,所以我們可以通過改變發送次序來控制傳輸速率。Linux流量控制主要是在輸出介面排列時進行處理和實現的。

⑥ linux qos 源碼在哪個文件

關於代碼實現,首先要說的是在幀的接收和發送的時候都講到了qos. 在實際的應用中發送用的最多,而接收的控制需要其他輔助性的工作. linux下qos需要iproute2集成的tc命令,以及iptables命令等的支持和配合,它和iptables/netfilters有點類似都需要用戶空間和內核空間的配合.
QOS的控制分為Ingress 和Egress。這里主要分析出口.
調試需要iproute2的tc :
點擊(此處)折疊或打開
Linux Traffic Control is configured with the utility tc. It is part of the iproute2 package. Some Linux distributions already include tc, but it may be an old version, without support for Diffserv.
點擊(此處)折疊或打開
調試版本iproute2-4.2.0
那麼編譯iproute2需要依賴的東西:
Bison
Flex
Libdb-dev
找到tc的源碼後,我們先看看tc命令的主程序 tc.c
點擊(此處)折疊或打開
int main(int argc, char **argv)
{
int ret;
char *batch_file = NULL;

while (argc > 1) {
if (argv[1][0] != '-')
break;
if (matches(argv[1], "-stats") == 0 ||
matches(argv[1], "-statistics") == 0) {
++show_stats;
} else if (matches(argv[1], "-details") == 0) {
++show_details;
} else if (matches(argv[1], "-raw") == 0) {
++show_raw;
} else if (matches(argv[1], "-pretty") == 0) {
++show_pretty;
} else if (matches(argv[1], "-graph") == 0) {
show_graph = 1;
} else if (matches(argv[1], "-Version") == 0) {
printf("tc utility, iproute2-ss%s\n", SNAPSHOT);
return 0;
} else if (matches(argv[1], "-iec") == 0) {
++use_iec;
} else if (matches(argv[1], "-help") == 0) {
usage();
return 0;
} else if (matches(argv[1], "-force") == 0) {
++force;
} else if (matches(argv[1], "-batch") == 0) {
argc--; argv++;
if (argc <= 1)
usage();
batch_file = argv[1];
} else if (matches(argv[1], "-netns") == 0) {
NEXT_ARG();
if (netns_switch(argv[1]))
return -1;
} else if (matches(argv[1], "-names") == 0 ||
matches(argv[1], "-nm") == 0) {
use_names = true;
} else if (matches(argv[1], "-cf") == 0 ||
matches(argv[1], "-conf") == 0) {
NEXT_ARG();
conf_file = argv[1];
} else {
fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n", argv[1]);
return -1;
}
argc--; argv++;
}

if (batch_file)
return batch(batch_file);

if (argc <= 1) {
usage();
return 0;
}

tc_core_init();
if (rtnl_open(&rth, 0) < 0) {
fprintf(stderr, "Cannot open rtnetlink\n");
exit(1);
}

if (use_names && cls_names_init(conf_file)) {
ret = -1;
goto Exit;
}

ret = do_cmd(argc-1, argv+1);
Exit:
rtnl_close(&rth);

if (use_names)
cls_names_uninit();

return ret;
}

⑦ 求tc 下的多邊形裁剪演算法的源代碼

#include <graphics.h>

#include <dos.h>

union REGS i,o;

int xl=100,xr=540,yb=400,yt=200; /*方框邊界*/

void init()

{

int driver=DETECT,gm;

initgraph(&driver,&gm,"");

printf("Instruction:\n");

printf("1.Press left mouse button to set the vertex;\n");

printf("2.Press right button to end drawing;\n");

/*printf("3.Press both button to clip.");*/

outtextxy(450, 440, "Edit by lcf&hy!");

setwritemode(2);

line(0,70,639,70);

setcolor(YELLOW);

rectangle(xl,yt,xr,yb);

i.x.ax=0;

int86(0x33,&i,&o);

if(o.x.ax==0)

{

printf("Mouse is not available...");

getch();

exit();

}

i.x.ax=1;

int86(0x33,&i,&o);

/*設置游標可用范圍(Y方向)*/

i.x.ax=8;

i.x.cx=71;

i.x.dx=479;

int86(0x33,&i,&o);

}

int mousestatus(int *x,int *y)

{

i.x.ax=3; /*查詢滑鼠狀態功能號為03H*/

int86(0x33,&i,&o);

*x=o.x.cx; /*滑鼠橫坐標 */

*y=o.x.dx; /*滑鼠縱坐標 */

return o.x.bx; /*返回按鍵情況:0-NONE,1-LEFT,2-RIGHT,3-BOTH; */

}

void endpro() /*結束裁剪*/

{

char s[50]="Press any key to exit...";

setcolor(WHITE);

outtextxy(200,120,s); /*此處有可能出現亂碼,正常現象,出現概率隨機*/

getch();

closegraph();

exit();

}

void code(int x,int y,int *c )

{/*c為5元數組*/

int i;

for(i=1;i<=4;i++) c[i]=0;

if(x<xl) c[4]=1;

if(x>xr) c[3]=1;

if(y<yt) c[1]=1;

if(y>yb) c[2]=1;

}

void cut(int x1,int y1,int x2,int y2)/*把不需要的線置為黑色,不可見*/

{

setcolor(BLACK);

setlinestyle(0, 0, 3); /*設置三點寬實線*/

line(x1,y1,x2,y2);

}

int logic_ride(int *c1,int *c2)/*判斷邏輯乘是否為0,是則返回0,否則返回1*/

{

int i;

for(i=1;i<=4;i++)

{

if(c1[i]*c2[i]==1) return 1;

}

return 0;

}

int logic2_ride(int *c)/*在內部則返回1,否則返回0*/

{

int m;

for(m=0;m<=4;m++)

if(c[m]==1) return 0;

return 1;

}

void clip(int *x,int *y,int k)

/*裁剪函數,如果某個線段不在可視區,我們將其顏色置為黑色,否則不作顏色改變*/

{

/*int i;

for(i=1;i<=k;i++)

printf("%d,%d\n",x[i],y[i]);*/ /*此段代碼檢測模板存入的數據沒錯*/

int c1[5],c2[5],c[5],p,x0,y0,ultra_x,ultra_y,t;/*x0,y0儲存臨時交點*/

x[k+1]=x[1];y[k+1]=y[1];

for(p=1;p<=k;p++)

{

code(x[p],y[p],c1);

code(x[p+1],y[p+1],c2);

if(logic_ride(c1,c2)) cut(x[p],y[p],x[p+1],y[p+1]);/*完全不可見,則完全剪除*/

else if(logic2_ride(c1)==1&&logic2_ride(c2)==1) ;/*排除一種情況*/

else /*不完全在裡面,也不完全在外面*/

{

if(logic2_ride(c1)!=1)/*起點在外面*/

{

t=1;

while(t)

{

if(logic_ride(c,c2)) {cut(x[p],y[p],x[p+1],y[p+1]);break;}/*完全不可見,則完全剪除*/

else

{

if(c1[4]==1)/*判斷四邊的情況*/

{

x0=xl;

y0=y[p]+(y[p+1]-y[p])*(xl-x[p])/(x[p+1]-x[p]);

}

else if(c1[3]==1)

{

x0=xr;

y0=y[p]+(y[p+1]-y[p])*(xr-x[p])/(x[p+1]-x[p]);

}

else if(c1[1]==1)

{

y0=yt;

x0=x[p]+(x[p+1]-x[p])*(yt-y[p])/(y[p+1]-y[p]);

}

else if(c1[2]==1)

{

y0=yb;

x0=x[p]+(x[p+1]-x[p])*(yb-y[p])/(y[p+1]-y[p]);

}

cut(x[p],y[p],x0,y0);

x[p]=x0;y[p]=y0; code(x0,y0,c);

if(logic2_ride(c)==1) t=0;

}

}

}

if(logic2_ride(c2)!=1)/*終點在外面*/

{

t=1;

if(c2[4]==1)/*判斷四邊的情況*/

{

x0=xl;

y0=y[p]+(y[p+1]-y[p])*(xl-x[p])/(x[p+1]-x[p]);

}

else if(c2[3]==1)

{

x0=xr;

y0=y[p]+(y[p+1]-y[p])*(xr-x[p])/(x[p+1]-x[p]);

}

else if(c2[1]==1)

{

y0=yt; x0=x[p]+(x[p+1]-x[p])*(yt-y[p])/(y[p+1]-y[p]);

}

else if(c2[2]==1)

{

y0=yb; x0=x[p]+(x[p+1]-x[p])*(yb-y[p])/(y[p+1]-y[p]);

}

cut(x0,y0,x[p+1],y[p+1]);

code(x0,y0,c);

if(logic2_ride(c)==0)

{

if(c[4]==1)/*判斷四邊的情況*/

{

ultra_x=xl;

ultra_y=y0+(y[p+1]-y0)*(xl-x0)/(x[p+1]-x0);

}

else if(c[3]==1)

{

ultra_x=xr;

ultra_y=y0+(y[p+1]-0)*(xr-0)/(x[p+1]-x0);

}

else if(c[1]==1)

{

ultra_y=yt;

ultra_x=x0+(x[p+1]-x0)*(yt-y0)/(y[p+1]-y0);

}

else if(c[2]==1)

{

ultra_y=yb;

ultra_x=x0+(x[p+1]-x0)*(yb-y0)/(y[p+1]-y0);

}

cut(x0,y0,ultra_x,ultra_y);

}

}

}

}

endpro();

}

void draw(int *x,int *y)

{

int k=0,lx,ly,color,i;

int tempx,tempy;

while(1){

/*描點並存儲頂點*/

if(mousestatus(&tempx,&tempy)==1)

{

if(x[k]!=tempx||y[k]!=tempy) k++; /*這一步有關鍵,想想看為什麼?*/

x[k]=tempx;

y[k]=tempy;

setcolor(WHITE);

circle(tempx,tempy,1);

if (k!=1)

{

setcolor(WHITE);

line(x[k-1],y[k-1],x[k],y[k]);

}

}

lx=tempx,ly=tempy;

if(mousestatus(&tempx,&tempy)==2) /*如果按下右鍵*/

{

line(x[1],y[1],x[k],y[k]);

clip(x,y,k);

}

putpixel(tempx,tempy,WHITE);/* trace the mouse,*/

putpixel(lx,ly,BLACK);

}

}

void main()

{

int x[100],y[100];

init();

draw(x,y);

}

⑧ 誰有TC源代碼

這東西應該沒有的吧,人家還要靠他賺錢呢,不可能開放源代碼給你的
------淡淡仙戀------

⑨ linux tc 命令

希望下列網頁對你有幫助
英文man:
http://linux.die.net/man/8/tc
中文man:
http://hi..com/chuanqi_ding/blog/item/862836826ba2d6a70cf4d253.html
你也可以 man tc 獲取聯機幫助,內容與上面類似。

閱讀全文

與linuxtc源碼相關的資料

熱點內容
文件包加密是什麼意思 瀏覽:500
南方加密狗多少錢一隻 瀏覽:839
php100張恩民視頻 瀏覽:640
安卓手機復制門禁卡加密 瀏覽:754
有哪些程序員特有的技能 瀏覽:399
痞幼資源包解壓密碼 瀏覽:699
pdf版本的ppt 瀏覽:176
網站伺服器地址在哪裡 瀏覽:715
python發行版常用包 瀏覽:212
nginx無法解析php 瀏覽:829
單片機編程基礎語言 瀏覽:308
私有雲伺服器怎麼設置 瀏覽:957
程序員的晚上生活 瀏覽:585
visualc的編譯鍵不見了 瀏覽:856
51單片機畢業設計論文 瀏覽:666
3doutline怎麼擴展命令 瀏覽:861
程序員生活費200 瀏覽:339
方舟編譯器與小米 瀏覽:184
佳明app訓練怎麼用 瀏覽:989
如何查看data有沒有加密 瀏覽:502