본문 바로가기

정규 강의/컴퓨터 네트워킹

Transport layer & Socket

Multiplexing and Demultiplexing

 

 

  • Multiplexing at sender: sending data from its own multiple applications through network
  • Demultiplexing at receiver: delivering data packets to their appropriate receivers among its own multiple applications
  • Theses are provided by the transport layer.

Port number

 

  • different applications are assigned different port numbers
  • transport layer segments have fields for source port and destination port numbers. so that each data goes to its destination.
  • However, the transport layer must be instructed by the application which process on which host should be the destination.
  • the mechanism of instructing transport layer is by socket

 

Socket

 

  • is provided as the form of APIs by OS
  • It is tiring for a programmer to develop all the network system on which her software sends and receives data.
  • So normally OS provides APIs between transport layer and application layer.
  • API stands for Application Program Interface which is function with which application can call to send data
  • you can provide data and url in this API function.
  • The set of these API functions is socket.
  • Example of Simple Socket program
    •  
    • [server]
      • 1) import socket
      • 2) ss.socket: create a server socket
      • 3) ss.bind: assign IP Address and port number to the socket
      • 4) ss.accept: accept connection request from client
      • 5) ss.recv: receive data
    • [client]
      • 1) cs.socket: establish the connection/ create a client socket 
      • 2) cs.connect: request connection to ‘localhost’ of which port number is 8089
      • 3) cs.send: send data 

 

출처: k-mooc 컴퓨터 네트워킹, 부산대학교 유영환