Network programming is defined

Network Programming
1. Point Network protocol theoretical knowledge
learning network programming purposes?

What is the Internet
network: a plurality of nodes interconnected by a spider web of fishing nets composed
calculated the Internet: some media connected to each other and consist of multiple computers over
the Internet exists is to allow information sharing

Network Programming: refers to the writing of web-based applications
the purpose of learning network programming
to develop applications that can take advantage of a network to transmit data

CS structure
networking requires at least two computers, and then use the network to transmit data
1. Unicom network must
2. need to access data in one of the application must be installed for the access data
to the application program called a client application (client)

In one must be installed to provide data required for application sharing data of
the application is called the application server (server)
, abbreviated as C / S
for example: qq is a client server Tencent
Tencent video

B / S Browser Browser / Server HTML text data are transmitted by this configuration

The ultimate goal of learning network programming is to write applications based on C / S structure


Corresponding to two conditions must have
1. a physical transmission medium (twisted pair fiber coaxial radio waves)
2. Communication Protocol (Key)


Communication protocol
is mutually agreed by the sender and the receiver set of norms

Why do we need agreement
which aims to correct the two sides can resolve data
such as internal communication: the two sides are in Mandarin with
international communication: English


IBM DELL HP early years, each company has its own set of protocols which leads to different brands of computers connected to the network can not
then ISO proposed a set of open system interconnection OSI model

The physical layer physical connection is established through physical media can send 1010101 binary data but can not understand the simple binary
must clear several disposable income, what is the meaning of each piece of binary

Data link layer
Ethernet protocol works at the data link layer
1. how packet data (format data)
every time a data frame is transmitted
for each data frame comprising a head and a Data
head18 46-1500 Data
head 802 comprises the source address in the tag ether type data

1518 will be more than the largest slice
2.MAC address of each computer you want to be networked with each NIC NIC necessarily have a globally unique MAC address
MAC can navigate to any computer, but if I do not know in advance your card it would need to be broadcast
to determine the corresponding relationship between the MAC address and the network port

 

Each LAN is the network address of a final ip ip is a broadcast address
such as: 192.168.13 0 - 255 range is therefore available: 1-254
router is also a switch


With computer link-layer theory, the world will be able to connect to the same network
but we can not all computer equipment connected to the same switch
broadcast storm: While many computers on the same network at the same time send broadcast will broadcast storm the only network paralysis


Question 1: There is no switch can support so many computer
Question 2: You can not use the original broadcast

Network layer
ip protocols work on the network Protocol Address Internet
ip protocol requires each device to a computer network must be assigned an Ip
address
ip is a logical address is not fixed may change
the physical presence of the opposite logic exist

ip address format of
the three segments 4 decimal
0.0.0.0 - 255.255.255.255
]

the concept of ip address to the network address in the mac address based on the network address can then have a narrow range of broadcast
so in the first three paragraphs ip address LAN network number is used to indicate where
after a while the host number is used to represent the host LAN location

Network layer
ip address into a network number and host number
can be positioned to a LAN via a network number
and then through a number of positioning a host computer
so that it can be a global positioning any computer ip

Problem: A computer can not only run a networked program requires that when the card receives the data, the data in the end to which application

The transport layer
TCP / UDP work in this layer
the transport layer requires that each application bundle a port number
port number is an integer in the range 0-655360-1024 system which is not recommended reserved
port number can not repeat
this point can be through one application on ip + port number for a global positioning computer

TCP Transmission Control Protocol
reliable transport protocol, how to guarantee reliable, after the completion of data occurs, we must wait for the recipient to return a reply message, send the data considered successful
if the other party does not return for some time, it will send the data again, limit the number of super, the missing link is determined that the
transmission links based on
how the link is called
to happen data must first establish a link simply means that to find a way to reach each other,
how to select an optimal transmission path, is controlled by the routing protocol
to ensure that data transfer chamber it must ensure reliable transmission path is available
to establish the link required three-way handshake:
three-way handshake is to determine the transmission is available
but does not guarantee reliable transmission so subsequent TCP protocol for transmitting data for each data segment segment requires confirmation
broken links need four waving
sure both sides data transfer is completed, why more than once, there may be some transmission end of the other side is not over yet

Pros:
to ensure reliable transmission, data integrity
drawback:
because of the need to confirm the transmission of information, so the network consume larger, relatively low efficiency
scenarios:
important data, online payment, text messages


User Datagram Protocol UDP protocol
is not reliable transmission of
UDP just sends no matter if it was received

Advantages: high transmission efficiency than TCP
Disadvantages: Unreliable transport
scenarios:
high speed requirements, integrity requirements for lower
video calls, voice chat
war game mostly UDP you card you normally play cards right people

 

UDP User Datagram Protocol

The basic elements of communication
OSI model

2.TCP stick package problem
3.UDP DNS

Concurrent programming
Origin 4. The multi-channel multi-process technology
5. locks, IPC, producer-consumer model

Guess you like

Origin www.cnblogs.com/huanghongzheng/p/11006437.html
Recommended