Supported Platforms
Related Documentation
- ACX, J, M, MX, SRX Series
- BGP Configuration Overview
- Understanding External BGP Peering Sessions
Example: Limiting TCP Segment Size for BGP
This example shows how to avoid Internet Control Message Protocol (ICMP) vulnerability issues by limiting TCP segment size when you are using maximum transmission unit (MTU) discovery. Using MTU discovery on TCP paths is one method of avoiding BGP packet fragmentation.
Requirements
No special configuration beyond device initialization is required before you configure this example.
Overview
TCP negotiates a maximum segment size (MSS) value during session connection establishment between two peers. The MSS value negotiated is primarily based on the maximum transmission unit (MTU) of the interfaces to which the communicating peers are directly connected. However, due to variations in link MTU on the path taken by the TCP packets, some packets in the network that are well within the MSS value might be fragmented when the packet size exceeds the link's MTU.
To configure the TCP MSS value, include the tcp-mss statement with a segment size from 1 through 4096.
If the router receives a TCP packet with the SYN bit and the MSS option set, and the MSS option specified in the packet is larger than the MSS value specified by the tcp-mss statement, the router replaces the MSS value in the packet with the lower value specified by the tcp-mss statement.
The configured MSS value is used as the maximum segment size for the sender. The assumption is that the TCP MSS value used by the sender to communicate with the BGP neighbor is the same as the TCP MSS value that the sender can accept from the BGP neighbor. If the MSS value from the BGP neighbor is less than the MSS value configured, the MSS value from the BGP neighbor is used as the maximum segment size for the sender.
This feature is supported with TCP over IPv4 and TCP over IPv6.
Topology Diagram
Figure 1 shows the topology used in this example.
Figure 1: TCP Maximum Segment Size for BGP

Configuration
CLI Quick Configuration
To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.
R0
Step-by-Step Procedure
The following example requires that you navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure Router R0:
- Configure the interfaces.[edit interfaces]user@R0# set fe-1/2/0 unit 1 family inet address 1.1.0.1/30user@R0# set lo0 unit 1 family inet address 10.255.14.179/32
- Configure an interior gateway protocol (IGP), OSPF in
this example.[edit protocols ospf area 0.0.0.0]user@R0# set interface fe-1/2/0.1user@R0# set interface 10.255.14.179
- Configure one or more BGP groups.[edit protocols bgp group int]user@R0# set type internaluser@R0# set local-address 10.255.14.179
- Configure MTU discovery to prevent packet fragmentation.[edit protocols bgp group int]user@R0# set mtu-discovery
- Configure the BGP neighbors, with the TCP MSS set globally
for the group or specifically for the various neighbors. [edit protocols bgo group int]user@R0# set tcp-mss 2020user@R0# set neighbor 10.255.14.177user@R0# set neighbor 10.255.71.24 tcp-mss 2000user@R0# set neighbor 10.0.14.4 tcp-mss 4000
Note: The TCP MSS neighbor setting overrides the group setting.
- Configure the local autonomous system.[edit routing-options]user@R0# set autonomous-system 65000
Results
From configuration mode, confirm your configuration by entering the show interfaces, show protocols, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
If you are done configuring the device, enter commit from configuration mode.
Verification
To confirm that the configuration is working properly, run the following commands:
- show system connections extensive | find <neighbor-address>, to check the negotiated TCP MSS value.
- monitor traffic interface, to monitor BGP traffic and to make sure that the configured TCP MSS value is used as the MSS option in the TCP SYN packet.
Troubleshooting
MSS Calculation with MTU Discovery
Problem
Consider an example in which two routing devices (R1 and R2) have an internal BGP (IBGP) connection. On both of the routers, the connected interfaces have 4034 as the IPv4 MTU.
user@R1# show protocols bgp | display set
[edit] set protocols bgp group ibgp type internal set protocols bgp group ibgp local-address 45.45.45.2 set protocols bgp group ibgp mtu-discovery set protocols bgp group ibgp neighbor 45.45.45.1
user@R1# run show interfaces xe-0/0/3 extensive
| match mtu
Link-level type: Ethernet, MTU: 4048, LAN-PHY mode, Speed: 10Gbps, FIFO errors: 0, HS link CRC errors: 0, MTU errors: 0, Resource errors: 0 Protocol inet, MTU: 4034, Generation: 180, Route table: 0 Protocol multiservice, MTU: Unlimited, Generation: 181, Route table: 0
In the following packet capture on Device R1, the negotiated MSS is 3994. In the show system connections extensive information for MSS, it is set to 2048.
05:50:01.575218 Out Juniper PCAP Flags [Ext], PCAP Extension(s) total length 16 Device Media Type Extension TLV #3, length 1, value: Ethernet (1) Logical Interface Encapsulation Extension TLV #6, length 1, value: Ethernet (14) Device Interface Index Extension TLV #1, length 2, value: 137 Logical Interface Index Extension TLV #4, length 4, value: 69 -----original packet----- 00:21:59:e1:e8:03 > 00:19:e2:20:79:01, ethertype IPv4 (0x0800), length 78: (tos 0xc0, ttl 64, id 53193, offset 0, flags [DF], proto: TCP (6), length: 64) 45.45.45.2.62840 > 45.45.45.1.bgp: S 2939345813:2939345813(0) win 16384 **mss 3994,nop,wscale 0,nop,nop,timestamp 70559970 0,sackOK,eol> 05:50:01.575875 In Juniper PCAP Flags [Ext, no-L2, In], PCAP Extension(s) total length 16 Device Media Type Extension TLV #3, length 1, value: Ethernet (1) Logical Interface Encapsulation Extension TLV #6, length 1, value: Ethernet (14) Device Interface Index Extension TLV #1, length 2, value: 137 Logical Interface Index Extension TLV #4, length 4, value: 69 -----original packet----- PFE proto 2 (ipv4): (tos 0xc0, ttl 255, id 37709, offset 0, flags [DF], proto: TCP (6), length: 64) 45.45.45.1.bgp > 45.45.45.2.62840: S 2634967984:2634967984(0) ack 2939345814 win 16384 **mss 3994,nop,wscale 0,nop,nop,timestamp 174167273 70559970,sackOK,eol>
user@R1# run show system connections extensive
| find 45.45
tcp4 0 0 45.45.45.2.62840 45.45.45.1.179 ESTABLISHED sndsbcc: 0 sndsbmbcnt: 0 sndsbmbmax: 131072 sndsblowat: 2048 sndsbhiwat: 16384 rcvsbcc: 0 rcvsbmbcnt: 0 rcvsbmbmax: 131072 rcvsblowat: 1 rcvsbhiwat: 16384 proc id: 19725 proc name: rpd iss: 2939345813 sndup: 2939345972 snduna: 2939345991 sndnxt: 2939345991 sndwnd: 16384 sndmax: 2939345991 sndcwnd: 10240 sndssthresh: 1073725440 irs: 2634967984 rcvup: 2634968162 rcvnxt: 2634968162 rcvadv: 2634984546 rcvwnd: 16384 rtt: 0 srtt: 1538 rttv: 1040 rxtcur: 1200 rxtshift: 0 rtseq: 2939345972 rttmin: 1000 mss: 2048
Solution
This is expected behavior with Junos OS. The MSS value is equal to the MTU value minus the IP or IPv6 and TCP headers. This means that the MSS value is generally 40 bytes less than the MTU (for IPv4) and 60 bytes less than the MTU (for IPv6). This value is negotiated between the peers. In this example, it is 4034 - 40 = 3994. Junos OS then rounds this value to a multiple of 2 KB. The value is 3994 / 2048 * 2048=2048. So it is not necessary to see same MSS value with in the show system connections output.
3994 / 2048 = 1.95
1.95 is rounded to 1.
1 * 2048 = 2048
Related Documentation
- ACX, J, M, MX, SRX Series
- BGP Configuration Overview
- Understanding External BGP Peering Sessions
Published: 2014-07-23
Supported Platforms
Related Documentation
- ACX, J, M, MX, SRX Series
- BGP Configuration Overview
- Understanding External BGP Peering Sessions