A communication device comprising: a base station unit configured to operate as a base station that establishes a wireless local area network, LAN, compliant with IEEE802.11; a station unit configured to operate as a station that connects to a base station that establishes a wireless LAN compliant with IEEE802.11; a providing unit configured to operate as a providing device that provides a communication parameter; a receiving unit configured to operate as a receiving device that receives a communication parameter from a providing device; and a determination unit configured to determine whether a role of the communication device is a first role or a second role based on a comparison of a first priority of the communication device with a second priority received from another communication device; wherein, the first priority set by the communication device depends on information associated with the communication device, wherein, in a case where the determination unit determines that the role of the communication device is the first role, the communication device operates the base station unit and the providing unit , causes the providing unit to provide a communication parameter for communicating in the wireless LAN compliant with IEEE802.11 to be established by the base station unit to the other communication device, and communicates with the other communication device by setting the communication parameter provided by the providing unit , and wherein, in a case where the determination unit determines that the role of the communication device is the second role, the communication device operates the station unit and the receiving unit , causes the receiving unit to receive a communication parameter for communicating in the wireless LAN compliant with IEEE802.11 to be established by the other communication device from the other communication device, and communicates with the other communication device by setting the communication parameter received by the receiving unit . a base station unit configured to operate as a base station that establishes a wireless local area network, LAN, compliant with IEEE802.11; a station unit configured to operate as a station that connects to a base station that establishes a wireless LAN compliant with IEEE802.11; a providing unit configured to operate as a providing device that provides a communication parameter; a receiving unit configured to operate as a receiving device that receives a communication parameter from a providing device; and a determination unit configured to determine whether a role of the communication device is a first role or a second role based on a comparison of a first priority of the communication device with a second priority received from another communication device; wherein, the first priority set by the communication device depends on information associated with the communication device, wherein, in a case where the determination unit determines that the role of the communication device is the first role, the communication device operates the base station unit and the providing unit , causes the providing unit to provide a communication parameter for communicating in the wireless LAN compliant with IEEE802.11 to be established by the base station unit to the other communication device, and communicates with the other communication device by setting the communication parameter provided by the providing unit , and wherein, in a case where the determination unit determines that the role of the communication device is the second role, the communication device operates the station unit and the receiving unit , causes the receiving unit to receive a communication parameter for communicating in the wireless LAN compliant with IEEE802.11 to be established by the other communication device from the other communication device, and communicates with the other communication device by setting the communication parameter received by the receiving unit . <EOS>