The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
0 votes

When a TCP segment arrives at a host, in order to direct it to the appropriate socket, the operating system's network stack uses which of the following?

(a)Transport protocol number

(b)Destination IP Address

(c)Source port number

(d)Destination port number

(e)Destination MAC Address

Answer is given to be a,b,c,d.

I understand why a,b and d are needed. Why source port number is needed?

Document Ref:

asked in Computer Networks by Boss (25.3k points) | 98 views

In order to identify connection uniquely , port number is not sufficient , Two host chossen the same host

or IP address is also not sufficient because there is a chance that the  two host have same IP addresses  

, they can choose any port number inside the computer , it might so happen that , the number which they have choose is also 'X'

So we are not going to use Only prt number , Or only  IP address to identify the connection uniquely

therefore we combine both (IP + Port = Socket)




two IP choosen by the same host within a same network will be same

It will be Two port.

I want to say that

How to identify the the connection uniquely

two host can choose the same port number

or two host can have same IP address

therefore we can combine both (IP address + post = socket)
How this is possible two hosts with the same IP??

As I know IP address is globally unique??
two host can have same port number that's why we use IP + port number to uniquely indetify???

How this is possible two hosts with the same IP??

 How said ??

read it !


if you see in your image You have given same port (x) But different IP address IA and IB.

I'm just trying to explain the concept  with the help of diagram

that's Y I write down below the whole summary can't visualize everything with this   diagram :p
According to you Ip address and port may be same. Then

How we will uniquely identify any network ???Then What's use of Socket ???
@Magma-Can we say that since TCP handles each client concurrently and has a incoming queue for each client to which it is connected, source port number is useful to identify to which service of source should the TCP server respond right?

yeah correct Ayush Upadhyaya



probability of occuring (same port no + same IP address ) of the two host at the same instant of time 

is very very very very very low :3

It is already told that TCP arrives in a host and now it is finding appropriate socket

So, it has no need to find destination IP again

@srestha-But to direct it to correct socket, you need destination Ip because socket=IP+Port

check this

If the URGENT flag is set, segments sent to the destination TCP will have the urgent pointer set. The receiving TCP will signal the urgent condition to the receiving process if the urgent pointer indicates that data preceding the urgent pointer has not been consumed by the receiving process. The purpose of urgent is to stimulate the receiver to process the urgent data and to indicate to the receiver when all the currently known urgent data has been received. The number of times the sending user's TCP signals urgent will not necessarily be equal to the number of times the receiving user will be notified of the presence of urgent data. If no foreign socket was specified in the OPEN, but the connection is established (e.g., because a LISTENing connection has become specific due to a foreign segment arriving for the local socket), then the designated buffer is sent to the implied foreign socket. Users who make use of OPEN with an unspecified foreign socket can make use of SEND without ever explicitly knowing the foreign socket address. However, if a SEND is attempted before the foreign socket becomes specified, an error will be returned. Users can use the STATUS call to determine the status of the connection. In some implementations the TCP may notify the user when an unspecified socket is bound.

chk pg 46 


Socket only need connections, not addresses



@srestha-TCP supports concurrent connections. In case multiple connections are open from a single server, source IP is needed to identify which source is being served by which child process so that the incoming segment goes into the respective queue of the server.

Please log in or register to answer this question.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,122 questions
53,241 answers
70,480 users