Multiplexing/demultiplexing multiplexing at sender: demultiplexing at receiver: handle data from multiple use header info to deliver sockets,add transport header received segments to correct (later used for demultiplexing) socket application application P1 P2 application ■socket (P3 P4 process transport transport network a phy ical physical Transport Layer:3-16
Multiplexing/demultiplexing process socket use header info to deliver received segments to correct socket demultiplexing at receiver: transport application physical link network P1 P2 transport application physical link network P4 transport application physical link network P3 handle data from multiple sockets, add transport header (later used for demultiplexing) multiplexing at sender: Transport Layer: 3-16
How demultiplexing works host receives IP datagrams 32 bits each datagram has source IP source port# dest port address,destination IP address each datagram carries one other header fields transport-layer segment each segment has source, destination port number application data host uses IP addresses port (payload) numbers to direct segment to appropriate socket TCP/UDP segment format Transport Layer:3-17
How demultiplexing works ▪ host receives IP datagrams • each datagram has source IP address, destination IP address • each datagram carries one transport-layer segment • each segment has source, destination port number ▪ host uses IP addresses & port numbers to direct segment to appropriate socket source port # dest port # 32 bits application data (payload) other header fields TCP/UDP segment format Transport Layer: 3-17
Connectionless demultiplexing Recall: when receiving host receives when creating socket,must UDP segment: specify host-local port # checks destination port in segment DatagramSocket mySoeketl directs UDP segment to new Datagramsock et(12534); socket with that port when creating datagram to send into UDP socket,must specify IP/UDP datagrams with same dest. port but different source IP destination IP address addresses and/or source port 。destination port# numbers will be directed to same socket at receiving host Transport Layer:3-18
Connectionless demultiplexing Recall: ▪ when creating socket, must specify host-local port #: DatagramSocket mySocket1 = new DatagramSocket(12534); when receiving host receives UDP segment: • checks destination port # in segment • directs UDP segment to socket with that port # ▪ when creating datagram to send into UDP socket, must specify • destination IP address • destination port # IP/UDP datagrams with same dest. port #, but different source IP addresses and/or source port numbers will be directed to same socket at receiving host Transport Layer: 3-18
Connectionless demultiplexing:an example DatagramSocket serverSocket new DatagramSocket DatagramSocket mySocket2 new DatagramSocket (6428); DatagramSocket mySocket1 new DatagramSocket (5775); (9157): application application P1 application P3 P4 中证 transport nerwork transp network tink physical physical physical source port:6428 source port: dest port:9157 dest port: source port:9157 source port: dest port:6428 dest port: Transport Layer:3-19
Connectionless demultiplexing: an example DatagramSocket serverSocket = new DatagramSocket (6428); transport application physical link network P3 transport application physical link network P1 transport application physical link network P4 DatagramSocket mySocket1 = new DatagramSocket (5775); DatagramSocket mySocket2 = new DatagramSocket (9157); source port: 9157 dest port: 6428 source port: 6428 dest port: 9157 source port: ? dest port: ? source port: ? dest port: ? Transport Layer: 3-19
Connection-oriented demultiplexing TCP socket identified by server may support many 4-tuple: simultaneous TCP sockets: ·source IP address each socket identified by its ·source port number own 4-tuple ·dest IP address each socket associated with ·dest port number a different connecting client demux:receiver uses all four values (4-tuple)to direct segment to appropriate socket Transport Layer:3-20
Connection-oriented demultiplexing ▪ TCP socket identified by 4-tuple: • source IP address • source port number • dest IP address • dest port number ▪ server may support many simultaneous TCP sockets: • each socket identified by its own 4-tuple • each socket associated with a different connecting client ▪ demux: receiver uses all four values (4-tuple) to direct segment to appropriate socket Transport Layer: 3-20