Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7248165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:06:06+00:00 2026-05-28T22:06:06+00:00

I’m finding surprisingly little information about sockets on the internet. Maybe it’s because of

  • 0

I’m finding surprisingly little information about sockets on the internet. Maybe it’s because of my search strategy.

Will binding a socket to an end point chosen by the operating system/NAT (what is it actually chosen by?) ensure that packets sent using it will always have the same source port?

For example if I were to create socket and bind it to a port chosen by Windows (i.e. pass new IPEndPoint(IPAddress.Any, 0)) and then send two packets to different hosts, will the source port of the two packets be the same?

If yes, what’s “NAT port randomisation”? I’ve heard that it makes the NAT select a new port for each host you’re sending data to … is that the case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:06:07+00:00Added an answer on May 28, 2026 at 10:06 pm

    For example if I were to create socket and bind it to a port chosen by Windows (i.e. pass new IPEndPoint(IPAddress.Any, 0)) and then send two packets to different hosts, will the source port of the two packets be the same?

    Let’s say on your local PC computer you binded to a specific port (or even port 0 – such that the operation system picks a port for you). All packets leaving the PC will have the same source port. Guaranteed.

    But the NAT – may do something entirely different. The NAT will definitely translate the IP address to the external IP address it was assigned. And the “source port” will undergo a “mapping” translation.

    Most, but not all, well behaved NATs will try to do the following. This does not include behaviors setup via port-forwarding rules that the user may have setup manually or via UPNP.

    1. Some NATs will try to “map” the source port of the internal host to the same port value when retransmitting UDP or making a TCP connection. This isn’t always possible if another host behind the same NAT is already using that port. In that case, another port is picked.

    2. For outbound TCP connections, the port mapping will occur as the outbound SYN packet leaves the NAT. The source port mapping will remain consistent for the lifetime of the TCP connection.

    3. If a host behind a NAT sends consecutive UDP packets to the same remote IP:port pair within a given internal, a well behaved NAT will maintain the same port mapping. That is, the source port remains the same.

    4. And most well behaved NATs will maintain the same source port mapping independent of what the destination IP or destination port is. That is, if a PC behind the NAT sends UDP packets from local port 3000 to two different IP:port addresses, the NAT will translate the source port the same. This is called “address independent mapping” and is an important characteristic with setting up P2P connections with other hosts that might be behind a NAT.

    If yes, what’s “NAT port randomisation”? I’ve heard that it makes the NAT select a new port for each host you’re sending data to … is that the case?

    There are NATs that are not so well behaved. The primary fault they have is this:

    When the NAT maintains “Address and port dependent” mapping (aka “symmetric NAT”). This is where the NAT picks a random source port for each unique IP:port pair that a host behind the NAT communicates with. As such, it becomes very difficult for two hosts (both behind different symmetric NATs) to communicate with each other without a relay service. I am told that most mobile devices communicating over 3G exhibit this behavior.

    Some not-so-well-behaved NATs will even sniff the data of the packets looking for protocols that might contain internal IP addresses and then attempt to “fix” the packet such that the internal IP address communicated in the packet data is now the external IP address. This fixes problems for legacy protocols like FTP. But for other applications, this can be create more problems.

    There is a set of technologies for traversing NATs. Please read up on STUN, TURN, and ICE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.