2012年11月28日星期三

3310 Computer Network(4)



The main task for this week is a project in which we need to write a short program to implement the function of transmission between two entities, (ie. Two computers with different IP address named Robot and Student respectively) using two different transmission layer protocols – TCP and UDP. What’s more, for the bonus, we need to extend the program to implement the function that measures the different throughput for different receiver buffer size. The foal of the task is to help us get familiar with the usage of socket programming as well as some important properties of sending and receiving data such as buffer size and how port works as well.
To design the program, the most important part is to understand how the connection procedure and properties should be in either TCP or UDP protocols. In the past lecture, we should have known that the procedures for these two transmission modes should be like:




   
Figure 1 : functions flow of connection-oriented socket and connectionless Socket

     Implementing the functions shown above and we can accomplish our basic goal. Besides, there also have some detailed staff that we should take care of.
First of all, when considering the structure object sockaddr_in, it is describing and identifying the socket address family of either the server or the client such as IP address and port number for the socket.
For example, the definition of the family address in the program for the robot is like:

Figure 2 , address family of robot in the program

Secondly, for TCP socket, it is a stream socket which does not preserve message boundary, so in order to avoid the situation that the buffer load the information before all the data is correctly received, a loop is needed for receiving data in TCP protocol. It is the same for the sending procedure. Take the codes of receiving as an example, it is like :
                 Figure 3 The loop for TCP socket receiving
                
     Thirdly, in the bonus part, we need to let the robot continuing sending packets to the destination, lasting for 30 seconds. To solve this problem, a time function is needed, clock_t determines a variable corresponding to a certain time, in the mean time function clock() will return the current time from the computer. By using these two properties and a loop, the continuous sending procedure can be done. In the program, it is like:
   
         Figure 4 Codes fort he big packets transmission part


Through the programming project, though it is a hard and tiring work, my understanding of this course has been deeply developed. Although it is just a tiny little part of computer network, it stands for what is the work procedure like for the engineer to develop and implement those theories we are talking in the class. To discuss a method, or a tactic a easy, but to implement it is a not a easy work, which would always requires for deeply understanding and cautious habits.


TOPIC :Introduciton of Two Functions
In the project, one requirement is to find out the initial receiving buffer size and in addition to modify its value to see how the buffer size would effect the throughput. To accomplish this task, we need two functions which are included in the "winsock2.h" .They are getsockopt() and setsockopt() respectively.
For the function getsockopt(), it’s used to get the information in the socket bind by the user. It’s structure is as the figure shown below:
where:
sockfd : is the description the socket, it should be pointed to the socket
 you are willing to execute.

level :  is determine for the options of the socket, there exit
two levels that are SOL_SOCKET and IPPROTO_TCP.
   optname: the option that the user need to get from the socket
   optval : a pointer that points to the buffer location of the option value.
   optlen : a pointer that points to the length of the buffer area

For the function setsockopt(), it’s used to set the value in the socket bind by the user. It’s structure is as the figure shown below:
where:
sockfd : is the description the socket, it should be pointed to the socket
 you are willing to execute.
level :  is determine for the options of the socket, there exits four levels
which are SOL_SOCKET, IPPROTO_TCP, IPPROTO_IP and IPPROTO_IPV6
 optname: the option that the user need to get from the socket
 optval : a pointer that points to the buffer location of the option value.
 optlen : a pointer that points to the length of the buffer area
    By using these two functions, we can get the information that the default receive buffer size is 8192 bytes. Once the user increase or decrease the buffer size, it can be seen that the throughput of the packets would increase and decrease in pace with the buffer size.

2012年11月8日星期四

3310 Computer Network(3)


3310 Computer Network(3)


    The main topic the course recently talking about is the peer-to-peer protocols, which contains Service Models and ARQ.A Service Model in a given layer specifies the manner in which information is transferred. There are two broad categories of service models: connection oriented and connectionless. In connection-oriented services a connection setup procedure precedes the transfer of information while connectionless do not involve a connection setup procedure.

Figure-1 Connection-oriented transfer service

Figure-2 Connectionless transfer service
    ARQ protocols includes Stop-and-Wait ARQ, Go-Back-N ARQ and Selective Repeat ARQ. The finite state machine (FSM) diagram of the above three ARQ protocols are as following:


Figure-3 Sender and Receiver Algorithms of Stop-and-Wait ARQ


              
               Figure-4 Sender and Receiver Algorithms of Go-Back-N ARQ


Figure-5 Sender and Receiver Algorithms of Selective-Repeat ARQ

    Also, we begin to learn some kinds of procedures and methods to measure the delay time, throughput and efficiency of the network transmission. For all these methods, we have certain assumptions respectively.
    In this section, I come to realize the details about how some of the network protocols work and how people gradually develop them. As we consider peer-to-peer protocols and the services the provide, they are trying to set up the interaction of two or more processes or entities through the exchange of PDUs. In order to accomplish this goal and also considering the cost and so on, different ideas show up and gradually improve the efficiency of network communication. This is also the way for us to research for developing faster, more reliable and efficiency achievements in the future. It is also the fundamental job for an engineer.






TOPIC : Comparison Between ARQ Protocols

Stop-and-Wait ARQ : works well on channels that have low propagation delay. However, the protocol becomes inefficient when the propagation delay is much greater than the time to transmit a frame.


Go-Back-N ARQ : Go-Back-N ARQ is efficient than Stop-and-Wait when the channels are long and as well the error rate is low.



Selective Repeat ARQ: It is the most efficient of the ARQ protocols as it uses the minimum number of retransmissions. However, if the window size is too small, then the transmitter may run out of sequence numbers from time to time and the efficiency will then reduced.

The relationship between transmission efficiency of ARQ Protocols among these ARQs are shown below :



                    
                     Figure-6 Transmission efficiency of ARQ Protocols

                    (where p is the frame error rate )






What’s else, the relationship between the frame size and the efficiency is like:





           Figure-7  Transmission efficiency of ARQ Protocols(frame size)

        -- Where p equals to 1.E-04.





2012年10月18日星期四

3310 – ComputerNetwork(2)

    After about four weeks’study on the course 3310, I, together with the professor, has gone through several important parts about socket programming. In addition, for socket programming, we have discussed not only the architecture but also the usage about many kinds of functions used for setting up communication between two peers, such as socket(), bind(), listen() and so on. Professor liew is introducing service Models and ARQ, which is for the peer-to-peer protocol communication, to us in the recent lectures, which contains detailed information about adaptation functions and two kinds of ARQ—Stop and Wait ARQ and Go-Back-N ARQ, for which we are discussing about both the advantages and disadvantages as well as how to make choice of these two types.

Figure 1 – Architecture ofSetting Connection-oriented Socket

Figure 2 – Model forStop-and-Wait ARQ
     After a period time ofstudying, I gradually build up the framework ofhow people can set up communication between two different places, which may befar far away from one to the other. What I am doing now is to fill theframework with detailed information and knowledge. For example, by learning, Iget to know the detailed method and process for computers to set up specificports and sockets between clients and servers. What I also learned is how toprevent conditions like transmission error and time-out by the method of ARQ.

    Besides the knowledgegained in the lectures, I also find that the course is no longerthat much mysterious to me. In other words, I become to realize the mainpurpose of this technology as well as begin to consider practical problems fromthe specific points of view of the technology.

    To learn the coursewell, in the past four weeks, I take the advice about insistingreading lecture notes as well as textbook for more than one hour per day fromprofessor liew. While reading the notes and the textbook, my goal is tounderstand how it is working and why people would design it like that, inaddition, I would try to think about my own ideas, which may look stupid ifcompared with the methods introduced in the lecture.

Topic:Comparison Between Two Functions – write() andsendto() 

    For socket programming, there are two kinds of functions that are for the same goal – senddata from one terminal to the other when communicating, they are write() andsendto(). The fundamental purpose of defining two different functions isbecause of the different usage for connection-oriented socket andconnectionless socket. Therefore, the architecture of these two kinds of socketis somehow different, which is shown as below:
Figure 3 – ComparisonBetween Two Functions in Corresponding Architecture
    Also, the two functionshave different prototypes, which are :
      int write ( int sd, char *buf, intbuflen ) ;
      int sendto ( int sd, char *buf,int buflen, int flags, stuct sockaddr *addrp, int addrlen) ;                                      
                                 --Communication Networks (Alberto Leon-Garcia)

    From the above two lines,we can see that thetwo functions have three consistent components :
           sd is the socket descriptor,
           buf is a pointer to a buffercontaining the data to traansmitted ,
           buflen is the length of the data inbytes .                                       and also the sendto() function have three extra components :
           flags can be used to controltransmission behavior such as handling out-of-band data
           addrp is a pointer to the sockaddrstructure containing the address information of the remote hosts
           addrlen is the lengeh of theaddress information

    From my point of view, through the differences above we can easily see why sendto() is especially for connectionless, each time when sendto() is called, it will send datas with both source and destination addresses, which is no need for connection-oriented. And thus we can draw a conclusion that the essential difference between these two function is that one is for connectionless and the other is for connection-oriented.
 
    In the further study, I would like to have the chance to have actual practice by using these socket functions, which will absolutely improve my acknowledge of the process of sending data by using different protocols.


2012年9月25日星期二

3310 -- Computer Networks


   To be frank, before attending the course Computer Networks in this term, though I have been as one of the beneficiaries of the Internet since even seven or eight, I know little about how actually the whole huge and exquisite world of Internet works. Maybe the only concept that I am well aware is that the information asked by clients served in the form of some kinds of signals through some certain pipes. I even do not know what a protocol is, not to mention the concepts of TCP/UDP, IP, CSMA/CD or the seven layer architecture and so on. I feel like that I am stepping one of my foot into a new field.

   For a beginner, a detailed reference textbook as well as wiki are both indispensable.


Figure 1-Wikipedia

Figure 2-Textbook

   The first task is to establish the basis of this course, which means that I need to go through all the basic concepts. For example, from both the textbook and the wiki, we can know that :

   TCP stands for transmission control protocol – a kind of transport protocol and it is on the transmission layer in the OSI architecture.

 

Figure 3-Basic Concepts Collection

   Fortunately, my roommate is a senior in IE department and I will of course put all of my questions to him. In face, we have just discussed about the question that why TCP is connection-oriented while IP is connectionless a few minutes ago.

   After collecting all these concepts, I am now ready to explore the operation mode of the network.

    The course is on every Tuesday and Thursday. After each class, I would overview the whole PPT of the lecture to make sure that I clearly get the information and knowledge from the professor. To make the review effectively, I print all of the course contents and take notes on the paper  to set up a clear structure about what I have learnt.

Figure 4-The Lecture and the Notes

TopicThe OSI Reference Model

Figure 5- OSI Seven-Layer Model


The origin of the model:

http://zh.wikipedia.org/wiki/OSI%E6%A8%A1%E5%9E%8B
                                                         – The introduction of wikipedia

   The early architectures developed by various computer vendors were not compatible with each other, which hindered the communication between different users with different network architecture. Therefore, the unified model --OSI (Open System Interconnection Reference Model) come along.

The Architecture of the Seven Layer Model

OSI partitioned the communication process into seven layers which are :


1.  application layer
        -- provide services that involve communication
2.  presentation layer
        -- provide the application layer with the representation of data
3.  Session layer
        -- control the manner that data are exchanged
4.  Transport layer
        -- be responsible for the end-to-end transfer.
5.  Network layer
        -- provide for the transfer of data in the form of packet
6.  Data link layer
        -- provides for the transfer of frames, which are the block of information
7.  Physical layer
        -- deal with the transfer of bits over a communication channel

   From my point of view, as a beginner, I cannot imagine a better model to describe the whole work of communication since it has taken almost every part into consideration such as flow controlling and data capsulation as well as error detection in each layer.

   However, in practical application, the TCP/IP model which has only four layer, is used much more frequently. I think the reason should be that in most instances, neither the presentation nor the session layer would be useless. What’s more, maybe executing flow controlling ,data capsulation as well as error detection in each layer would be expensive, and as we know, there is always trading between cost and theoretical efficiency.

    In the further study, I want to know more about the tasks for each layer and how do they finish these tasks. What’s more, I would explore the cooperation of the whole architecture to see clearly that how the whole communication network would be done.