顯示具有 network 標籤的文章。 顯示所有文章
顯示具有 network 標籤的文章。 顯示所有文章

2020年1月8日 星期三

ebtable staudy


ebtables

默認有三個Table (filter,nat,broute)

filter 內建三個chain:INPUT/OUTPUT/FORWARD

nat 內建三個chain:PREROUTING/OUTPUT/POSTROUTING

broute內建一個chain : BROUTING



*顯示table

ebtables [-t filter] -L 顯示filter table的內容,默認也是顯示該table

ebtables -t broute -L 顯示broute table的內容

ebtables -t nat -L 顯示nat table的內容



增加一個chain

ebtables -t filter -N newChain -P ACCEPT



但此時不會有封包走到此chain,須將 chain 加到 linux 內建的 hook chain上

ebtables -t filter -A INPUT -j newChain 


ebtables -t filter -L

Bridge chain: INPUT, entries: 1, policy: ACCEPT

-j newChain 



ebtables [-t table ] -[ACDI] chain rule specification [match extensions] [watcher extensions] target    // append, delete, change-counters, insert

ebtables [-t table ] -P chain ACCEPT | DROP | RETURN                                                                      // policy, Set the policy for the chain to the given target

ebtables [-t table ] -F [chain]                                                                                                           // flush, Flush the selected chain

ebtables [-t table ] -Z [chain]                                                                                                           // zero, Set the counters of the selected chain to zero

ebtables [-t table ] -L [-Z] [chain] [ [--Ln] | [--Lx] ] [--Lc] [--Lmac2]                                                  // list, List all rules in the selected chain. If no chain is selected, all chains are listed.

                              // -L -Z , When both the -Z and -L commands are used together in this way, the rule counters are printed on the screen before they are set to zero.

                              // -L --Ln, Shows the counters at the end of each rule displayed by the -L command.

ebtables [-t table ] -N chain [-P ACCEPT | DROP | RETURN]                                                               // new-chain

ebtables [-t table ] -X [chain]                                                                                                           // delete-chain

ebtables [-t table ] -E old-chain-name new-chain-name                                                                    // rename-chain

ebtables [-t table ] --init-table                                                                                                         // Replace the current table data by the initial table data

ebtables [-t table ] [--atomic-file file] --atomic-commit

ebtables [-t table ] [--atomic-file file] --atomic-init

ebtables [-t table ] [--atomic-file file] --atomic-save





ebtables [-t table ] -[ACDI] chain rule specification [match extensions] [watcher extensions] target

ebtables [-t table ] -P chain ACCEPT | DROP | RETURN

ebtables [-t table ] -F [chain]

ebtables [-t table ] -Z [chain]

ebtables [-t table ] -L [-Z] [chain] [ [--Ln] | [--Lx] ] [--Lc] [--Lmac2]

ebtables [-t table ] -N chain [-P ACCEPT | DROP | RETURN]

ebtables [-t table ] -X [chain]

ebtables [-t table ] -E old-chain-name new-chain-name

ebtables [-t table ] --init-table

ebtables [-t table ] [--atomic-file file] --atomic-commit

ebtables [-t table ] [--atomic-file file] --atomic-init

ebtables [-t table ] [--atomic-file file] --atomic-save




2015年5月19日 星期二

struct 宣告 在big_endian 和 little_endian 上的排列

若是以bit 為單位在
big_endian : struct 由上而下 在記憶體的位置則是以bits為單位  由高位排至低位
little_endian :struct 由上而下 在記憶體的位置以1byte 為單位  由最高位byte的最低位bit開始 往記憶體低位排



以ipv6 addr packet 的前4個byte  為例 (from wiki)

例子如下:
#ifdef _BIG_ENDIAN
uint32 version:4;
uint32 tclassH:4;

uint32 tclassL:4;
uint32 flow_lblH:4;

uint32 flow_lblL:16;
#elif  _LITTLE_ENDIAN
uint32 tclassH:4;
  uint32 version:4;

uint32 flow_lblH:4;
uint32 tclassL:4;

uint32 flow_lblL:16;
#endif

其中big_endian 其實也可以寫的更簡潔
uint32 version:4;
uint32 tclass:8;
uint32 flow_lblL:20;


2015年1月21日 星期三

How many bytes in a packet?

Sometime, we found some devices that point out "forwarding rate, Mpps". The "pps" is the short term for packet per second. However, how many bytes in a packet? It depends, there is no specification on how many byte in a packet, you define it by yourself.

In the 100M Ethernet network,
100M bps / 8 = 12.5 MBps = 12500000 Bytes/s(Bps)

If you define the frame size is 64 Bytes (Minimum Ethernet framz size):
8 Bytes (preamble) + 64 Bytes + 12 Bytes (interframe gap) = 84 Bytes

So forwarding rate will be
12500000 Bps / 84 bytes = 148809 pps

If you define the frame size is 1518 Bytes (Maximum Ethernet framz size):
8 Bytes (preamble) + 1518 Bytes + 12 Bytes (interframe gap) = 1538 Bytes

So forwarding rate will be
12500000 Bps / 1538 bytes = 8127 pps

100M Ethernet's forwarding rate formula:
12500000 Bps / ( 8 Bytes (preamble) + (Feame Size) + 12 Bytes (interframe gap)) = forwarding rate, pps

2014年10月29日 星期三

net_device 結構

出處


内核源码:linux-2.6.38.8.tar.bz2

在Linux系统中,网络设备都被抽象为struct net_device结构体。它是网络设备硬件与上层协议之间联系的接口,了解它对编写网络驱动程序非常有益,所以本文将着手简要介绍linux-2.6.38.8/include/linux/netdevice.h文件中struct net_device结构体的所有成员(没有按照它们定义的顺序)。




SKB(struct sk_buff)数据结构的部分分析

出處
other
http://simohayha.iteye.com/blog/556168
skb function 操作

2014年10月16日 星期四

IGMP study / MLD

看了一篇文章寫得不錯就copy 過來看

出處
http://blog.xuite.net/azelmk2/eday/83824141

概論:
unicast: 來源和目的只有一個, 一對一傳送

multicast: 來源一個, 目的是特殊的MAC/IP (稱之為multicast group IP/MAC), 一對多.