07-24-2019 01:23 AM
Hi dear Cisco Experts
Can we define a specific packet size for transferring through the network?
For Example; we want to send a text file of 150,000 bytes, Can we send it as packets of custom size (for example packets of 13840 bytes) ?!
Solved! Go to Solution.
07-26-2019 03:29 AM
Hello Moein,
in a TCP transfer between two endpoints the MSS = Maximum Segment Size is negotiated at session setup.
Usually the MSS is equal to : IP MTU - IPv4 header - TCP header = 1500 -20 -20 = 1460 bytes.
So a file transfer of a text file of size 141200 bytes would use:
96 packets with MSS = 1460 bytes and a last packet of 1040 bytes at TCP level
at IP level we would have 96 packets of size 1500 and one packet of size 1080 bytes.
In order to force a MSS of 1400 the endpoints or the router interfaces facing the endpoints require specific configuration.
In order to use only packets of a fixed size a custom application would be needed on endpoints using some form of padding (adding binary 00) to make last packet size equal to all other packets.
Hope to help
Giuseppe
07-24-2019 03:26 AM
Hello Moein,
the packet size is negotiated by the two endpoints in TCP session setup.
A packet size of 13840 bytes is too big and would require fragmentation and would cause lower performance end devices should perform fragment re-assembly and would use buffer resources to store all fragments.
Routers in the path cannot know what is the size negotiated by the two endpoints.
Hope to help
Giuseppe
07-24-2019 06:54 AM
07-25-2019 12:49 AM - edited 07-25-2019 12:51 AM
Hello Moein,
as far as I know we can use a match size in a route-map used for PBR.
However, packets not matching PBR are usually routed by destination based routing.
To have packets with only a specific size to pass you should use the following:
An extended ACL defining the involved endpoints both directions may be useful like
access-list 112 permit ip host 10.10.11.23 host 10.10.22.55
access-list 112 pemit ip host 10.10.22.55 host 10.10.11.23
Your route-map shoud look like something like
route-map PBR-size permit 10
match address 112
match not length 1384
! following discard packets with size not expected between addresses permitted by ACL 112
! sending packets to null0 means silent drop
set interface null0
route-map PBR-size permit 20
match address 112
match length 1384
! we perform no action here
The route-map has to be applied on the interface receiving packets on the path.
This can be supported on routers and multilayer switches, but not on L2 only switches.
see following link
note: you need to verify with tests what length matches (L3 PDU size OR L3 PDU plus some L2 overhead ?)
The use of an extended ACL combined with the check on packet length is necessary to avoid to drop packets that need to be accepted and routed
Edit:
on carrier grade ASR 9000 support for checking packet length in QoS class-maps has been introduced in IOS XR 5.2
see following thread
Here, the suggestions is to rate-limit instead of always dropping in a context of defense against DoS attacks.
Hope to help
Giuseppe
07-26-2019 03:12 AM
07-26-2019 03:29 AM
Hello Moein,
in a TCP transfer between two endpoints the MSS = Maximum Segment Size is negotiated at session setup.
Usually the MSS is equal to : IP MTU - IPv4 header - TCP header = 1500 -20 -20 = 1460 bytes.
So a file transfer of a text file of size 141200 bytes would use:
96 packets with MSS = 1460 bytes and a last packet of 1040 bytes at TCP level
at IP level we would have 96 packets of size 1500 and one packet of size 1080 bytes.
In order to force a MSS of 1400 the endpoints or the router interfaces facing the endpoints require specific configuration.
In order to use only packets of a fixed size a custom application would be needed on endpoints using some form of padding (adding binary 00) to make last packet size equal to all other packets.
Hope to help
Giuseppe
07-26-2019 08:56 AM
07-29-2019 12:07 AM
Hello Moein,
I am not able to provide help in developing the custom application.
There are some points that I would like to point out:
you should use the lowest level libraries available for example C++ and libraries at low level interacting with TCP/IP.
However, in most cases for the layered approach the library you can use make an API call to operating system TCP/IP stack opening a so called socket and performing reads and writes on the socket handle (like it was a file handle).
The issues arises for the first packets used to set up the TCP session :
Sender A sends a packet with SYN TCP flag set to host B on a well known port representing a service.
The packet contains the initial sequence number ISN used by sender A for sending user data.
Host B answers with a packet with SYN TCP flag, ACK flag set with SenderA's ISN+1 in the ACK field and ISNb in the sequence number field
The host A answers with an ACK containing ISNb+1 in ACK value and TCP ACK flag set.
The issue here is that these first three packets do not carry user data and create the socket.
So we should be able to discriminate these initial packets from following packets.
In the case of Cisco routers it is not possible to match TCP flags directly but there is the keyword established that means SYN flag not set. So the extended ACL should be something like:
access-list 130 permit tcp host host-A host host-B established
access-list 130 permit tcp host host-B host host-A established
However, the third packet in the TCP three way handshake has the SYN flag unset and qualifies to match the above ACL.
Here it is the difficulty of this approach: even the lowest level library that you can find may use operating system API calls to create the socket and a socket handler is made available to your program after the three packets are exchanged.
If so the issue is how to allow the third packet to be transmitted even if its size cannot be adjusted to the desired size and it is already classified as TCP established.
So it is real a challenging task to make a program that implement the custom application.
You would need to find a customizable TCP/IP stack to use instead of standard calls to make the size of third packet the desired size.
For understanding all the details of the TCP protocol you can refer to two very famous books
TCP/IP illustrated Volume I Stevens
"Internetworking with TCP/IP volume I" by Douglas Comer. This book explains all the details about TCP/IP and many details about different implementations.
see
https://doc.lagout.org/network/Internetworking%20with%20TCP_IP%20%20Vol%20I.pdf
As far as I know the first packet with user data should be packet number 4.
Hope to help
Giuseppe
07-24-2019 08:44 AM
07-25-2019 12:29 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide