Changing BGP packet size less than 19 and greater than 4096 - scapy

I am working with bgp implementation on ubuntu. I want to do some malformation in bgp packets , bgp restrict us on size between 19 to 4096 , however for testing purpose I am changing the size less than 19 and greater than 4096. After this when I send this packet from one to second, on established bgp session between two speakers, second one should send notification message containing error: bad message length.
But I am not getting that rather it is showing malformed packet in wireshark and also I am not able to open that packet in wireshark. Can anybody help me in this malformation of packet and to get notification error.
Just for information: I have tried every packets like open, update and keepalive. malformed open packet:

UPDATED ANSWER BELOW
The BGP packet shown in Wireshark has marker field (16 x ff) followed by length 16 (00 10).
Thus, this is indeed the scenario that you wanted to test: your tester BGP speaker sent a BGP packet with an incorrect length, and the remote BGP speaker under test should respond by sending back a NOTIFICATION packet with error code "Message Header Error" and error sub-code "Bad Message Length".
Wireshark is showing the malformed BGP packet that was sent from the tester BGP speaker to the BGP speaker under test. Wireshark is correct to complain that it is a malformed BGP packet: it is malformed because the length is invalid. Evidently, Wireshark is not very specific about what it doesn't like about the packet.
You should look in the TCP stream in the reverse direction (source 10.0.0.2 destination 10.0.0.1) and look for the BGP NOTIFICATION packet that the BGP speaker under test sent back.
UPDATED ANSWER STARTS HERE
Based on the error message ([Error] bgp_read_packet error: Connection reset), it looks like you are testing Free Range Routing, or one of its predecessors Quagga or Zebra.
I reproduced the scenario you are testing.
I am running a Free Range Routing (FRR) BGP speaker with the following configuration:
Current configuration:
!
frr version 7.1-dev-MyOwnFRRVersion
frr defaults traditional
hostname ip-172-31-31-121
log file /var/log/frr/debug.log
log syslog
service integrated-vtysh-config
!
debug bgp neighbor-events
!
router bgp 100
neighbor X.X.X.X remote-as 200
!
line vty
!
end
I use the following Python test program to send a message with a "too short" header:
#!/usr/bin/env python3
import socket
BGP_IP = 'Y.Y.Y.Y'
SHORT_MSG = (b'\xff\xff\xff\xff\xff\xff\xff\xff' # First 8 bytes of marker
b'\xff\xff\xff\xff\xff\xff\xff\xff' # Last 8 bytes of marker
b'\x00\x10' # Length 16
b'\x01') # Open
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print("Socket created")
sock.connect((BGP_IP, 179))
print("Socket connected")
sock.send(SHORT_MSG)
print("Short message sent")
while True:
data = sock.recv(1)
if data == b'':
print("Connection closed or reset")
break
print("Received:", data)
if __name__ == "__main__":
main()
Replace X.X.X.X with the IP address of the tester, and replace Y.Y.Y.Y with the IP address of the BGP speaker under test.
In this scenario, the BGP speaker under test does indeed send the correct NOTIFICATION message.
Here is what the FRR log reports:
2019/02/09 21:49:05 BGP: 172.31.17.121 [FSM] Timer (connect timer expire)
2019/02/09 21:49:05 BGP: 172.31.17.121 [FSM] ConnectRetry_timer_expired (Active->Connect), fd -1
2019/02/09 21:49:05 BGP: 172.31.17.121 [Event] Connect start to 172.31.17.121 fd 26
2019/02/09 21:49:05 BGP: 172.31.17.121 [FSM] Non blocking connect waiting result, fd 26
2019/02/09 21:49:05 BGP: bgp_fsm_change_status : vrf 0, established_peers 0
2019/02/09 21:49:05 BGP: 172.31.17.121 went from Active to Connect
2019/02/09 21:49:05 BGP: 172.31.17.121 [Event] Connect failed 111(Connection refused)
2019/02/09 21:49:05 BGP: 172.31.17.121 [FSM] TCP_connection_open_failed (Connect->Active), fd 26
2019/02/09 21:49:05 BGP: bgp_fsm_change_status : vrf 0, established_peers 0
2019/02/09 21:49:05 BGP: 172.31.17.121 went from Connect to Active
2019/02/09 21:49:08 BGP: [Event] BGP connection from host 172.31.17.121 fd 26
2019/02/09 21:49:08 BGP: bgp_fsm_change_status : vrf 0, established_peers 0
2019/02/09 21:49:08 BGP: 172.31.17.121 went from Idle to Active
2019/02/09 21:49:08 BGP: 172.31.17.121 [FSM] TCP_connection_open (Active->OpenSent), fd 26
2019/02/09 21:49:08 BGP: 172.31.17.121 passive open
2019/02/09 21:49:08 BGP: 172.31.17.121 Sending hostname cap with hn = ip-172-31-31-121, dn = (null)
2019/02/09 21:49:08 BGP: 172.31.17.121 sending OPEN, version 4, my as 100, holdtime 180, id 172.31.31.121
2019/02/09 21:49:08 BGP: bgp_fsm_change_status : vrf 0, established_peers 0
2019/02/09 21:49:08 BGP: 172.31.17.121 went from Active to OpenSent
2019/02/09 21:49:08 BGP: 172.31.17.121 bad message length - 16 for OPEN
2019/02/09 21:49:08 BGP: %NOTIFICATION: sent to neighbor 172.31.17.121 1/2 (Message Header Error/Bad Message Length) 2 bytes 00 10
2019/02/09 21:49:08 BGP: 172.31.17.121 [FSM] BGP_Stop (OpenSent->Idle), fd 26
2019/02/09 21:49:08 BGP: bgp_fsm_change_status : vrf 0, established_peers 0
2019/02/09 21:49:08 BGP: 172.31.17.121 went from OpenSent to Deleted
Note the "Bad Message Length" message.
Here is what the test program reports:
Socket created
Socket connected
Short message sent
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\xff'
Received: b'\x00'
Received: b'\x17'
Received: b'\x03'
Received: b'\x01'
Received: b'\x02'
Received: b'\x00'
Received: b'\x10'
Connection closed or reset
Note that this is the correct Bad Message Length NOTIFICATION.
Here is the Wireshark decode of the bad message:
Here is the Wireshark decode of the NOTIFICATION:
If the test program terminates without attempting to read the NOTIFICATION message, then the BGP speaker under test will not be able to send the NOTIFICATION message on the wire. This is because it will receive a TCP RST message before it is able to send the NOTIFICATION. This is most likely why you did not see the NOTIFICATION on the wire.
Indeed, I was able to reproduce this hypothesis by modifying the test program as follows:
#!/usr/bin/env python3
import socket
import struct
BGP_IP = '172.31.31.121'
SHORT_MSG = (b'\xff\xff\xff\xff\xff\xff\xff\xff' # First 8 bytes of marker
b'\xff\xff\xff\xff\xff\xff\xff\xff' # Last 8 bytes of marker
b'\x00\x10' # Length 16
b'\x01') # Open
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print("Socket created")
sock.connect((BGP_IP, 179))
print("Socket connected")
sock.send(SHORT_MSG)
# Trick TCP into sending a RST when the socket is closed
on_off = 1
linger = 0
sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', on_off, linger))
print("Socket linger time set to 0")
# Close the socket
sock.close()
print("Socket closed")
# Terminate without reading the response NOTIFICATION
if __name__ == "__main__":
main()
Using this test program, the NOTIFICATION is missing from the Wireshark trace (exactly as you reported it):
Note that I had to jump through some hoops (specifically setting the linger time to zero) to force the test program to send a RST as opposed to a FIN ACK. (See Sending a reset in TCP/IP Socket connection for details.)
If the test program sends a FIN ACK instead of a RST (which happens if you gracefully close the socket, or even terminate normally without closing the socket), then the BGP speaker under test will be able to send the NOTIFICATION after receiving the FIN ACK but before sending its own FIN ACK.

Related

Bluetooth LE connection drops immediately after connecting

I'm building an application (runs on central device) in which I can scan, connect, pair, & reconnect in LE to a specific target device (peripheral device). My application is able to scan for Bluetooth LE devices and I have set the connection function. When I run my application, it scans until it find the target device and then it starts the connecting process.
On the target side (peripheral), I can see my central device was able to connect to it but the connection is dropped immediately. I think this is because it didn't find any compatible service (I think that just means there was no recognizable GATT attirubute/application/service?). I tried to connect to the same peripheral device through bluetoothctl and the connection drops immediately which makes me think something is missing from my target device (peripheral).
I'm wondering if I need to implement anything else before I try to connect to my peripheral device? Is it disconnecting because it didn't find any recognizable service on my central?
This is what I have from btmon on the peripheral side with another connection which was successful:
Connection request
Read remote supported features (understood remote as target device)
Turn off scan
Read remote extended features
Remote name request
Found this in the BTMON. "Attribute not found" possibly the issue?
> ACL Data RX: Handle 128 flags 0x02 dlen 11 #23 [hci0] 16.564046
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Primary Service (0x2800)
< ACL Data TX: Handle 128 flags 0x00 dlen 24 #24 [hci0] 16.564325
ATT: Read By Group Type Response (0x11) len 19
Attribute data length: 6
Attribute group list: 3 entries
Handle range: 0x0001-0x0005
UUID: Generic Access Profile (0x1800)
Handle range: 0x0006-0x000f
UUID: Generic Attribute Profile (0x1801)
Handle range: 0x0010-0x0012
UUID: Device Information (0x180a)
< ACL Data TX: Handle 128 flags 0x00 dlen 11 #25 [hci0] 16.564349
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0xffff
Attribute type: Unknown (0x2b3a)
> HCI Event: Number of Completed Packets (0x13) plen 5 #26 [hci0] 16.580038
Num handles: 1
Handle: 128
Count: 1
> ACL Data RX: Handle 128 flags 0x02 dlen 11 #27 [hci0] 16.596035
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0013-0xffff
Attribute group type: Primary Service (0x2800)
> HCI Event: Number of Completed Packets (0x13) plen 5 #28 [hci0] 16.596041
Num handles: 1
Handle: 128
Count: 1
< ACL Data TX: Handle 128 flags 0x00 dlen 9 #29 [hci0] 16.596267
ATT: Error Response (0x01) len 4
Read By Group Type Request (0x10)
Handle: 0x0013
Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 128 flags 0x02 dlen 9 #30 [hci0] 16.620082
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0001
Error: Attribute Not Found (0x0a)

Weird behavior of Paho-MQTT python library on Ubuntu 20.04

I'm working on a project using paho-mqtt python library. I have two machines Raspberry pi 3 and a desktop with ubuntu 20.04. The Mosquitto broker installed on the Raspberry pi and my python code running on Ubuntu.
The two machines connected over LAN. when I use Mosquitto client CLI on Ubuntu to publish to the broker (broker running on the Raspberry pi) it is working fine but when I use python code it is working once when I run the code for many time it connects once time only. when I run the python code on the Raspberry pi it working fine without any problem.
I installed Mosquitto broker on Ubuntu also faced the same problem the python code not working properly.
I used python 3.8 and 3.5 interpreters and tried all paho-mqtt library versions but still the same problem. It also doesn't fire exceptions or show logs. it shows logs only when it connects. I think the problem is in Ubuntu 20.04. My python code below:
mqtthandeler.py
import paho.mqtt.client as mqtt
from configmanager import ConfigManager
# Retrieve the commands and configurations from the server via MQTT
class Subscriber:
def __init__(self):
self.cfg = ConfigManager()
self.cfg.get_config()
# Network connection status LEDs indicators
# MQTT connection flag
self.connected = False
def test(self, x, y, z):
print('new command = ' + str(z))
def mqtt_connect(self):
global client
# Creat instance for MQTT client
client = mqtt.Client(client_id=self.cfg.config_data['MQTT']['server id'],
clean_session=False, userdata=None,
protocol=mqtt.MQTTv311, transport='tcp')
# Set the username and password to connect to the MQTT Broker
client.username_pw_set(username=self.cfg.config_data['MQTT']['authentication']['username'],
password=self.cfg.config_data['MQTT']['authentication']['password'])
# callbacks for on connect and disconnect
client.on_connect = self.on_connect
client.on_disconnect = self.on_disconnect
client.on_message = self.on_message
client.on_log = self.on_log
# Connect to the MQTT broker
try:
client.connect_async(host=self.cfg.config_data['MQTT']['hostname'],
port=self.cfg.config_data['MQTT']['port'],
keepalive=60, bind_address="")
client.loop_start()
print('try to connect')
except Exception as e:
# If debug true print error message
print('Unable to connect to MQTT broker \n Error message: ' + e)
if self.cfg.config_data['DEBUG']:
print('Unable to connect to MQTT broker \n Error message: ' + e)
else:
print('Unable to connect to MQTT broker')
def on_log(self, client, userdata, level, buff):
print('log= ' + buff)
# If connected to the MQTT broker print the results of the connection
def on_connect(self, client, userdata, flags, rc):
self.connected = True
# Subscribe to the commands topic to receive commands from the server
client.subscribe(topic=self.cfg.config_data['MQTT']['topics']['commands'],
qos=self.cfg.config_data['MQTT']['qos'])
if self.cfg.config_data['DEBUG']:
print("Connection returned result: " + mqtt.connack_string(rc))
# If disconnected from MQTT broker print the message and try to reconnect again
def on_disconnect(self, _client, userdata, rc):
self.connected = False
if rc != 0 & self.cfg.config_data['DEBUG']:
print("Unexpected disconnection.")
# When Message received from MQTT
def on_message(self, client, userdata, message):
print("Received message '" + str(message.payload) + "' on topic '"
+ message.topic + "' with QoS " + str(message.qos))
'''#================================================================================================================#'''
# Publish data to the MQTT
class Publisher(Subscriber):
def __init__(self):
qos_cfg = ConfigManager()
qos_cfg.get_config()
self._qos = qos_cfg.config_data['MQTT']['qos']
# ================================================================================================================#
def publish(self, _topic, msg):
client.publish(topic=_topic, payload=msg, qos=self._qos)
print('Sent')
main.py
from mqtthandler import Subscriber, Publisher
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print("MDL Server Started")
# Establish connection to the MQTT broker
mqtt = Subscriber()
mqtt.mqtt_connect()
pub = Publisher()
for i in range(10):
pub.publish('prox\\', '2222\\')
Mosquitto -v output (when the code connected)
1612077624: No will message specified.
1612077624: Sending CONNACK to 2222 (1, 0)
1612077624: Received SUBSCRIBE from 2222
1612077624: command\ (QoS 1)
1612077624: 2222 1 command\
1612077624: Sending SUBACK to 2222
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m2, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m2, rc0)
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m3, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m3, rc0)
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m4, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m4, rc0)
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m5, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m5, rc0)
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m6, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m6, rc0)
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m7, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m7, rc0)
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m8, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m8, rc0)
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m9, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m9, rc0)
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m10, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m10, rc0)
1612077624: Received PUBLISH from 2222 (d0, q1, r0, m11, 'prox\', ... (5 bytes))
1612077624: Sending PUBACK to 2222 (m11, rc0)
1612077624: Socket error on client 2222, disconnecting.
and sometimes Mosquitto -v shows this output after many tries
1612078246: Socket error on client <unknown>, disconnecting.
1612079414: New connection from 192.168.10.2 on port 1883.
and sometimes nothing on Mosquitto -v
Also, I ran the code outside the virtualenv (Pycharm virtualenv) but the same behavior
I hope someone can help me. Thank you in advance
I'm just posting the solution that I found in case of someone faces the same problem.
The solution is to add a 0.1-sec delay after calling "mqtt_connect" function in main.py to give the MQTT code enough time to connect to the broker. I think this issue happens because my machine is fast so the program executes and finishes before the MQTT client gets enough time to connect.
final main.py code:
import time
from mqtthandler import Subscriber, Publisher
# Stop
# def exit():
# print('MDL Server stopped')
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print("MDL Server Started")
# Establish connection to the MQTT broker
mqtt = Subscriber()
mqtt.mqtt_connect()
time.sleep(0.1)
pub = Publisher()
for i in range(10):
pub.publish('prox\\', '2222' + '\\')

Is there a way to check the Socket Priority with Wireshark or Tcpdump?

I am doing some changes in the SO_PRIORITY of the socket that sends UDP packets, using the command setsockopt, is there a way to see that changes with Wireshark or Tcpdump.
I read that can be DSF (Differentiated Services Field), but I am not sure because when I make the changes I see that this field is 00.
I am running a Linux Mint 19.3
It is part of the 802.1Q header. For ex:
> 802.1Q Virtual LAN, PRI: 5, DEI: 0, ID: 4
101. .... .... .... = Priority: Voice, < 10ms latency and jitter (5)
...0 .... .... .... = DEI: Ineligible
.... 0000 0000 0100 = ID: 4
Type: IPv6 (0x86dd)

eof error when trying to initiate commands in python ftp_tls module

I have bought two servers both being from the same hosting company and same package,
the first server bought works perfectly, this was just for testing and experimental,
the other server which I have been told by support team that their ssl and ftp versions are the same
does not work and gives me an error in my python script when trying to initiate commands.
'''
from ftplib_custom import FTP_TLS
import ssl
import ftplib_custom
import socket
def launch():
#Wait upon user input
print("Press Enter To Initialise Server Connection: ")
input()
#Info
print("Server Found")
print("Admin Auto Login...")
print("\n")
#Connection Initiation
#Working Test Server
ftp = FTP_TLS('MyHostname', user='Username', passwd='Password')
#Not Working Server
ftp = FTP_TLS('MyHostname', user='Username', passwd='Password')
ftp.ssl_version = ssl.PROTOCOL_TLS
print(ftp.getwelcome())
ftp.set_debuglevel(1)
ftp.set_pasv(True)
ftp.prot_p()
ftp.ccc()
print ("Login Successful")
def listLineCallback(line):
msg = ("** %s*"%line)
print(msg)
#Commands
ftp.pwd()
ftp.cwd("/")
ftp.retrlines('LIST', listLineCallback)
#ftp.dir()
launch()
'''
This is what I get from the working test server...
'''
Press Enter To Initialise Server Connection:
Server Found
Admin Auto Login...
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 10:53. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
*cmd* 'PBSZ 0'
*resp* '200 PBSZ=0'
*cmd* 'PROT P'
*resp* '200 Data protection level set to "private"'
*cmd* 'CCC'
*resp* '200 Control connection unencrypted'
Login Successful
*cmd* 'PWD'
*resp* '257 "/" is your current location'
*cmd* 'CWD /'
*resp* '250 OK. Current directory is /'
*cmd* 'TYPE A'
*resp* '200 TYPE is now ASCII'
*cmd* 'PASV'
*resp* '227 Entering Passive Mode (91,103,219,222,232,11)'
*cmd* 'LIST'
*resp* '150 Accepted data connection'
** drwxr-xr-x 2 sensitive sensitive 4096 Dec 18 15:53 .*
** drwxr-xr-x 2 sensitive sensitive 4096 Dec 18 15:53 ..*
** -rw------- 1 sensitive sensitive 4 Oct 28 15:59 .ftpquota*
*resp* '226-Options: -a -l \n226 3 matches total'
'''
This is what I get if I try and connect to the main server...
'''
Server Found
Admin Auto Login...
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 10:57. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
*cmd* 'PBSZ 0'
*resp* '200 PBSZ=0'
*cmd* 'PROT P'
*resp* '200 Data protection level set to "private"'
*cmd* 'CCC'
*resp* '200 Control connection unencrypted'
Login Successful
*cmd* 'PWD'
*resp* '257 "/" is your current location'
*cmd* 'CWD /'
*resp* '250 OK. Current directory is /'
*cmd* 'TYPE A'
*resp* '200 TYPE is now ASCII'
*cmd* 'PASV'
*resp* '227 Entering Passive Mode (91,146,105,202,253,214)'
*cmd* 'LIST'
*resp* '150 Accepted data connection'
Traceback (most recent call last):
File "C:\Users\install\Desktop\WebsiteConnecting\Website_FTP_Testing.py", line 54, in <module>
launch()
File "C:\Users\install\Desktop\WebsiteConnecting\Website_FTP_Testing.py", line 51, in launch
ftp.retrlines('LIST', listLineCallback)
File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 488, in retrlines
return self.voidresp()
File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 251, in voidresp
resp = self.getresp()
File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 236, in getresp
resp = self.getmultiline()
File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 222, in getmultiline
line = self.getline()
File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 210, in getline
raise EOFError
EOFError
'''
Any help would be much appreciated and I will edit or add upon request for whats needed.
'''
EDIT:
Status: Resolving address of ########
Status: Connecting to 91.146.105.202:21...
Status: Connection established, initializing TLS...
Error: GnuTLS error -15: An unexpected TLS packet was received.
Status: Connection attempt failed with "ECONNABORTED - Connection aborted".
Error: Could not connect to server
Status: Disconnected from server
Status: Selected port usually in use by a different protocol.
Status: Resolving address of ######
Status: Connecting to 91.146.105.202:21...
Status: Connection established, initializing TLS...
Error: GnuTLS error -15: An unexpected TLS packet was received.
Status: Connection attempt failed with "ECONNABORTED - Connection aborted".
Error: Could not connect to server
Status: Waiting to retry...
Status: Resolving address of #######
Status: Connecting to 91.146.105.202:21...
Status: Connection established, initializing TLS...
Error: GnuTLS error -15: An unexpected TLS packet was received.
Status: Connection attempt failed with "ECONNABORTED - Connection aborted".
Error: Could not connect to server
'''

Buffered UDP packets during shortage time

The situation i have is Linux client is using UDP Socket. Client is sending message and in case no response within 10 seconds , Client will retry again in 10 seconds intervals.
The case is when connection is down , many trials are sent from client at the same time nothing was received on server side . Once the connection is up i found all previous messages are received at the same moment on server which means it was buffered and it causes a lot of problems because of duplicated messages received on the same moment on server side .
TCPDUMP ON client Side:
21:01:14.691903 IP 172.123.13211 > 172.34.13211: length 88 "1st at second 14"
21:01:24.692791 IP 172.123.13211 > 172.34.13211: length 88 "2nd at second 24"
21:01:34.694930 IP 172.123.13211 > 172.34.13211: length 88 "3rd at second 34"
21:01:44.696020 IP 172.123.13211 > 172.34.13211: length 88 "4th ate second 44"
Server TCPDUMP once the connection is up :
12:02:01.509518 IP 172.123.13211 > 13211: length 88 "Received 1st at second 1"
12:02:01.517841 IP 172.123.13211 > 13211: length 88 "Received 2nd at second 1"
12:02:01.543759 IP 172.123.13211 > 13211 length 88 "Received 3rd at second 1"
12:02:01.550741 IP 13211 > 172.123.13211: length 36
12:02:01.567948 IP 172.123.13211 > .13211: length 88
I need to understand in case of UDP socket is used and Connection is down .
how to avoid buffering packets during shortage
Client Code is in C++
Thank you
you might be looking for this :
How to flush Input Buffer of an UDP Socket in C?
Also the language you have used in the question is wrong. Please be more clean and precise and use relevant terminology

Resources