es of the calling terminal, listing supported codecs. It is acknowledged with a TerminalCapability- SetAck response from the called terminal. The called terminal also sends a Terminal CapabilitySet message containing its media capabilities, which receives a TerminalCapabilitySetAck response. The H.323 protocol requires that one terminal be selected as the master with the other as the slave. This is accomplished using MasterSlaveDe- termination messages exchanged between the terminals. The messages con- tain the terminal type of the terminal and a random number. Terminal types are hierarchical, which determines the master. If the terminal type is the same, the random number determines the master. The message is acknowledged with a MasterSlaveDeterminationAcl message. The final phase of the call setup is the opening of two logical channels between the terminals. These channels are used to set up and control the media channels. The H.245 OpenLogicalChannel message sent in the H.245 control signaling connection contains the desired media type, including the codec that has been determined from the exchange of capabilities. It also con- tains a pair of addresses for the RTP and RTCP streams. The message is acknowledged with an OpenLogicalChannelAck message. SIP: Understanding the Session Initiation Protocol Now, the terminals begin sending RTP media packets and also RTCP control packets using the IP addresses and port numbers exchanged in the OpenLogicalChannel messages. Figure 8.3 shows a call tear-down sequence, which either terminal may initiate. In this example, the called terminal sends an EndSessionCommand message in the H.245 control signaling channel. The other terminal responds with an EndSessionCommand message in the H.245 control signaling channel, which can now be closed. The called terminal then sends a Disengage Request (DRQ) message and receives a Disengage Confirmation (DCF) message from the gatekeeper. This way, the gatekeeper knows that the resources used in the call have now been freed up. A Call Det