Network Programming Overview

Source: Internet
Author: User

1. Overview
By means of a communication line (wired or wireless), a computer network can be formed by connecting computers of different geographical locations to each other with their external devices. Under the management and coordination of operating system, network management software and network communication protocol, the resource sharing and information transmission between computers can be realized.
Network programming means that the data can be exchanged between programs running on different computers that are used to realize network interconnection. For us, how to use the programming language Java to realize the communication between different computers in the computer network.
2. Three elements of network communication
IP Address
The unique identification of the computer in the network;
32bit (4 bytes), generally denoted by "dotted decimal", such as 192.168.1.158;
IP address = Network address + host address can be categorized:
Class A: The 1th 8-bit represents a network address. The remaining 3 8 bits represent the host address
Class B: The first 2 8 bits represent the network address. The remaining 2 8 bits represent the host address
Class C: The first 3 8 bits represent the network address. The remaining 8-bit indicates that the host address Class D address is used for multicast in the IP network
Class E addresses are reserved for research purposes.
The InetAddress class can be used in Java programming to manipulate IP addresses.

public static void main(String[] args) throws UnknownHostException {        InetAddress localHost = InetAddress.getLocalHost();         System.out.println(localHost.getHostAddress());         System.out.println(localHost.getHostName());     }

Port number
Identifies the logical address of the process and the identity of the different processes;
Valid ports: 0-65535, where 0-1024 systems use or retain ports.
Transport protocol
Rules of Communication
Common protocols: UDP (User Datagram Protocol), TCP (Control Protocol)

3. Network model
What rules are communicated between computer networks is the problem of network model.

The network model generally refers to the OSI seven-layer reference model and the TCP/IP five-layer reference model.

Each layer implements its own capabilities and protocols, and it provides business functionality to the previous tier. To provide this business function, the next layer merges the data from the previous layer into the data domain of this layer, and then implements the business function of the layer by adding a header or a trailer, which is called data encapsulation. The user's data is to be wrapped over and over again, and finally transformed into a signal that can be transmitted over the network and sent to the network. When the destination computer is reached, the reverse data unpacking process is performed.

Physical Layer:
The main definition of physical equipment standards, such as the interface type of network cable, the interface type of optical fiber, the transmission rate of various transmission media.
The main function is to encode the data into a bit stream identified by 0 and 1, which is transmitted through physical media. This layer of data is called a bit.
Data Link Layer:
The data received is mainly packaged and unpacked with the MAC address (NIC address). This layer of data is often called a frame. This layer of equipment that works often is a switch.
Network layer:
The data received is mainly encapsulated and unpacked with IP address.
This layer of data is often called a packet. This layer of equipment is a router. Transport Layer:
Defines the protocols and port numbers for data transfer.
The data received will be segmented and transmitted, and then reorganized after reaching the destination address. This layer of data is often called a segment.
Session Layer:
The path of data transmission is established through the transport layer.
Primarily initiates a session between systems or receives a session request. Presentation layer:
The main data interpretation, encryption and decryption, compression and decompression.
Ensure that the data sent by the application layer of one system can be identified by the application layer of the other system. Application layer:
Mainly for some terminal applications to provide services. Directly facing the user.

Network Programming Overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.