i didnt understand what the teacher meant when saying while explaining about ports.."from the sending machine you could actually put the destination port number on the packet and the other side would be able to go out". where sending packet from my machine puts beside my address my port and not the destination port(as resembled in netstat -a) (Course: MTA Networking Fundamentals - 98-366 (UPDATE 2018))
about ports in networking
Remember that a single computer, can send different types data (e.g. email, http and snmp) all that data is leaving the source computer as signal or bits. The source must differentiate this data so that when it's on the network, the data can arrive at the right computer (via the IP address) and also so that right application is delivered that data and there is no ambiguity. Port numbers are used for this.
A sending computer generates an ephemeral port (dynamic) and attaches that the source IP address. But insure that the right computer and right application on the destination computer get it. It sends the destination IP address to get to the destination computer then uses the default port number, which the application is "listening" on to get it to the right application.
Let me know if I only added to the confusion. I hope this explains it better.
Also I moved this topic to a more generic category as you were asking about networking but also about a Microsoft show.
so that if we say my computer(source computer) sends a request on the network 192.168.2.130:5002 and the destination computer replies by 54..123.334.17:https
then my port (5002) will be configured as https port? so that we can say it can be like that 192.168.2.130:https instead of 192.168.2.130:5002 ?
where 5002 be same as https after the destination replies on my response?
As @Ronnie-Wong mentioned, ports allow a single IP address to establish multiple connections.
The sending device can use any port, usually in the dynamic port range (49152-65535).
The sending device will address the packet with the destination IP address and the port associated with the protocol being used (443 for HTTPS for example).
So if my computer has an IP address of 192.168.1.1 and I make a secure connection with a web server who has an IP address of 126.96.36.199, it would look like this...
192.168.1.1:55123 -> 188.8.131.52:443
55123 is a dynamic port that my computer picked at random (that was not being used for anything else).
443 is the well known port for HTTPS
The web server would send the requested web page back to my computer, using the IP address and port number that my computer used to send the packet
184.108.40.206:443 -> 192.168.1.1:55123
There is now an established connection between my computer and the web server.
If I open another tab in my browser and connect to a different web server, let's say 220.127.116.11, my computer would establish a second connection, using the same sending IP, but a different port number.
192.168.1.1:56321 -> 18.104.22.168:443
The second web server would send traffic back using the port number my computer chose.
22.214.171.124:443 -> 192.168.1.1:56321
So now my computer has two secure connections with two different web servers, using one IP address and two different port numbers.
The return traffic to my computer doesn't use the well-known port for the protocol, but the dynamic port that my computer decided to use.
Hope this helps,