Jumbo Frame(巨幀)
站在用戶的角度思考問題,與客戶深入溝通,找到浦江網(wǎng)站設(shè)計與浦江網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都網(wǎng)站制作、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名注冊、網(wǎng)站空間、企業(yè)郵箱。業(yè)務覆蓋浦江地區(qū)。IEEE 802.3以太網(wǎng)標準僅規(guī)定支持1500Byte的幀MTU,總計1518Byte的幀大小。(使用IEEE 802.1Q VLAN/QoS標簽時,增加至1522Byte)而巨型幀往往采用9000Byte的幀MTU,合計9018/9022Byte的幀大小。
目前巨型幀尚未成為官方的IEEE 802.3以太網(wǎng)標準的一部分。所以不同硬件廠商的設(shè)備支持程度可能不盡相同。
使用巨型幀,增大的有效報文長度提升了帶寬使用效率的提升(如下圖)。與此同時,增長的報文也帶來傳輸時延的增加,時延敏感型數(shù)據(jù)并不適合使用巨型幀傳輸。
neutron中的MTU配置項
從配置項的描述總結(jié)而言,global_physnet_mtu與physical_network_mtus共同定義了underlay physical network的MTU,path_mtu定義了overlay network的MTU。
**調(diào)整MTU的3個用例
單MTU值物理網(wǎng)絡(luò)體系**
在neutron.conf中
1.[DEFAULT]
2.global_physnet_mtu?=?900
在ml2.ini中
1.[ml2]??
2.path_mtu?=?9000
該配置定義了所有underlay網(wǎng)絡(luò)(flat,vlan)與overlay網(wǎng)絡(luò)(vxlan,gre)的MTU值均為9000。
多MTU值物理網(wǎng)絡(luò)體系
在neutron.conf中
1.[DEFAULT]??
2.global_physnet_mtu?=?9000?
在ml2.ini中
1.? [ovs]??
2.??bridge_mappings?=?provider1:eth2,provider2:eth3,provider3:eth4??
3.? [ml2]??
4.??physical_network_mtus?=?provider2:4000,provider3:1500??
5.??path_mtu?=?9000??
該配置定義了underlay網(wǎng)絡(luò)provider2的MTU值為4000,provider3的MTU值為1500,其他如provider1的MTU值為9000。而overlay網(wǎng)絡(luò)的MTU值為9000。
Overlay網(wǎng)絡(luò)MTU
在neutron.conf中
2.?global_physnet_mtu?=?9000?
在ml2.ini中
2.?path_mtu?=?4000?
該配置定義了所有underlay網(wǎng)絡(luò)MTU值為9000,overlay網(wǎng)絡(luò)的MTU值均為4000。
代碼淺析
創(chuàng)建network resource時的MTU處理
flat和vlan網(wǎng)絡(luò),根據(jù)實際的物理網(wǎng)絡(luò)映射與physical_network_mtus、global_physnet_mtu信息,獲取最小可用MTU值。
1.??def?get_deployment_physnet_mtu():??
2.??return?cfg.CONF.global_physnet_mtu??
3.? ??
4.??class?BaseTypeDriver(api.ML2TypeDriver):??
5.??def?init(self):??
6.??try:??
7.? self.physnet_mtus = helpers.parse_mappings(??
8.? cfg.CONF.ml2.physical_network_mtus, unique_values=False??
9.? ? )??
10.??except?Exception as e:??
11.? LOG.error("Failed to parse physical_network_mtus: %s", e)??
12.? self.physnet_mtus = []??
13.? ?
14.??def?get_mtu(self, physical_network=None):??
15.???return?p_utils.get_deployment_physnet_mtu()??
16.? ?
17.?class?FlatTypeDriver(helpers.BaseTypeDriver):??
18.? ? ?...??
19.??def?get_mtu(self, physical_network):??
20.? seg_mtu = super(FlatTypeDriver, self).get_mtu()??
21.??mtu?= []??
22.? if seg_mtu > 0:??
23.? ?mtu.append(seg_mtu)??
24.???if?physical_network in self.physnet_mtus:??
25.? mtu.append(int(self.physnet_mtus[physical_network]))??
26.??return?min(mtu) if mtu else 0??
27.? ?
28.?class?VlanTypeDriver(helpers.SegmentTypeDriver):??
29.? ? ?...??
30.??def?get_mtu(self, physical_network):??
31.? seg_mtu = super(VlanTypeDriver, self).get_mtu()??
32.? mtu = []??
33.??if?seg_mtu > 0:??
34.? mtu.append(seg_mtu)??
35.??if?physical_network in self.physnet_mtus:??
36.? mtu.append(int(self.physnet_mtus[physical_network]))??
37.??return?min(mtu) if mtu else 0??
Geneve,Gre,Vxlan類型網(wǎng)絡(luò),則根據(jù)global_physnet_mtu與path_mtu中選取最小的可用MTU值,減去各類型報文頭部開銷,獲取實際可用MTU值。
1.? class _TunnelTypeDriverBase(helpers.SegmentTypeDriver):??
2.? ...??
3.? def get_mtu(self, physical_network=None):??
4.? seg_mtu = super(_TunnelTypeDriverBase, self).get_mtu()??
5.? mtu = []??
6.? if seg_mtu > 0:??
7.? mtu.append(seg_mtu)??
8.? if cfg.CONF.ml2.path_mtu > 0:??
9.? mtu.append(cfg.CONF.ml2.path_mtu)??
10.? version = cfg.CONF.ml2.overlay_ip_version??
11.? ip_header_length = p_const.IP_HEADER_LENGTH[version]??
13.? ?
15.? ...??
def get_mtu(self, physical_network=None):??
mtu = super(GeneveTypeDriver, self).get_mtu()??
19.? ?
21.? ? ?...??
23.? mtu = super(GreTypeDriver, self).get_mtu(physical_network)??
24.? return mtu - p_const.GRE_ENCAP_OVERHEAD if mtu else 0??
25.? ? ? ? ? ?
27.? ...??
def get_mtu(self, physical_network=None):??
mtu = super(VxlanTypeDriver, self).get_mtu()??
在用戶實際創(chuàng)建network資源時,若未顯式指定網(wǎng)絡(luò)MTU值,則使用該網(wǎng)絡(luò)類型下系統(tǒng)定義的大可用MTU。若顯式指定MTU,neutron會檢查用戶定義MTU是否小于等于該網(wǎng)絡(luò)類型下系統(tǒng)定義的大可用MTU。
1.? def _get_network_mtu(self, network_db, validate=True):??
2.? mtus = []??
3.? ...??
4.? for s in segments:??
5.? segment_type = s.get('network_type')??
6.? if segment_type is None:??
7.? ?...??
8.? else:??
9.? mtu = type_driver.get_mtu(s['physical_network'])??
11.? # then is that for the segment type, MTU has no meaning or??
13.? if mtu:??
14.? mtus.append(mtu)??
15.? ?
max_mtu = min(mtus) if mtus else p_utils.get_deployment_physnet_mtu()??
18.? ?
19.? if validate:??
20.? # validate that requested mtu conforms to allocated segments??
21.? if net_mtu and max_mtu and max_mtu < net_mtu:??
msg = _("Requested MTU is too big, maximum is %d") % max_mtu??
24.? ?
25.? # if mtu is not set in database, use the maximum possible??
虛擬機tap設(shè)置MTU
在使用Linux Bridge實現(xiàn)的Neutron網(wǎng)絡(luò)中,Linux Bridge Agent在偵測到新的device后,會通過ip link set 操作,根據(jù)network中的MTU值,設(shè)置虛擬機綁定至Linux Bridge的tap設(shè)備的MTU值。反觀Openvswitch實現(xiàn)的網(wǎng)絡(luò)中卻沒有相關(guān)的設(shè)置。實際在使用過程中需要通過ovs-vsctl set Interface
1.? class LinuxBridgeManager(amb.CommonAgentManagerBase):??
2.? def plug_interface(self, network_id, network_segment, tap_name,??
3.? device_owner):??
4.? return self.add_tap_interface(network_id, network_segment.network_type,??
5.? network_segment.physical_network,??
6.? network_segment.segmentation_id,??
7.? tap_name, device_owner,??
8.? network_segment.mtu)??
9.? ??
10.? def _set_tap_mtu(self, tap_device_name, mtu):??
網(wǎng)絡(luò)設(shè)備tap設(shè)置MTU
dhcp和router相關(guān)的tap設(shè)備在plug時,neutron會根據(jù)網(wǎng)絡(luò)的MTU,在各tap設(shè)備所在的namespace內(nèi)運行“ip link set
1.? class OVSInterfaceDriver(LinuxInterfaceDriver):??
3.? bridge=None, namespace=None, prefix=None, mtu=None):??
4.? ...??
5.? # NOTE(ihrachys): the order here is significant: we must set MTU after??
6.? # the device is moved into a namespace, otherwise OVS bridge does not??
7.? # allow to set MTU that is higher than the least of all device MTUs on??
8.? # the bridge??
9.? if mtu:??
10.? self.set_mtu(device_name, mtu, namespace=namespace, prefix=prefix)??
11.? else:??
12.? LOG.warning("No MTU configured for port %s", port_id)??
13.? ...??
14.? ?
16.? if self.conf.ovs_use_veth:??
tap_name = self._get_tap_name(device_name, prefix)??
19.? tap_name, device_name, namespace2=namespace)??
20.? root_dev.link.set_mtu(mtu)??
else:??
23.? ns_dev.link.set_mtu(mtu)??
24.? ?
class IpLinkCommand(IpDeviceCommandBase):??
27.? ? ?...??
28.? def set_mtu(self, mtu_size):??
29.? self._as_root([], ('set', self.name, 'mtu', mtu_size))?
bridge間veth設(shè)置MTU
Openstack從J版以后,neutron使用ovs patch port代替了linux veth實現(xiàn)OVS網(wǎng)橋之間的連接(出于性能提升的目的)。但依舊保留了veth連接的方式。在openvswitch_agent.ini中可以通過配置use_veth_interconnection=true啟用veth連接網(wǎng)橋的功能。如果開啟這項配置,默認的veth_mtu值為9000。當配置鏈路MTU大于9000時,需要修改openvswitch_agent.ini配置文件中veth_mtu的值,以免發(fā)生瓶頸效應。
1.? class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,??
2.? dvr_rpc.DVRAgentRpcCallbackMixin):??
3.? def init(self, bridge_classes, ext_manager, conf=None):??
4.? ...??
5.? self.use_veth_interconnection = ovs_conf.use_veth_interconnection??
6.? self.veth_mtu = agent_conf.veth_mtu??
7.? ?...??
8.? def setup_physical_bridges(self, bridge_mappings):??
9.? ?'''''Setup the physical network bridges.?
10.??
11.? Creates physical network bridges and links them to the?
12.? integration bridge using veths or patch ports.?
13.??
14.? ?:param bridge_mappings: map physical network names to bridge names.?
15.? ?'''??
16.? self.phys_brs = {}??
17.? self.int_ofports = {}??
18.? self.phys_ofports = {}??
19.? ip_wrapper = ip_lib.IPWrapper()??
20.? ovs = ovs_lib.BaseOVS()??
21.? ovs_bridges = ovs.get_bridges()??
22.? for physical_network, bridge in bridge_mappings.items():??
23.? ?...??
24.? ?if self.use_veth_interconnection:??
25.? ?# enable veth to pass traffic??
26.? int_veth.link.set_up()??
27.? ?phys_veth.link.set_up()??
28.? ?if self.veth_mtu:??
29.? ?# set up mtu size for veth interfaces??
30.? int_veth.link.set_mtu(self.veth_mtu)??
31.? phys_veth.link.set_mtu(self.veth_mtu)??
32.? else:??
33.? # associate patch ports to pass traffic??
34.? self.int_br.set_db_attribute('Interface', int_if_name,??
35.? ?'options', {'peer': phys_if_name})??
36.? br.set_db_attribute('Interface', phys_if_name,??
37.? ? 'options', {'peer': int_if_name})??
虛擬機網(wǎng)卡如何設(shè)置MTU
虛擬機內(nèi)部網(wǎng)卡配置MTU則是通過虛擬機DHCP請求IP地址時,順便請求MTU值。在RFC2132 DHCP Option and BOOTP Vendor Extensions里明確定義了Interface MTU Option。DHCP Option Code 26 用兩個字節(jié)的MTU數(shù)據(jù),定義了網(wǎng)絡(luò)接口的MTU值。如下表所示。
在DHCP agent中,dnsmasq的spawn_process會根據(jù)network的MTU值調(diào)整自身的啟動參數(shù)。從而使虛擬機在DHCP過程中能正確地配置自身網(wǎng)卡的MTU值。
1.? class Dnsmasq(DhcpLocalProcess):??
2.? def _build_cmdline_callback(self, pid_file):??
3.? # We ignore local resolv.conf if dns servers are specified??
4.? # or if local resolution is explicitly disabled.??
5.? ...??
6.? mtu = getattr(self.network, 'mtu', 0)??
7.? ?# Do not advertise unknown mtu??
8.? ?if mtu > 0:??
9.? cmd.append('--dhcp-option-force=option:mtu,%d' % mtu)??
10.? ?...??
11.? return cmd??
探測MTU
通過指定ICMP報文內(nèi)容size以及IP報文不分片來探測MTU值設(shè)置是否正確。注意這里的size是指icmp data size。該size并不包含ICMP報文頭部長度(8Byte)以及IP頭部長度(20Byte)。
windows下:
1.? ping -f -l
linux下:
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。