# Patent

## Title
Command processing apparatus

## Abstract

A command processing apparatus includes a CPU (28). The CPU (28) determines whether or not a router (16) is compliant with UPnP, and issues a port releasing request to the router (16) when the determination result is affirmative. Thus, a specific port is released. Next, destination information including an identifier of the specific port is requested to be sent to a server (14). The destination information is sent to the server (14) by the router (16), and the server (14) sends a command to the specific port on the basis of the identifier included in the destination information. When the determination result is negative, an information send request is repeatedly issued. Every issuance, destination information including an identifier of an arbitrary port (response wait port) is sent to the server (14) by the router (16), and the response wait port is temporarily released. The server (14) outputs a command to the response wait port on the basis of the identifier included in the destination information.

## Background
TECHNICAL FIELD
The present invention relates to a command processing apparatus. More specifically, the present invention relates to a command processing apparatus which executes processing according to a command sent from an external server through a router.
PRIOR ART
Conventionally, following two apparatuses are known as a command processing apparatus of such a kind. The first related art issues to a router a port releasing request for requesting to release a specific port, and issues a send request for requesting to send destination information including an identifier of the specific port to the external server. Then, the specific port is continuously released by the router, and the destination information is sent to the external server. From the external server, a command is sent to the specific port on the basis of the identifier included in the destination information at arbitrary timing.
The second related art issues to the router a information send request for requesting to send destination information including an identifier of an arbitrary port (hereafter, called “response wait port”) to the external server. Then, the destination information is sent to the external server by the router, and the response wait port is temporarily released. A command is sent from the external server to the response wait port on the basis of the identifier included in the destination information.
A conventional router is disclosed in the “all about broadband router AI mukku” [issued on Jun. 11, 2002 by AI Publisher]
However, in the first related art, if the router is not a type compliant with a system of continuously releasing the specific port in response to a port releasing request, it is impossible to receive a command from the external server. On the other hand, in the second related art, only when the response wait port is released, it is impossible to accept a command from the external server.
SUMMARY OF THE INVENTION
Therefore, it is a primary object of the present invention to provide a novel command processing apparatus.
Another object of the present invention is to provide a command processing apparatus capable of accepting a command from an external server at arbitrary timing regardless of a system adopted by a router.
A command processing apparatus according to claim 1 is a command processing apparatus which executes a process according to a command sent from an external server through a router, out of a first system continuously releasing a specific port in response to a port releasing request and a second system performing an information sending in response to an information send request and temporarily releasing an arbitrary port, being compliant with at least the second system, comprises: a determining means for determining whether or not the router is compliant with the first system; a first issuing means for issuing the port releasing request to the router when the determination result by the determining means is affirmative; a send requesting means for requesting the router to send destination information including an identifier of the specific port released in response to the port releasing request to the external server; and a second issuing means for repeatedly issuing the information send request to the router when the determination result by the determining means is negative. The information send request issued by the second issuing means is a send request of the destination information including the identifier of the arbitrary port to the external server.
Out of a first system continuously releasing a specific port in response to a port releasing request and a second system performing an information sending in response to an information send request and temporarily releasing an arbitrary port, a router adopts at least the second system. A command is sent from an external server through the router.
A determining means determines whether or not the router is compliant with the first system. When the determination result by the determining means is affirmative, a first issuing means issues a port releasing request to the router. Thus, a specific port is released. A send requesting means requests the router to send destination information including an identifier of the released specific port to the external server. The destination information is sent to the external server by the router. The external server sends a command to the specific port on the basis of the identifier included in the destination information.
When the determination result by the determining means is negative, a second issuing means repeatedly issues information send request to the router. The issued information send request is a send request of the destination information including the identifier of the arbitrary port to the external server. The router sends destination information to the external server, and temporarily releases the arbitrary port every time that the information send request is issued. The external server outputs a command to the arbitrary port on the basis of the identifier included in the destination information.
A command processing apparatus according to claim 2 is dependent on claim 1, and the first system is a system compliant with a UPnP (Universal Plug & Play) protocol, and the determining means includes a protocol determining means for determining whether or not the router is compliant with the UPnP protocol, and the second issuing means performs issuing processing when the determination result by the protocol determining means is negative.
The first system is compliant with a UPnP protocol. The protocol determining means determines whether or not the router is compliant with the UPnP protocol. The issuing processing of the second issuing means is performed when the determination result by the protocol determining means is negative.
When the router is not compliant with the UPnP protocol, an information send request is repeatedly issued to the router, and consequently, the arbitrary port is in a continuously released state.
A command processing apparatus according to claim 3 is dependent on claim 2, and the protocol determining means performs determination processing by utilizing a discovery function adopted by the UPnP protocol.
A command processing apparatus according to claim 4 is dependent on claim 2, and the determining means further includes a trying means for trying to acquire a global IP address when the determination result by the protocol determining means is affirmative, and a success determining means for determining whether or not the try by the trying means is successful, and the second issuing means performs issuing processing when the determination result by the success determining means is negative.
A trying means tries to acquire a global IP address when the determination result by the protocol determining means is affirmative. A success determining means determines whether or not the try by the trying means is successful. The issuing processing of the second issuing means is performed when the determination result by the success determining means is negative.
Even if the router is compliant with the UPnP protocol, if a global IP address is not acquired from the router, an information send request is repeatedly issued to the router, and consequently, the arbitrary port is in a continuously released state.
A command processing apparatus according to claim 5 is dependent on claim 1, further comprises: a third issuing means for issuing to the router a send request to request to send an ask signal for asking a repetitive response to the external server; a receiving means for receiving a response signal from the external server through the arbitrary port in response to the send request issued by the third issuing means; and a deciding means for deciding an issuance cycle of the second issuing means on the basis of the reception result by the receiving means.
A third issuing means issues to the router a send request to request to send an ask signal for asking a repetitive response to the external server. When such a send request is issued, an ask signal for asking a repetitive response is sent to the external server by the router, and an arbitrary port is temporarily released. From the external server, a response signal is repeatedly sent back. The sent-back response signal is received by a receiving means through the released arbitrary port.
The arbitrary port released when the third issuing means issues the send request is closed after a lapse of a constant time period. When the arbitrary port is closed, the receiving means does not receive a response signal thereafter, and therefore, it is possible to know a period during which the router releases the arbitrary port (port releasing period) when a send request is issued on the basis of the receiving result by the receiving means, capable of, in turn, determining an optimal issuance cycle of the second issuing means.
A deciding means decides an issuance cycle of the second issuing means on the basis of the receiving result by such a receiving means. If the second issuing means issues a send request at a cycle thus determined, the longest cycle within the port releasing period, that is, a cycle equal to or slightly shorter than the port releasing period, it is possible to make a state in which the arbitrary port is continuously released, while minimizing a load on the communications line.
A command processing apparatus according to claim 6 is dependent on claim 1, and further comprises: a third issuing means for repeatedly issuing to the router a send request to request to send an ask signal for asking a response at timings different from each other to the external server; a receiving means for receiving a response signal from the external server through the arbitrary port in response to the send request issued by the third issuing means; and a deciding means for deciding an issuance cycle of the second issuing means on the basis of the reception result by the receiving means.
A third issuing means repeatedly issues to the router a send request to request to send an ask signal for asking a response at timings different from each other to the external server. Every time that the third issuing means issues a send request, a an ask signal for asking a response at timings different from each other is sent to the external server by the router, and the arbitrary port is temporarily released. Every time that a send request is issued by the third issuing means, from the external server, a response signal is sent back at timing different from each other.
The arbitrary port released when the third issuing means issues the send request is closed after a lapse of a constant time period. Out of the response signals sent back at timings different from each other, a response signal sent back at timing later than the timing when the receive port is closed is not received by the receiving means. Thus, it is possible to know a period during which the router releases the arbitrary port (port releasing period) when a send request is issued on the basis of the receiving result by the receiving means, capable of, in turn, determining an optimal issuance cycle of the second issuing means.
A deciding means decides an issuance cycle of the second issuing means on the basis of the receiving result by such a receiving means. If the second issuing means issues a send request at a cycle thus determined, the longest cycle within the port releasing period, that is, a cycle equal to or slightly shorter than the port releasing period, it is possible to make a state in which the arbitrary port is continuously released, while minimizing a load on communications line.
A control program according to claim 7 is a control program to be executed by a processor of a command processing apparatus for executing a process according to a command sent from an external server through a router, out of a first system continuously releasing a specific port in response to a port releasing request and a second system performing an information sending in response to an information send request and temporarily releasing an arbitrary port, being compliant with at least the second system, comprises: a determining step for determining whether or not the router is compliant with the first system; a first issuing step for issuing the port releasing request to the router when the determination result by the determining step is affirmative; a send requesting step for requesting the router to send destination information including an identifier of the specific port released in response to the port releasing request to the external server; and a second issuing step for repeatedly issuing the information send request to the router when the determination result by the determining step is negative. The information send request issued by the second issuing step is a send request of destination information including an identifier of the arbitrary port to the external server.
According to the present invention, when the router adopts the first system, a specific port is continuously released by the router, and destination information including an identifier of the specific port is notified to the external server. When the router adopts the second system, an arbitrary port (response wait port) is continuously released by the router, and destination information including an identifier of the response wait port is notified to the external server, capable of accepting a command from the external server at arbitrary timing regardless of the system adopted by the router.
The above described objects and other objects, features, aspects and advantages of the present invention will become more apparent from the following detailed description of the present invention when taken in conjunction with the accompanying drawings.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a block diagram showing a configuration in accordance with one embodiment of the present invention;
FIG. 2(A) is a sequence diagram showing a part of a communication process performed in a case that a router is compliant with UPnP;
FIG. 2(B) is an illustrative view showing a configuration of a port notification packet utilized in a case that the router is compliant with UPnP,
FIG. 2(C) is a sequence diagram showing another part of the communication process performed in a case that the router is compliant with UPnP;
FIG. 3(A) is a sequence diagram showing a part of a communication process performed in a case that the router is not compliant with UPnP;
FIG. 3(B) is a sequence diagram showing another part of the communication process in a case that the router is not compliant with UPnP;
FIG. 3(C) is an illustrative view showing a configuration of a port notification packet utilized in a case that the router is not compliant with UPnP;
FIG. 4 is a flowchart showing a part of an operation of a client CPU;
FIG. 5 is a flowchart showing another part of the operation of the client CPU;
FIG. 6 is a flowchart showing the other part of the operation of the client CPU;
FIG. 7 is a flowchart showing a further part of the operation of the client CPU;
FIG. 8 is a flowchart showing another part of the operation of the client CPU;
FIG. 9 is a flowchart showing a part of an operation of a server CPU;
FIG. 10 is a flowchart showing another part of the operation of the server CPU;
FIG. 11 is a sequence diagram showing a part of a communication process performed in a case that a router is not compliant with UPnP in another embodiment;
FIG. 12 is a flowchart showing a part of an operation of the client CPU in FIG. 11 embodiment;
FIG. 13 is a flowchart showing a part of an operation of the server CPU in FIG. 11 embodiment;
FIG. 14 is a flowchart showing a part of an operation of the client CPU in the other embodiment;
FIG. 15 is a flowchart showing a part of an operation of the server CPU in FIG. 14 embodiment;
FIG. 16 is a sequence diagram showing a part of the communication process performed in a case that a router is not compliant with UPnP in a further embodiment;
FIG. 17 is a flowchart showing a part of an operation of the client CPU in FIG. 16 embodiment;
FIG. 18 is a sequence diagram showing a part of a communication process in a case that a router is not compliant with UPnP in another embodiment;
FIG. 19 is a flowchart showing a part of an operation of the client CPU in FIG. 18 embodiment;
FIG. 20 is a flowchart showing another part of the operation of the client CPU in FIG. 18 embodiment;
FIG. 21 is a sequence diagram a part of a communication process in a case that a router is not compliant with UPnP in the other embodiment;
FIG. 22 is a flowchart showing a part of an operation of the client CPU in FIG. 21 embodiment; and
FIG. 23 is a flowchart showing another part of the operation of the client CPU in FIG. 21 embodiment.



BEST MODE FOR PRACTICING THE INVENTION
Referring to FIG. 1, a surveillance camera system 10 in the present embodiment includes a Web camera 12. The Web camera 12 is connected to the Internet 20 over a router 16 and a DSL modem 18. The Internet 20 is connected with a server 14, and through the server 14, the Web camera 12 accepts an operation from a terminal, such as a cellular phone 22 connected to the Internet 20. The detailed operation includes an operation of adjusting a sensitivity, a zoom magnification, etc. through an imager 24 and a camera processing circuit 26, and controlling a direction of the Web camera 12 via a drive unit not shown.
It should be noted that the router 16 is connected with other home information appliances such as a PC as needed as well as the Web camera 12. The Web camera 12, other home information appliances such as the PC, etc. are thus connected via the router 16 to thereby constitute one LAN. The router 16 has an only one global IP address, and each of the appliances constituting a LAN is assigned a private IP address. Then, when an appliance on the side of the LAN is communicated with an appliance on the side of the Internet 20, address/port converting processing is executed for converting a private IP address and a source port number utilized on the side of the LAN and a global IP address and a response wait port number utilized on the side of the Internet are transformed between them.
As a router 16, two kinds of protocols, a UPnP (Universal Plug & Play) protocol-compliant type and a UPnP non-compliant type are used. The Web camera 12 selects a control system suitable for the router 16 connected thereto by cooperating with the server 14, and accepts an operation from a cellular phone 22 according to the selected control system. Additionally, whether or not the router 16 is the UPnP-compliant type can be determined by means of a discovery function adopted by the UPnP, such as the SSDP (Simple Service Discovery Protocol).
An initial setting including selection of a control system is specifically executed as follows. That is, when the power source is turned on, the Web camera 12 first sends an M-SEARCH packet based on the SSDP to the router 16 in order to determine whether or not the router 16 is the UPnP-compliant type. FIG. 2(A) shows a procedure of an initial setting in a case that the router 16 is the UPnP-compliant type, and FIG. 3(A) shows a procedure of an initial setting in a case that the router 16 is the UPnP-non-compliant type.
First, with reference to FIG. 2(A), in a case that the router 16 is the UPnP-compliant type, the router 16 sends back a 200 OK packet to the Web camera 12 in response to a M-SEARCH packet from the Web camera 12 (client). The Web camera 12 having receiving the 200 OK packet next requests a global IP address from the router 16. The router 16 notifies the Web camera 12 of the global IP address in response to the request from the Web camera 12.
The Web camera 12 thus having obtaining the global IP address then requests the router 16 to release a specific port. The router 16 releases the specific port in response to the request from the Web camera 12. Thereafter, all the packets directed to the specific port are transmitted to the Web camera 12 by the router 16.
Succeedingly, the Web camera 12 sends a port notification packet complying with the UDP (User Datagram Protocol) to the server 14. A configuration of the port notification packet sent to the router 16 by the Web camera 12 (client) when the router 16 is the UPnP-compliant type is shown in FIG. 2(B). With reference to FIG. 2(B), in the data area of the port notification packet, a port number of the specific port released by the router 16 is described. In addition, in the data area, an appliance ID for identification, etc. is described as necessary.
In the header area, a private IP address and a source port number are described like other packets. The private IP address and the source port number within the header area are converted into a global IP address and a response wait port number when passing through the router 16.
The server 14 receives the port notification packet from the Web camera 12, extracts the specific port number from the data area of the received port notification packet, and the global IP address from the header area of the same port notification packet. Then, a response packet is sent to the destination specified by the extracted address and the extracted port number, and the extracted address and the extracted port number are held in the RAM 36. The sent response packet is transmitted to the Web camera 12 by the router 16. The address and the port number held in the RAM 36 are referred when a command is sent to the Web camera 12 thereafter. It should be noted that the data in the RAM 36 such as an address, a port number, a command, and the like are backed up in the HDD 44 (and so forth).
Next, with reference to FIG. 3(A), in a case that the router 16 is the UPnP-non-compliant type, the router 16 does not respond even if an M-SEARCH packet is sent from the Web camera 12. The Web camera 12 does not receive a 200 OK packet even after the M-SEARCH packet is sent, and thus determines that the router 16 is the UPnP-non-compliant type to shift the process to a processing for evaluating an optimum send interval (T).
In the optimum send interval calculating processing, the client, that is, the Web camera 12 first sends a test start packet complying with the UDP to the server 14.
The transmitted test start packet is subjected to the address/port converting processing by the router 16, and the packet being subjected to the address/port converting processing is received by the server 14. At this time, in the router 16, a response wait port is released, and a source address, that is, the private IP address of the Web camera 12, and the port numbers before and after the conversion, that is, the source port number and the response wait port number are recorded in the table. The response wait port released in response to the test start packet is closed after a lapse of 15 seconds.
The server 14 sends a response packet to the client after a lapse of a predetermined time such as 2 seconds after receiving the test start packet. In the response packet, time information indicative of the elapsed time from reception of the test start packet, that is, “2 seconds” is described.
The response packet sent after 2 seconds is subjected to address/port converting processing on the basis of the above-described table in the router 16, and the packet on which the address/port converting processing is performed is received by the Web camera 12. The Web camera 12 extracts the time information of “2 seconds” from the received response packet, and records the extracted time information of “2 seconds” in the register “T”.
The server 14 further successively sends response packets to the client after an elapse of 4 seconds, 6 seconds . . . from the reception of the test start packet. In each of the response packet, the elapsed time period “4 seconds”, “6 seconds” . . . is described.
The response packets sent after 4 seconds, 6 seconds . . . are also subjected to address/port converting processing in the router 16, and the packets on which the converting processing is performed are received by the Web camera 12. The Web camera 12 extracts the time information “4 seconds”, “6 seconds” . . . from the received response packet, and records the extracted time information “4 seconds”, “6 seconds” . . . in the register “T” so as to overwrite the previous value. Accordingly, the time information extracted from the response packet received directly after is held in the register “T”.
Then, assuming that a response packet sent after t seconds is received by the Web camera 12, and the response wait port shall be closed directly thereafter. All the successive response packets, that is, response packets transmitted after (t+2) seconds, (t+4) seconds . . . are discarded in the routers 16, and do not arrive at the Web camera 12.
The Web camera 12 sends a test end packet because it does not receive a next response packet even after an elapse of 5 seconds from the preceding reception. The server 14 receives the test end packet to end the sending of the response packet. Consequently, in the register “T” of the Web camera 12, “t seconds” remains, and accordingly, “t seconds” is an optimum send interval T.
After completion of such an initial setting, the Web camera 12 accepts a command from the terminal, that is, the cellular phone 22 through the server 14, and sends back an execution result of the command to the cellular phone 22. A transmission procedure of a command and an execution result in a case that the router 16 is the UPnP-compliant type is shown in FIG. 2(C), and a transmission procedure of a command and an execution result in a case that the router 16 is the UPnP-non-compliant type is shown in FIG. 3(B).
First, with reference to FIG. 2(C), as to the router 16 of the UPnP-compliant type, the specific port is released by the preceding initial setting. A command sent from the cellular phone 22 is received by the server 14. The server 14 holds the received command in the RAM 36 while sending a “command's presence” notification packet to the destination specified by the address and the port number held in the RAM 36.
The “command's presence” notification packet sent from the server 14 is received by the router 16. The router 16 transmits the received “command's presence” notification packet to the Web camera 12.
The Web camera 12 receives the “command's presence” notification packet transmitted by the router 16, and sends a command request packet complying with the TCP (Transmission Control Protocol). The sent command request packet is received by the server 14, and in response thereto, the server 14 sends a command held in the RAM 36 to the client. The sent command is received in a predetermined port by the router 16, and the router 16 transmits the received command to the Web camera 12.
The Web camera 12 receives the command transferred by the router 16, executes the received command, and sends an execution result according to the TCP. The transmitted execution result is received by the server 14, and the server 14 transmits the received execution result to the cellular phone 22. The transmitted execution result is received by the cellular phone 22, and the cellular phone 22 displays the received execution result on an LCD monitor (not illustrated).
Next, with reference to FIG. 3(B), because the router 16 is the UPnP-non-compliant type, the client, that is, the Web camera 12 periodically sends a port notification packet at the optimum send interval (T) calculated in the initial setting. Consequently, in the router 16, the response wait port is in a continuously released state.
A configuration of a port notification packet sent to the router 16 by the Web camera 12 (client) when the router 16 is the UPnP-non-compliant type is shown in FIG. 3(C). With reference to FIG. 3(C), an insignificant port number, “0”, is described in the data area of the port notification packet, and the private IP address and the source port number are described in the header area thereof. The private IP address and the source port number in the header area are converted into the global IP address and the response wait port number when traveling across the router 16.
The server 14 receives the port notification packet from the Web camera 12, and extracts the global IP address and the response wait port number from the header area of the received port notification packet. Then, the extracted address and port number are held in the RAM 36.
The command sent from the cellular phone 22 is received by the server 14. The server 14 holds the received command in the RAM 36 while sending a “command's presence” notification packet complying with the UDP to a destination specified by the address and the port number held in the RAM 36. The “command's presence” notification packet sent from the server 14 is received in the response wait port by the router 16, and the router 16 transfers the received “command's presence” notification packet to the Web camera 12.
The Web camera 12 receives the “command's presence” notification packet transmitted by the router 16, and sends a command request packet complying with the TCP. The sent command request packet is received at a predetermined port by the server 14. The server 14 sends the command held in the RAM 36 in accordance with the TCP to the client. The sent command is received by the router 16 at a predetermined port, and the router 16 transmits the received command to the Web camera 12.
The Web camera 12 receives the command transmitted by the router 16, executes the received command, and sends an execution result in accordance with the TCP. The sent execution result is received by the server 14, and the server 14 transmits the received execution result to the cellular phone 22. The transmitted execution result is received by the cellular phone 22, and the cellular phone 22 displays the received execution result on the LCD monitor.
The client, that is, the CPU 28 of the Web camera 12 executes a type identifying task shown in FIG. 4 when the power source, or the like is turned on. After completion of the type identifying task, a main task shown in FIG. 5 and FIG. 6, a port notification packet sending task shown in FIG. 7, and a command executing task shown in FIG. 8 are executed in parallel manner under the control of the multitasking OS such as μITRON. It should be noted that the control programs according to these flowcharts are stored in the flash memory 30.
With reference to FIG. 4, in the type identifying task, it is determined whether or not the router 16 is the UPnP-compliant type in a step S1. If the determination result is negative, the process shifts to a step S3. In the step S3, a control system is set to the “type 2”. Thereafter, the task is ended.
Here, the determination in the step S1 can be performed as follows. An M-SEARCH packet on the basis of the SSDP is sent to the router 16, and responding to a 200 OK packet being sent back from the router 16, it is determined to be the UPnP-compliant type. On the other hand, if a 200 OK packet is not sent back, it is determined to be the UPnP-non-compliant type.
If the determination result in the step S1 is affirmative, the process shifts to a step S5 to request an IP address (WAN address) to access the Internet 20 via the network controller 34 from the router 16. In a step S7, it is determined whether or not a global IP address is received. If the determination result is negative, that is, if a private IP address is received, the control system is set to “type 2” in a step S9. Thereafter, the main task is ended.
When a global IP address is received, the process shifts from the step S7 to a step S11 to request the router 16 to release a specific port. In a next step S13, a port notification packet compliant with the UDP is sent to the server 14. In the data area of the port notification packet, a port number of a specific port requested to be released to the router 16 is described (see FIG. 2(B)). Thereafter, the process enters a loop in steps S15 and S17.
In the step S15, it is determined whether or not a response packet is received, and in the step S17, it is determined whether or not a predetermined time, 5 seconds, for example, has elapsed. If a response packet is received within 5 seconds from sending of the port notification packet, “YES” is determined in the step S15, and the process proceeds to a step 19. In the step S19, the control system is set to the “type 1”. Then, the task is ended.
If a response packet is not received even after an elapse of 5 seconds, “YES” is determined in the step S17, and then, the process proceeds to a step S21. In the step S21, the router 16 is requested to close the specific port previously released. In a step S23, the control system is set to the “type 2”. Then, the task is ended.
If the router 16 is not complaint with the UPnP, the type 2 is immediately selected as a control system. On the other hand, if the router 16 is compliant with the UPnP, only when a global IP address can be obtained from the router 16, and a response packet can be received within a predetermined time after sending of the port notification packet, the “type 1” is selected as a control system. If a global IP address cannot be obtained from the router 16, the “type 2” is selected as a control system. Additionally, even if a global IP address can be obtained, when a response packet cannot be received within a predetermined time, it is determined that the external server 14 does not send back a response packet to the notified address and port number, or it is determined that the specific port is not released in the router 16, and therefore, the control system becomes the “type 2”.
With reference to FIG. 5, in the main task, initialization processing is first executed in a step S31. In the initialization processing, an optimum send interval (T) at a time of sending a port notification packet is calculated. It should be noted that a detail of the optimum send interval (T) calculating processing is described later.
In a next step S33, it is determined whether or not the process enters a remote control mode. If the process enters the remote control mode, the process shifts from the step S33 to a step S35 to determine whether or not the control system is set to the “type 2”. If the determination result is affirmative, a port notification packet sending task (as later described) is activated in a step S37, and then, the process shifts to a step 39. If the determination result in the step S35 is negative, that is, if the control system is set to the “type 1”, the process directly shifts to the step S39.
In the step S39, a command executing task (as later described) is activated. In a next step S41, it is determined whether or not the process is out of the remote control mode. When the process is out of the remote control mode, the process shifts from the step S33 to the step S35 to determine whether or not the control system is set to the “type 2”. If the determination result is affirmative, the port notification packet sending task (described later) is activated in the step S37, and then, the process shifts to the step S39. If the determination result in the step S35 is negative, that is, if the control system is set to the “type 1”, the process directly shifts to the step S39.
In the step S39, a command execution task (described late) is activated. In a next step S41, it is determined whether or not the process is out of the remote control mode. When the process is out of the remote control mode, the process shifts from the step S41 to a step S43 to end the port notification packet transmission task. Furthermore, in a step S45, the command execution task is ended, and then, the process returns to the step S33.
The above-described optimum send interval (T) calculating processing in the step S31 is executed according to a subroutine shown in FIG. 6. With reference to FIG. 6, in a step S51, a test start packet compliant with the UDP is sent to the server 14. In a step S53, a timer is reset and started, and then, the process enters a loop in steps S55 and S57. In the step S55, it is determined whether or not a response packet is received, and in the step S57, it is determined whether or not a predetermined time, 5 seconds, for example, has elapsed.
If a response packet is received within 5 seconds, “YES” is determined in the step S55, and the process shifts to a step S59. In the step S59, time information (t) is extracted from the received response packet, and in a step S61, the extracted time information (t) is set to the register “T”. Then, the process returns to the step S53.
If a response packet is not received even after a lapse of 5 seconds, “YES” is determined in the step S57, and the process shifts to a step S63. In the step S63, a test end packet compliant with the UDP is sent to the server 14, and then, the process is restored to the hierarchical upper level of the routine.
With reference to FIG. 7, in the port notification packet sending task, in a first step S71, a port notification packet (see FIG. 3(C)) is sent to the server 14, and in a step S73, the timer is reset and started. In a step S75, it is determined whether or not the optimum send interval (T) has elapsed, and if the determination result is affirmative, the process returns to the step S71.
With reference to FIG. 8, in the command executing task, in a first step S81, it is determined whether or not a “command's presence” notification packet is received. In a step S83, a command request packet compliant with the TCP is sent to the server 14. In a step S85, it is determined whether or not a command is received, and if a command is received, the process shifts to a step S87. In the step S87, the received command is executed, and in a step S89, the execution result is sent to the server 14 according to the TCP. Then, the process returns to the step S81.
The CPU42 of the server 14 executes a UDP packet processing task shown in FIG. 9 and a main task shown in FIG. 10 in a parallel manner under the control of the multitasking OS such as μITRON. Additionally, the control program corresponding to these flowcharts are stored in the ROM 38.
With reference to FIG. 9, in the UDP packet processing task, the process enters a loop in first steps S101 and S103. In the step S101, it is determined whether or not a port notification packet is received, and in the step S103, it is determined whether or not a test start packet is received. When the port notification packet is received, “YES” is determined in the step S101, and the process shifts to a step S105. In the step S105, it is determined whether or not significant information is described in the data area of the received port notification packet. If the determination result in the step S105 is affirmative, the process shifts to a step S107. For example, when the port notification packet shown in FIG. 2(B) is received, the determination result in the step S105 becomes affirmative.
In the step S107, a port number is extracted from the data area of the received port notification packet, and an address is extracted from the header area of the same port notification packet. Then, the extracted port number, that is, the number of the specific port, and the extracted address, that is, the global IP address are held in the RAM 36. In a next step S109, a response packet is sent to the destination specified by the address and the port number held in the RAM 36, and then, the process returns to a loop of the steps S101 and S103.
If the determination result is negative in the step S105, the process shifts to a step S111. When the port notification packet shown in FIG. 3(C) is received, the determination result in the step S105 becomes negative. In the step S111, an address and a port number are extracted from the header area of the received port notification packet. Then, the extracted port number, that is, the response wait port number and the extracted address, that is, the global IP address are held in the RAM 36. Then, the process returns to the loop in the steps S101 and S103.
When a test start packet is received, “YES” is determined in the step S103, and the process shifts to a step S113. In the step S113, time information (t) is initialized. More specifically, “0” is se to the variable t. Then, in a step S115, the timer is reset and started, and the process enters a loop in steps S117 and S119. In the step S117, it is determined whether or not a constant time, two seconds, for example, has elapsed from receiving of the test start packet (preceding test packet) by the timer, and in the step S119, it is determined whether or not a test end packet is received.
After an elapse of 2 seconds from receiving of the test start packet (preceding test packet), in a first step S121, “2” is added to the variable t, and in a next step S123, the value of the variable t is embedded in a response packet, and in a step S125, the response packet is sent to the client according to the UDP. Then, the process returns to the step S115.
When the test end packet is received, the process returns to the loop in the steps S101 and S103.
With reference to FIG. 10, in the main task, in a first step S131, it is determined whether or not a command is received from a terminal, that is, the cellular phone 22. When the command is received, the process shifts to a step S133 to send a “command's presence” notification packet compliant with the UDP to the destination specified by the address and the port number held in the RAM 36. Here, the port number held in the RAM 36 is either of the specific port number and the response wait port number.
In a step S135, it is determined whether or not a command request packet is received, and when a command request packet is received, the process shifts to a step S137 to send the command previously received and held in the RAM 36 to the destination specified by the address and the port number held in the same RAM 36. In a next step S139, it is determined whether or not an execution result is received, and when the execution result is received, the process shifts to a step S141 to transmit the received execution result to the cellular phone 22. Then, the process returns to the step S131.
As understood from the above description, in this embodiment, either of the UPnP protocol compliant type and the UPnP protocol-non compliant type is utilized as a router 16. A command is transmitted from the external server 14 through the router 16.
When the router 16 is the UPnP-compliant type, the Web camera 12 issues to the router 16 a port releasing request. This releases a specific port. Next, the Web camera 12 request the router 16 to send destination information including an identifier of the released specific port to the external server 14. The destination information (see FIG. 2(B)) is sent to the external server 14 by the router 16. The external server 14 sends a command to the specific port on the basis of the identifier included in the destination information.
When the router 16 is the UPnP-non-compliant type, the Web camera 12 repeatedly issues information send requests to the router 16. The information send request to be issued is a send request for sending the destination information including an identifier of an arbitrary port to the external server 14. The router 16 sends destination information (see FIG. 3(C)) to the external server 14, and temporarily releases an arbitrary port (response wait port) every time that an information send request is issued. The external server 14 outputs a command on the basis of the identifier included in the destination information to a response wait port.
Thus, when the router 16 is the UPnP-compliant type, the Web camera 12 request the router 16 to release a specific port, and to send the destination information including the identifier of the released specific port to the server 14. On the other hand, when the router 16 is the UPnP-non-compliant type, an information send request is repeatedly issued to the router 16 to thereby make a state in which the response wait port is continuously released, and notifies the server 14 of the destination information including the identifier of the released response wait port. Thus, it is possible to accept a command from the server 14 at an arbitrary timing regardless of types of the router 16.
In addition, when the router 16 is the UPnP-non-compliant type, the Web camera 12 issues to the router 16 a send request to request the router 16 to send a test packet for requesting repetitive responses to the server 14. In response thereto, the router 16 sends a test packet to the server 14, and temporarily releases the response wait port. The server 14 repeatedly sends back a response packet in response to the test packet. At this time, the server 14 attaches time information representative of a waiting time from receiving the test packet to its reply to the response packet to be sent back.
The Web camera 12 receives the response packet repeatedly sent back from the external server 14 through the released response wait port. When the response wait port is closed, it becomes impossible to receive a response packet. Here, a time indicated by the time information attached to the lastly received response packet shall be a send request issuing cycle (=optimum send cycle T).
The Web camera 12 repeatedly issues a send request to the router 16 at the cycle thus determined, the longest period within the period (port releasing period) during which the router 16 releases the response wait port in response to a send request, that is, the period equal to or slightly shorter than the port releasing period. Thus, it is possible to making a state in which the response wait port is continuously released while reducing the load on the communications line, such as the Internet 20, a LAN, etc.
In this embodiment, the server 14 attaches the time information to the response packet, and the Web camera 12 regards the time indicated by the time information attached to the lastly received response packet as an information send request issuing cycle. However, it may be possible that the Web camera 12 itself counts the elapsed time from sending a test packet to receiving a response packet, and regard the counting result corresponding to the finally received response packet as an information sending request issuing cycle.
Next, another embodiment is described. The embodiment also relates to the surveillance camera system. The surveillance camera system of this embodiment is constituted as in the surveillance camera system of the above-described embodiment. The operation of the surveillance camera system in this embodiment is the same as that of the above-described embodiment except for an optimum send interval (T) calculating process. Thus, in this embodiment, by utilizing FIG. 1, FIG. 2(A), FIG. 2(B), FIG. 3(B), FIG. 4, FIG. 5, FIG. 7, FIG. 8 and FIG. 10, a duplicated description will be omitted.
In what follows, the optimum send interval calculating processing is described with reference to FIG. 11-FIG. 13. It should be noted that FIG. 11 corresponds to FIG. 3(A), FIG. 12 corresponds to FIG. 6, and FIG. 13 corresponds to FIG. 9.
First, with reference to FIG. 11, in a case that the router 16 is the UPnP-non-compliant type, the router 16 does not respond to an M-SEARCH packet from the Web camera 12. Since a 200 OK packet is not sent back even if an M-SEARCH packet is sent, the Web camera 12 selects the type 2 as a control system to shift to the optimum send interval (T) calculating processing.
In the optimum send interval calculating processing, the client, that is, the Web camera 12 first sends a test start packet compliant with the UDP to the server 14. The sent test start packet is subjected to address/port converting processing by the router 16, and the packet on which the address/port converting processing is performed is received by the server 14. At this time, in the router 16, a response wait port is released, and a source address, that is, a private IP address of the Web camera 12 and port numbers before and after the conversion, that is, a source port number and a response wait port number are recorded in the table. The response wait port released in response to the test start packet is closed after a lapse of a predetermined time period, 15 seconds, for example.
The server 14 sends a response packet compliant with the UDP to the client after 60 seconds from receiving the test start packet. In the response packet, the time information indicative of the elapsed time from receiving the test start packet, that is, “60 seconds” is described.
At this time, the response wait port has already been closed, thus, the response packet sent after 60 seconds is discarded in the router 16, and the Web camera 12 cannot receive a response packet.
Thus, the Web camera 12 sends a first test packet to the server 14 when a predetermined time period, 65 seconds, for example has elapsed from sending of the test start packet. The sent test packet is subjected to address/port converting processing by the router 16, and the packet on which the address/port converting processing is performed is received by the server 14. At this time, in the router 16, the response wait port is released again, and the private IP address, the source port number, and the response wait port number are recorded in the table. The response wait port released in response to the test packet is closed after a lapse of 15 seconds, for example.
The server 14 sends a response packet to the client after 50 seconds from receiving the test packet. In the response packet, the time information indicative of the elapsed time from receiving of the test start packet, that is, “50 seconds” is described.
At this time, the response wait port has already been closed, and thus, the response packet sent after 50 seconds is discarded in the router 16, and the Web camera 12 cannot receive a response packet.
Thus, the Web camera 12 sends a next test packet to the server 14 when 65 seconds have elapsed from sending the preceding test packet. The sent test packet is subjected to the above described processing in the router 16, and then received by the server 14. The server 14 sends a response packet “40 seconds” to the client after 40 seconds have elapsed after receiving the test packet.
However, at this time also, the response wait port has already been closed, thus, the response packet “40 seconds” is discarded in the router 16, and the Web camera 12 cannot receive a response packet.
Thus, the Web camera 12 sends a further next test packet to the server 14 when 65 seconds have elapsed from sending the previous test packet. That is, the Web camera 12 sends a test packet for every 65 seconds while a response packet cannot be received.
In response to the test packet thus sent every 65 seconds, the server 14 sends a response packet “30 seconds”, a response packet “20 seconds” . . . by shortening a waiting time until the response by 10 seconds at each time, that is, after 30 seconds, 20 seconds . . . from the reception.
Thus, when a waiting time until the response (this shall be s seconds) is below a port-releasing time period, the Web camera 12 can receive a response packet. The Web camera 12 extracts time information “s seconds” from the received response packet, and records the extracted time information “s seconds” in the register “T”. For example, in a case that the releasing time of the response wait port is 15 seconds, a response packet “10 seconds” arrives at the Web camera 12, and “10 seconds” is recorded in the register “T”.
When the time information “s seconds” is thus recorded in the register “T”, the Web camera 12 sends a test end packet, and in the server 14 receiving the test end packet, the optimum send interval calculating processing is ended.
The optimum interval (T) calculating processing in the step S31 in FIG. 5 is executed according to a subroutine shown in FIG. 12. With reference to FIG. 12, in a step S151, a test start packet compliant with the UDP is sent to the server 14. In a step S153, the timer is reset and started, and then, the process enters a loop in steps S155 and S157. In the step S155, it is determined whether or not a response packet is received. In the step S157, it is determined whether or not a predetermined time, 65 seconds, for example has elapsed.
If a response packet is received within 65 seconds, “YES” is determined in the step S155, and the process shifts to a step S159. In the step S159, the time information(s) is extracted from the received response packet, and in a step S161, the extracted time information (s) is set in the register “T”. Then, in a step S163, a test end packet compliant with the UDP is sent to the server 14, and then, the process is restored to the hierarchical upper level of the routine.
If a response packet is not received after the lapse of 65 seconds, “YES” is determined in the step S157, and the process shifts to a step S165. In the step S165, a test packet is sent to the server 14, and thereafter, the process returns to the step S153.
With reference to FIG. 13, the processing in steps S171-S181 is the same as that in the steps S101-S111 shown in FIG. 9, and the description thereof is omitted. When a test start packet is received, “YES” is determined in the step S173, and the process shifts to a step S183. In the step S183, the time information (s) is initialized. More specifically, “60” is set to the variable s. Then, in a step S185, the timer is reset and started, and the process enter the loop in steps S187 and S189. In the step S187, it is determined whether or not s seconds have elapsed from receiving of the test start packet by the timer. In the step S189, it is determined whether or not a test end packet is received.
When s seconds have elapsed from receiving of the test start packet, in a step S191, a value of the variable s is embedded in the response packet, in a next step S193, the response packet is sent to the client according to the UDP, and in a step S195, “10” is subtracted from the variable s. Then, the process returns to the step S185.
When a test end packet is received within s seconds from receiving of the test start packet, the process returns to the loop in the steps S171 and S173.
As understood from above, in this embodiment, similar to the above-described embodiment, the Web camera 12 can accept a command at arbitrary timing regardless of the type of the router 16.
In addition, when the router 16 is the UPnP non-compliant type, the Web camera 12 repeatedly sends a test packet for requesting a response to the server 14 through the router 16 while updating the response timing so as to be shortened. In other words, the Web camera 12 repeatedly issues a send request to the router 16 to request the router 16 to send a test packet to the server 14, and the router 16 sends to the server 14 a test packet in response to each send request. Then, the response wait port is temporarily released in the router 16, and the server 14 sends a response packet in response to the test packet. The response timing is gradually shortened every time that a test packet is received. At this time, the server 14 attaches the time information representative of the waiting time from receiving the test packet to its reply to the response packet to be sent.
At first, the response packet is sent back at timing later for the timing when the response wait port is closed, and therefore, the Web camera 12 cannot receive a response packet. When the response timing is shortened so as to be the timing when the response wait port is closed, the Web camera 12 can receive a response packet. Thus, a time indicated by the time information attached to the response packet first received shall be a send request issuing cycle (=optimum send cycle T).
The Web camera 12 repeatedly issues a send request to the router 16 at a cycle thus determined, that is, the longest cycle within the period (port releasing period) during which the router 16 releases the response wait port in response to a send request, that is, the cycle equal to the port releasing period or slightly shorter than the cycle. Thus, it is possible to make a state in which the response wait port is continuously released while reducing a load on the communications line, such as the Internet 20, a LAN, etc.
It should be noted that in this embodiment, the server 14 attaches the time information to a response packet, and the Web camera 12 regards the time indicated by the time information attached to the response packet first received as an information send request issuing cycle. Alternatively, the Web camera 12 itself counts the elapsed time from the last sending of a test packet to the first receiving of a response packet, and regards the counting result as an information sending request issuing cycle.
Next, another embodiment is described. In the above-described FIG. 11-FIG. 13 embodiment, a response packet send-back timing is determined by the server 14 (see step S183 and S195). However, in this embodiment, the client (Web camera 12) may determine this.
FIG. 14 shows an optimum send interval (T) calculating processing on the client side in this embodiment, and FIG. 15 shows a UDP packet processing task on the server 14 shown in this embodiment. The communication process performed between the client and the server itself is the same as the afore-mentioned embodiment, sot that FIG. 11 is aided.
First, with reference to FIG. 11, a test packet to be transmitted from the client to the server 14 includes time information indicative of send-back timing (s=60 seconds, 50 seconds . . . s+10 seconds, s seconds) determined on the side of the client. The server 14 sends back a response packet at the timing according to the time information included in the test packet. In the response packet, the time information representative of the elapsed time from receiving the test packet to its replay, that is, the time information (60 seconds, 50 seconds, . . . , s+10 seconds, s seconds) included in the test packet is described. It should be noted that in this embodiment, because the send-back timing is determined on the side of the client, processing of describing the time information in the response packet by the server 14 may be omitted.
An optimum interval calculating processing by the client in FIG. 14 further includes processing in steps S150 and S164 in FIG. 12. A UDP packet processing task by the server 14 shown in FIG. 15 is the processing in FIG. 13 with the steps S179 and S191 deleted. The steps S150 and S164 added to FIG. 14 correspond to the steps S179 and S191 deleted from FIG. 13.
With reference to FIG. 14, first, in the step S150, time information (s) is initialized. More specifically, “60” is set to the variable s. In a next step S151, a test start packet including the time information (s) is sent. Succeeding steps S153-S157 are similar to the steps S153-S157 in FIG. 12, and thus, the description thereof is omitted. If the determination result in the step S157 is “YES”, “10” is subtracted in the step S164, and the test start packet including the time information (s) is sent in a next step S165.
With reference to FIG. 15, steps S171-S181 are the same as the steps S171-S181 in FIG. 13, and thus, the description thereof is omitted. If the determination result in the step S173 is “YES”, the process shifts to a step S185 to reset and start the timer. Succeeding steps S187-S193 are the same as the steps in S187-S193 in FIG. 13, and therefore, the description thereof is omitted. Then, after execution of the step S193, the process returns to the step S185.
According to this embodiment, a next advantage can be obtained in addition to that of the above-described embodiments in FIG. 11-FIG. 13. That is, since the response packet send-back timing is determined on the side of the client, it is possible to reduce a processing load on the server 14 especially in a case of a lot of clients.
Additionally, in this embodiment, although the response timing of a response packet is changed so as to be shortened (see step S164), it may be changed so as to be lengthened. In what follows, an embodiment for changing a response timing of a response packet so as to be lengthened is explained by FIG. 16 and FIG. 17.
Referring to FIG. 16, a test packet to be sent from the client side (Web camera 12) to the server 14 includes time information representative of the send-back timing (s=5 seconds, 15 seconds, . . . , s seconds, s+10 seconds) determined on the side of the client. The server 14 sends back a response packet at the timing according to the time information included in the test packet. In the response packet, time information indicative of the elapsed time from receiving the test packet and its replay, that is, time information (5 seconds, 15 seconds, . . . , s seconds, s+10 seconds) the same as that included in the test packet is described. Additionally, in this embodiment, the send-back timing is determined on the side of the client, and therefore, the process of describing the time information in the response packet by the server 14 may be omitted.
When a waiting time until the reply is above the port releasing time, the Web camera 12 cannot receive a response packet. Thus, the time information “s seconds” extracted from the lastly received response packet is held in the register T of the Web camera 12.
The CPU 28 of the Web camera 12 calculates an optimum send interval (T) according to the procedure shown in FIG. 17. With reference to FIG. 17, in a step S201, time information (s) is first initialized. More specifically, “5” is set in the variable s. In a next step S203, a test start packet including the time information (s) is sent. Steps S205-S213 are the same as the steps S153-S159 in FIG. 14, and the description thereof is omitted.
In a step S215, “10” is added to the variable s, and in a next step S217, a test start packet including the time information (s) is sent. Thereafter, the process returns to the step S205.
If “YES” is determined in the step S209, the process shifts to a step S219 to send a test end packet to the server 14. Thereafter, the process is restored to the hierarchical upper level of the routine.
According to this embodiment, a following advantage can be obtained in addition to that of the above-described FIG. 11-FIG. 13 embodiment. That is, the response packet send-back timing is determined on the side of the client, and therefore, it is possible to reduce a processing load of the server 14 especially in a case that a lot of clients exist.
Additionally, in this embodiment, although the response packet send-back timing is determined on the side of the client (Web camera 12), the response packet send-back timing can be determined by the server 14. If the determination of the send-back timing is performed by the server 14, the steps S201 and S215 are deleted from the optimum send interval calculating processing shown in FIG. 17. On the other hand, in the UDP packet processing task of the server 14 shown in FIG. 15, a step corresponding to the deleted step S201 (S183a; not shown) is added directly after the step S173, and a step corresponding to the deleted step S215 (S195a; not shown) is added directly after the step S193.
In addition, in this embodiment, the response timing is updated at a constant interval (=10) in a lengthening direction, and the time information (s) described in the lastly received response packet is determined to be the optimum send interval (T). However, there is another method of reducing the update interval of the response timing to half of the original (=5) when a state in which a response packet has not yet arrived continues for a predetermined time. In what follows, an embodiment of reducing the update interval of the response timing when a state in which a response packet has not yet arrived continues for a predetermined time is described with reference to FIG. 18-FIG. 20.
Referring to FIG. 18, the client accepts that a response packet “s+10 seconds” has not yet arrived, and then sends a test packet including time information “s+5 seconds”. If the response packet “s+5 seconds” in response thereto is received, time information “s+5 seconds” extracted from the response packet is registered in the register T of the Web camera 12. If the response packet “s+5 seconds” is not received, the time information “s seconds” extracted from the previously received response packet remains to be held in the register T.
Additionally, in a case that the above-described response packet “s+5 seconds” has not yet arrived, a test packet including time information with the update interval further reduced, for example, time information with the update interval reduced to a quarter (=2.5) of the original may further be transmitted.
The client (CPU 28 of the Web camera 12) calculates an optimum send interval (T) in accordance with a procedure shown in FIG. 19 and FIG. 20. Referring to FIG. 19, steps S201-S219 are the same as the steps S201-S219 in FIG. 17, and therefore, the detailed description is omitted. If “YES” is determined in a step S209, the process shifts to a step S218a to add “5” to the variable s. In a step S218b, a test packet including time information (s) is sent to the server 14. In a step S218c, the timer is reset and started, and then, the process enters a loop of steps S218d and S218e. 
Referring to FIG. 20, in the step S218d, it is determined whether or not a response packet is received, and in the step S218e, it is determined whether or not a predetermined time, 65 seconds, for example, has elapsed.
If a response packet is received within 65 seconds, “YES” is determined in the step S218d, and the process shifts to a step S218f. In the step S218f, the time information (s) is extracted from the received response packet, and in a step S218g, the extracted time information (s) is set to the register “T”. Then, the process proceeds to a step S219.
If a response packet is not received even after the lapse of 65 seconds, “YES” is determined in the step S218e, and the process shifts to the step S219. In the step S219, a test end packet is sent to the server 14, and then, the process is restored to the hierarchical upper level of the routine.
According to this embodiment, when a state in which a response packet has not yet arrived continues for a predetermined time, by sending a test packet with the update interval of a response timing reduced, it is possible to improve calculation accuracy of the optimum send interval.
With respect to this, in FIG. 11-FIG. 13 embodiment and FIG. 14 and FIG. 15 embodiment, a response timing is updated at a constant interval (=10) in a shortening direction, and the time information (s) described in the firstly received response packet is determined to be the optimum send interval (T), but there also is a method of reducing the update interval of a response timing to half (=5) of the original when a response packet is first received. In what follows, an embodiment of reducing the update interval of a response timing when a response packet is first received is described by FIG. 21-FIG. 23.
Referring to FIG. 21, the client accepts arriving of a response packet “s seconds”, and then sends a test packet including the time information “s+5 seconds”. If a response packet “s+5 seconds” in response thereto is received, the time information “s+5 seconds” extracted from the response packet is registered in the register T. If the response packet “s+5 seconds” is not received, the time information “s seconds” extracted from the previously received response packet remains to be held in the register T.
Additionally, in a case that the above-described response packet “s+5 seconds” has received, a test packet including time information with the update interval further reduced, for example, time information with the update interval reduced to a quarter (=2.5) of the original may further be sent.
The client (the CPU 28 of the Web camera 12) calculates an optimum send interval (T) in accordance with procedure shown in FIG. 22 and FIG. 23. Referring to FIG. 22, steps S150-S161 are the same as the steps S150-S161 shown in FIG. 14, and therefore, the description thereof is omitted. In a step S162a succeeding to the step S161, “5” is subtracted from the variable s. In a step S162b, a test packet including time information (s) is sent to the server 14. In a step S162c, the timer is reset and started, and then, the process enters a loop in steps S162d and S162e. 
With reference to FIG. 23, in the step S162d, it is determined whether or not a response packet is received, and in the step S162e, it is determined whether or not a predetermined time, 65 seconds, for example, has elapsed.
If a response packet is received within 65 seconds, “YES” is determined in the step S162d, and the process shifts to a step S162f. In the step S162f, the time information (s) is extracted from the received response packet, and in a step S162g, the extracted time information (s) is set to the register “T”. Then, the process proceeds to a step S163.
Even after the 65 seconds have elapsed, if a response packet is not received, “YES” is determined in a step S162e, and then, the process shifts to the step S163. In the step S163, a test end packet is sent to the server 14, and thereafter, the process is restored to the hierarchical upper level of the routine.
According to this embodiment, when a response packet is first received, by sending a test packet with an update interval of the response timing reduced, it is possible to improve calculation accuracy of the optimum send interval.
According to the above, the description is made on the surveillance camera system 10 including the Web camera 12 and the server 14, but the present invention can be applied to any processing systems including an external server and a command processing apparatus for executing processing according to a command notified from an external server through a router.
Although the present invention has been described and illustrated in detail, it is clearly understood that the same is by way of illustration and example only and is not to be taken by way of limitation, the spirit and scope of the present invention being limited only by the terms of the appended claims.

## Claims

1. A command processing apparatus for executing a process according to a command sent from an external server through a router, out of a first system continuously releasing a specific port in response to a port releasing request and being compliant with a UPnP protocol and a second system performing an information sending in response to an information send request and temporarily releasing an arbitrary port, the router being compliant with at least said second system, comprising:
a determining device that determines whether or not said router is compliant with said first system;
a first issuer that issues said port releasing request to said router when the determination result by said determining device is affirmative;
a send requestor that requests said router to send destination information including an identifier of said specific port released in response to said port releasing request to said external server; and
a second issuer, wherein
when it is determined that the determination result by said determining device is negative, said command processing apparatus shifts process to determine an optimal send interval, and said second issuer repeatedly issues said information send request to said router at the optimal send interval, said information send request issued by said second issuer being a send request of the destination information including the identifier of said arbitrary port to said external server.

2. A command processing apparatus according to claim 1, wherein said determining device includes a protocol determining device that determines whether or not said router is compliant with said UPnP protocol, and said second issuer performs issuing processing when the determination result by said protocol determining device is negative.

3. A command processing apparatus according to claim 2, wherein said protocol determining device performs determination processing by utilizing a discovery function adopted by said UPnP protocol.

4. A command processing apparatus according to claim 2, wherein said determining device further includes a trying device that tries to acquire a global IP address when the determination result by said protocol determining device is affirmative, and a success determining device that determines whether or not the try by said trying device is successful, and
said second issuer performs issuing processing when the determination result by said success determining device is negative.

5. A command processing apparatus according to claim 1, further comprising:
a third issuer that issues to said router a send request to request to send an ask signal for asking a repetitive response to said external server;
a receiver that receives a response signal from said external server through said arbitrary port in response to the send request issued by said third issuer; and
a deciding device that decides an issuance cycle of said second issuer on the basis of the reception result by said receiver.

6. A command processing apparatus according to claim 1, further comprising:
a third issuer that repeatedly issues to said router a send request to request to send an ask signal for asking a response at timings different from each other to said external server;
a receiver that receives a response signal from said external server through said arbitrary port in response to the send request issued by said third issuer; and
a deciding device that decides an issuance cycle of said second issuing means on the basis of the reception result by said receiving means.

7. A storage medium storing a program to be executed by a processor of a command processing apparatus for executing processing according to a command sent from an external server through a router, out of a first system continuously releasing a specific port in response to a port releasing request and a second system performing an information sending in response to an information send request and temporarily releasing an arbitrary port, being compliant with at least said second system, said program comprising:
a determining step for determining whether or not said router is compliant with said first system;
a first issuing step for issuing said port releasing request to said router when the determination result by said determining step is affirmative;
a send requesting step for requesting said router to send destination information including an identifier of said specific port released in response to said port releasing request to said external server; and
a second issuing step for repeatedly issuing said information send request to said router when the determination result by said determining step is negative, wherein,
said information send request issued by said second issuing step is a send request of the destination information including the identifier of said arbitrary port to said external server.