79656631

Date: 2025-06-07 02:26:47
Score: 3
Natty:
Report link

Use application-layer ACK to bypass the ICMP mechanism

Here is a new answer that you would be like.The traditional ways of shielding and increased listening are High latency and instability.

For a development company,the efficiency,stability,and security of a soulation are factors that cannnot be ignored,especially for network communication.

So your boss don't like this soultation is all right.

I'll only use Python to explain and answer your question(because I really don'h know Go well)

Now ,think about the advantage of UDP.

The answer is msut on the tip of your tongue.It's efficiency. But this advantage is what we gained at the cost of sacrificing security and reliability.

So ,is there a solution that can achieve both,or make the most of the advantages of both approaches?

Year,the cleaver programmer thought that could we use the UDP Simulated TCP,or we use the TCP simulated UDP.(Think carefully about this sentence! It's a interesting idea

First way-Customize ACK to simulate TCP acknowledment mechanism

#sender 
import socket
def send_with_retry(sock,data,max_retries = 3):
    seq_id = 1 
    packet = f"{seq_id}:{data}".encode()

    for attempt in range(max_retries):
        sock.sendto(packet, addr)
        sock.settimeout(1.0) #wait for a minute to ACK
        try:
            ack_data, _ = sock.recvfrom(1024)
            ack_seq = int(ack_data.decome().split(":")[1])
            if ack_seq == seq_id;
                return True
            except socket.timeout:
                print(f"TIMEOUT, retrying...{{attempt + 1}/{max_retries}}"}
                continue
            return False
#receiver
def handle_packet(sock)
    data, addr = sock.recvfrom(1024)
    seq_id, payload = data.decode().split(":",1)
    print(f"RECEIVED: {payolad}")

    sock.sendto(f"ACK:{seq_id}".encode(),addr) #return ack

This is the most basic UDP imitation TCP code,it can be called a template.

Asa a basic template,your boss mat refuse it again.

So how will you change it?You can set a log to record,add Serial Number(For python,the most standard way to do this is to use _next_seq_id )to deduplication,and you can also sonfigure error handling to make the program more stable and secure. (If you need these code can call me again)

Use a new control

In the above,I've said an interesting idea:Use UDP simulate the TCP,and we make it(really?)

Why these control have these advantages?

UDP is efficient because it gives up some things like ACK , resend ,congestion control.You will find that the implementation of these tunctions has a huge overhead,which is why TCP is not efficient.

In other words ,TCP is doomed to be inefficient unless it abandons these things ,but when it abandons these things ,it is no longer TCP.

TCP can not simulate UDP,you will find this process is about weighing the pros and cons,just like when we make a circuit we considder the efficiency of the entire circuit,and when we manage finances we give up something.

Now you may ask a question:Dosen't that mean everything ia s trade-off?

This is wrong,because UDP and TCP are not extremes in terms of safety and efficiency.

Now you need a new IP haha

Just like QUIC , SCTP , DCCP ...

I know a little thing about QUIC by chance,It's really convenient:

#it use aioquic library
from aioquic.quic.configuration import QuicConfiguration
from aioquic.quic.connection import QuicConnection

config = QuicConfiguration(is_client = True)
conn = QuicConnection(config = config)
conn.connect(address=("example.com",4433))
conn.send_stream_data(stream_id = 0,data=b"Nice to meet you")

If your boss particularly likes UDP,you can learn about UDT,it's a high-performance UDP library.

Wish this answer can solve your question.

Reasons:
  • Blacklisted phrase (3): is there a solution
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: taoqingbaiyi