A communication apparatus (STA-A, STA-B, STA-C) for communicating using Wi-Fi direct which has a base station function and a terminal function and performs communication using at least one of the base station function and the terminal function, comprising: identification means for identifying a partner apparatus for communication among one or more other communication apparatuses based on a service to be executed by the communication apparatus and services to be executed by the other communication apparatuses; and decision means for deciding whether the communication apparatus uses the base station function or the terminal function when connecting to the partner apparatus, based on execution states of base station functions and terminal functions of the communication apparatus and the partner apparatus wherein: in a case that the partner apparatus executes the terminal function and the communication apparatus does not execute the terminal function, the decision means is adapted to decide to connect to the partner apparatus using the base station function by causing the partner apparatus to join the network of the communication apparatus, in a case that the partner apparatus executes the base station function (S701, P2P GO) and the communication apparatus does not execute the base station function, the decision means is adapted to decide to connect to the partner apparatus using the terminal function, in a case that the partner apparatus executes neither the base station function nor the terminal function (S501, S701, S901, UNDECIDED), the decision means is adapted to perform decision, with the partner apparatus based on a predetermined protocol, in which one of the communication apparatus and the partner apparatus is decided to execute the base station function and another one of the communication apparatus and the partner apparatus is decided to execute the terminal function (S504, S707, S906), and wherein in a case where both the communication apparatus and the partner apparatus execute the base station function, the communication apparatus is adapted to abnormally terminate the connection processing by outputting an error. identification means for identifying a partner apparatus for communication among one or more other communication apparatuses based on a service to be executed by the communication apparatus and services to be executed by the other communication apparatuses; and decision means for deciding whether the communication apparatus uses the base station function or the terminal function when connecting to the partner apparatus, based on execution states of base station functions and terminal functions of the communication apparatus and the partner apparatus wherein: in a case that the partner apparatus executes the terminal function and the communication apparatus does not execute the terminal function, the decision means is adapted to decide to connect to the partner apparatus using the base station function by causing the partner apparatus to join the network of the communication apparatus, in a case that the partner apparatus executes the base station function (S701, P2P GO) and the communication apparatus does not execute the base station function, the decision means is adapted to decide to connect to the partner apparatus using the terminal function, in a case that the partner apparatus executes neither the base station function nor the terminal function (S501, S701, S901, UNDECIDED), the decision means is adapted to perform decision, with the partner apparatus based on a predetermined protocol, in which one of the communication apparatus and the partner apparatus is decided to execute the base station function and another one of the communication apparatus and the partner apparatus is decided to execute the terminal function (S504, S707, S906), and wherein in a case where both the communication apparatus and the partner apparatus execute the base station function, the communication apparatus is adapted to abnormally terminate the connection processing by outputting an error. in a case that the partner apparatus executes the terminal function and the communication apparatus does not execute the terminal function, the decision means is adapted to decide to connect to the partner apparatus using the base station function by causing the partner apparatus to join the network of the communication apparatus, in a case that the partner apparatus executes the base station function (S701, P2P GO) and the communication apparatus does not execute the base station function, the decision means is adapted to decide to connect to the partner apparatus using the terminal function, in a case that the partner apparatus executes neither the base station function nor the terminal function (S501, S701, S901, UNDECIDED), the decision means is adapted to perform decision, with the partner apparatus based on a predetermined protocol, in which one of the communication apparatus and the partner apparatus is decided to execute the base station function and another one of the communication apparatus and the partner apparatus is decided to execute the terminal function (S504, S707, S906), and wherein in a case where both the communication apparatus and the partner apparatus execute the base station function, the communication apparatus is adapted to abnormally terminate the connection processing by outputting an error.