[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
whats the difference between a socket and a port on the session layer?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 16
Thread images: 1
File: Sad-Frog-Meme-Gun-021.jpg (9 KB, 267x181) Image search: [Google]
Sad-Frog-Meme-Gun-021.jpg
9 KB, 267x181
whats the difference between a socket and a port on the session layer?
>>
socket - the endpoint IP, the protocol, and the port.

port - the port number
>>
dumb frogposter
>>
>>54647414
soooo, sockets are primarily used for networking APIs and ports are used for transporting TCP/UDP?
>>
>>54647414
Why don't they call it something us normies can understand, like "setup" or "configuration"
>>
>>54649076
Ports are used to redirect traffick.

It works by something called "masquerading" where a port coming from a ip (lets say port 22 from 192.168.1.5) gets redirected to a higher port number (41515 or similar)

Internally it looks like 192.168.1.5 is sending from port 22 out to the world. The router then takes that package, links port 22 on 192.168.1.5 up to port 41515 and send it off. The receiver will see the public ip (51.414.232.13 something, your public ip) and the port 41515. When The receiver responds, he send a packet back to 51.414.232.13 port 41515. Since it's on port 41515, your router knows that it's meant for 192.168.1.5 port 22 since that is what it dedicated 41515 for.

Basically, it's just portforwarding but automatic.

That's how the ports work.

Physical ports (the ones you plug ethernet cables into) are used to assign mac-adresses (machines) into vlans.
>>
>>54649434
>educational post on /g/

what the fuck
>>
>>54649434
what are you talking about, you just killed my brain.

>>54649076
socket is an active connection on a port.
>>
>>54649434
Thanks for the information
>>
>>54649434
oh so internally your port will be advertised as say 22 for example but past your gateway it will be advertised as 41515.

why does it need to assign it another port number. Can it not just use the same port?

example port 80 stays as 80 for http traffic

why does it need to sign it another port up to 65000?
>>
>>54650415

because multiple computers might use the same local port on their individual machines (22, for example is for SSH) so it redirects each individual connection a new higher port (usually in the 5 decimals range meaning anywhere in XXXXX) so that the router knows which computer the connection is meant for.

If every machine used port 22, then how would the router know which machine the packets were meant for?

It's basically the answer to "how does the router know which computer the packet is meant for?"

Sorry for late reply. I had a quick powernap. Also, you worded it more elegantly than me. Yes. locally on the computer is is advertised as 22, but beyond the gateway/router it is advertised as 41515.
>>
>>54651679
Remember, beyond the gateway all the computers share the same IP.
>>
>>54651696
>>54651679
thanks that makes a lot of sense. I'm doing CCNA lol
>>
>>54649434
more elegant example:

- Computer sends packet: 192.168.1.5:22
- Router sees packet: 192.168.1.5:22
- Router assigns it a new port so that it knows the traffic is meant for 192.168.1.5:22
- New port 51512 has been chosen
- Beyond the router, this connection is now looked upon as public IP and new port (552.414.131.222:51512)
- Router forwards packet to destination
- Destination responds by sending packet back to 552.414.131.222:51512
- Router looks at packet, sees that the destination is 552.414.131.222:51512
- Router checks database and sees that port 51512 means that the traffick is meant for 192.168.1.5:22
- Sends packet to 192.168.1.5:22

Hope that is easier to understand.

God bless I'm going out and getting smashed tonight. Just finished finals wooo. God bless I appreciate everyone of you, you are all special, proud of you all.
>>
>>54651679
>If every machine used port 22, then how would the router know which machine the packets were meant for?

Through frame data. Specifically the MAC address. Packets are encapsulated in frames.
>>
>>54647378
Port is an application ID.
IP is a computer ID.

A single computer (server) can have multiple application (service) running thus needing listening port number. (eg: http on 80, SMTP on 25, etc)

A single computer (client) can also make connection to multiple computer (server) or application (service). Each of this connection will require unique port number on client side to maintain unique connection.

A computer can also map application ID running on another computer.This is know as a port forwarding on server side and masquerade (gateway) on client side.
Thread replies: 16
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.