-九、發明說明: *【發明所屬之技術領域】 本發明涉及網路電話,尤其涉及一種網路設備及其建立 服務品質之方法。 【先前技術】 在網路電話應用中,語音封包的傳輸需要低延遲與流量 穩定的網路環境,若網路環境未提供服務品質(Quality of > Service ’ Qos ),則無法保證語音封包地穩定傳輸,易造成 通話品質不佳。現有的QoS建立方法係在網路電話系統之發 話端發出會話發起協定(Session Initiation Protocol,SIP) 呼叫建立請求(INVITE)之前就先送出Q〇S請求訊息,或 ,是受話端接收到來自發話端之SIP INVITE後才開始建立 QoS。 ¥ 然而’現有之做法使得QoS資源無法做有效管理,原因 在於發話端在發出SIP INVITE之前就要求Q0S,但該通通 .話卻不能保證一疋會建立。另外,如果來自於發話端之Sip INVITE異常’容易造成QoS的資源被佔用,造成浪費。 【發明内容】 有鑑於此,需提供一種網路設備,用於在連接於網路之 兩終端設備之間建立服務品質。 此外,還需提供一種建立服務品質之方法,用於在連接 於網路之兩終端設備間建立服務品質。 一種網路設備,用於在連接於網路之兩終端設備之間建 立服務品質(Quality of Service,Q〇s),包括收發模組及狀 1376911 -態設置模組。收發模組用於收發該等終端設備之任一者發送 .、之呼叫建立請求、請求響應訊息、確認訊息及QoS請求。狀 . 態設置模組用於設置該網路設備之狀態,該網路設備之狀態 包括空閒狀態、邀請狀態、嘗試狀態、確認狀態及QoS狀態。 該狀態設置模組用於當該收發模組於該空閒狀態接收到該 呼叫建立請求時,將該網路設備之狀態由該空閒狀態切換為 該邀請狀態,當該收發模組於該邀請狀態接收到該請求響應 訊息時,將該網路設備之狀態由該邀請狀態切換為該嘗試狀 鲁態,當該收發模組於該嘗試狀態接收到該確認訊息時,將該 網路設備之狀態由該嘗試狀態切換到該確認狀態,及當該收 發模組於該確認狀態接收到該QoS請求且該QoS請求成功 時,將該網路設備之狀態由該確認狀態切換到該QoS狀態。 一種建立服務品質之方法,應用於網路設備中,以在連 '接於網路之兩終端設備間建立QoS,包括:該網路設備處於 空閒狀態;接收該等終端設備之一者發送之呼叫建立請求, φ發送該呼叫建立請求至該等終端設備之另一者,並將該網路 設備之狀態切換到遨請狀態;接收該等終端設備之另一者發 送之請求響應訊息,發送該請求響應訊息至該等終端設備之 一者,並將該網路設備之狀態切換到嘗試狀態;接收該等終 端設備之一者發送之確認訊息,發送該確認訊息至該等終端 設備之另一者,並將該網路設備之狀態切換到確認狀態;及 接收該等終端設備之任一者發送之QoS請求,並在QoS請 求成功後,將該網路設備之狀態切換到QoS狀態。 【實施方式】 1376911 - 參閱圖1,所示為本發明一實施方式中網路設備10之應 用環境圖。在本實施方式中,兩終端設備20與20’分別經由 網路設備10與10’連接至網路從而進行相互通訊。在本實施 方式中,網路設備10與10’為閘道器,所連接之網路為網路 電話(Voice over Internet Protocol,VoIP)網路,終端設備 20與20’係為網路電話機,其相互通訊所傳輸之封包為語音 封包,因而需建立服務品質(Quality of Service,QoS ),以 確保語音封包的穩定傳輸。在本發明之其他實施方式中,網 ®路設備10與10’亦可應用於其他網路中。在本實施方式中, 網路設備10與10’之結構及工作原理完全相同,因而以下僅 以一個網路設備10為例進行說明。 圖2所示為本發明一實施方式中網路設備10之模組 圖。在本實施方式中,網路設備10在連接於網路之兩終端 -設備20與20’之間建立QoS,其包括收發模組100及狀態設 置模組110。收發模組100用於收發該等終端設備20與20’ |之任一者發送之呼叫建立請求、請求響應訊息、確認訊息及 QoS請求。狀態設置模組110用於設置網路設備10之狀態, 網路設備10之狀態包括空閒狀態(Idle )、邀請狀態(Invite )、 嘗試狀態(Trying )、破認狀態(Acknowledge )及QoS狀態。 在本實施方式中,開始時,終端設備20與20’之間並未 有任何訊息傳輸,網路設備10處於空閒狀態。此時,若終 端設備20與20’之間需進行通訊,其中一個終端設備20發 送呼叫建立請求至與其相應之網路設備10,以發送至另一個 終端設備20’。網路設備10之收發模組100於空閒狀態接收 1376911 -到呼叫建立請求,將該呼叫建立請求發送至另一個終端設備 υ 20’,同時,狀態設置模組110將網路設備10之狀態由空閒 狀態切換到邀請狀態。若另一個終端設備20’接受該呼叫建 立請求,其發送請求響應訊息至網路設備10。 收發模組100於邀請狀態接收到請求響應訊息,將該請 求響應訊息發送至終端設備20,同時,狀態設置模組110 將該網路設備10之狀態由邀請狀態切換為嘗試狀態。在本 實施方式中,收發模組100還用於判斷呼叫建立請求與請求 *響應訊息是否來自網路同一側之終端設備20與20’。若呼叫 建立請求與請求響應訊息來自網路同一側之終端設備20與 20’,表明通訊屬於内部琴訊或訊息異常,狀態設置模組110 不會將網路設備10之狀態由邀請狀態切換為嘗試狀態。 t. 發話方接收到請求響應訊息後,發送確認訊息至網路設 -備10。收發模組100於嘗試狀態接收到確認訊息,將確認訊 息發送至另一終端設備20’,同時,狀態設置模組110將網 Φ路設備10之狀態由嘗試狀態切換為確認狀態。在本實施方 式中,收發模組100還用於判斷請求響應訊息與確認訊息是 否來自網路同一侧之終端設備20與20’。若請求響應訊息與 確認訊息來自網路同一側之終端設備20與20’,表明訊息異 常,狀態設置模組110不會將網路設備10之狀態由嘗試狀 態切換到確認狀態。 若該等終端設備20與20’之任一者發出QoS請求至網 路設備10,收發模組100於確認狀態接收到QoS請求,將 QoS請求發送至該等終端設備20與20’相應之另一者,當該 1376911 • QoS請求成功時,該狀態設置模組110將網路設備10之狀 、態由確認狀態切換到Qos狀態。 在本實施方式中,收發模組100還用於收發該等終端設 備20與20,之任一者發送之呼叫結束訊息、釋放Q〇S請求 及釋放q〇S響應’網路設備1 〇之狀態還包括QoS釋放狀態。 若終端設備20與終端設備2〇’之通訊結束’該等終端設備 20與20,之任一者發出呼叫結束訊息至網路設備10。收發模 組100於QoS狀態接收呼叫結束訊息’將呼叫結束訊息發送 鲁至該等終端設備20與20’相應之另一者’同時,狀態設置模 組11〇將網路設備ίο之狀態由Q〇s狀態切換到Q〇s釋放狀 態。該等終端設備20與20’之任一者發出釋放QoS請求至 網路設備ίο,收發模組100於Q〇s釋放狀態接收到釋放Q〇s 請求,將釋放QoS請求發送至該等終端設備20與20’相應 -之另一者。當收發模組100接收到該等終端設備20與20’ 之另一者發送之釋放QoS響應時’狀態設置模組110將網路 •設備10之狀態由QoS釋放狀態切換到空閒狀態。 在本實施方式中,網路設備10應用於VoIP網路中’呼 叫建立請求為會話發起協定(Session Initiation Protocol’ SIP) INVITE,請求響應訊息為SIP 1XX-2XX,確認訊息為 SIP ACK,呼叫結束訊息為SIP BYE。 在本實施方式中,網路設備10還包括計時器120,用於 當網路設備10之狀態切換到邀請狀態、嘗試狀態及確認狀 態時啟動。狀態設置模組110還用於當計時器120於邀請狀 態、嘗試狀態及確認狀態逾時而收發模組100未收到任何訊 1376911 -息時,將網路設備10之狀態切換到空閒狀態。 , 當收發模組100於邀請狀態接收到呼叫建立取消或呼叫 建立錯誤訊息時,狀態設置模組110將網路設備10之狀態 由邀請狀態切換到空閒狀態。 當收發模組100於嘗試狀態及確認狀態接收到呼叫建立 取消訊息時,狀態設置模組110將網路設備10之狀態切換 到空閒狀態。 當收發模組100於QoS狀態及釋放QoS狀態接收到QoS ®失敗訊息時,狀態設置模組110將網路設備10之狀態切換 到空閒狀態。 圖3所示為本發明一實施方式中建立服務品質之方法之 流程圖。首先,在步驟S300,終端設備20與20’之間並未 有任何訊息傳輸,網路設備10處於空閒狀態。此時,若終 端設備20之間需進行通訊,其中一個終端設備20發送呼叫 建立請求至網路設備10,以發送至另一個終端設備20’。在 鲁步驟S302,網路設備10之收發模組100接收終端設備20 發送之呼叫建立請求,發送該呼叫建立請求至另一個終端設 備20’,同時,狀態設置模組110將網路設備10之狀態由空 閒狀態切換到邀請狀態。 若另一個終端設備20’接受該呼叫建立請求,其發送請 求響應訊息至網路設備10。在步驟S304,收發模組100接 收另一個終端設備20’發送之請求響應訊息,發送該請求響 應訊息至終端設備20,同時,狀態設置模組110將該網路設 備10之狀態由邀請狀態切換到嘗試狀態。 11 1376911 • 終端設備20接收到請求響應訊息後,發送確認訊息至 、網路設備10。在步驟S306,收發模組100接收終端設備20 發送之確認訊息,發送確認訊息至另一個終端設備20’,同 時,狀態設置模組110將網路設備10之狀態由嘗試狀態切 換為確認狀態。 若此時,該等終端設備20與20’之任一者發出QoS請 求至網路設備10,在步驟S308,收發模組100接收該等終 端設備20與20’之任一者發送之QoS請求,將QoS請求發 鲁送至該等終端設備20與20’之另一者,當該QoS請求成功 時,該狀態設置模組110將網路設備10之狀態由確認狀態 切換到QoS狀態。 若該等終端設備20與20’之通訊結束,該等終端設備 20與20’之任一者發出呼叫結束訊息至網路設備10。在步驟 • S310,收發模組100接收該等終端設備20與20’之任一者發 送之呼叫結束訊息,將呼叫結束訊息發送至該等終端設備20 鲁與20’之另一者,同時,狀態設置模組110將網路設備10之 狀態由QoS狀態切換到QoS釋放狀態。 該等終端設備20與20’之任一者發出釋放QoS請求至 網路設備10,在步驟S312,收發模組100接收該等終端設 備20與20’之任一者發送之釋放QoS請求,將釋放QoS請 求該等終端設備20與20’之另一者,且接收該等終端設備 20與20’之另一者發送之釋放QoS響應,狀態設置模組110 將網路設備10之狀態由QoS釋放狀態切換到空閒狀態。 圖4A與4B所示為本發明之另一實施方式中建立服務 12 1376911 •品質之方法之流程圖。首先,在步驟S400,網路設備ίο處 ,於空閒狀態。此時,終端設備20發送呼叫建立請求至網路 設備10,以發送至另一個終端設備20’。在步驟S402,網路 設備10之收發模組100接收終端設備20發送之呼叫建立請 求,發送該呼叫建立請求至另一個終端設備20’,啟動計時 器120,狀態設置模組110將網路設備10之狀態由空閒狀態 切換到邀請狀態。 在步驟S404,收發模組100判斷於計時器120計時期内 鲁是否從另一個終端設備20’接收到任何訊息。若計時器120 逾時,而收發模組100仍未接收到任何訊息,在步驟S406, 狀態設置模組110將網路設備10之狀態由邀請狀態切換到 空閒狀態,然後回到步驟S400。 若收發模組100於計時器120計時期内接收到訊息,在 •步驟S408,收發模組100關閉計時器120,判斷接收到之訊 息之類型。若接收到的訊息為呼叫建立取消或呼叫建立錯誤 鲁訊息,在步驟S410,狀態設置模組110將網路設備10之狀 態切換到空閒狀態,然後回到步驟S400。 若接收到的訊息為請求響應訊息,在步驟S412,收發模 組100判斷請求響應訊息與呼叫建立請求是否來自網路同一 側。若來自網路同一側,表明是區域網内的用戶互相通訊或 訊息異常,忽略該請求響應訊息,在步驟S414,狀態設置模 組110將網路設備10之狀態由邀請狀態切換到空閒狀態, 然後回到步驟S400。 若請求響應訊息與呼叫建立請求來自網路之兩侧,即終 13 1376911 •端設備20與20’位於網路之兩側,在步驟S416,收發模組 • . 100發送請求響應訊息至終端設備20,啟動計時器120,狀 態設置模組110將網路設備10之狀態切換到嘗試狀態。 在步驟S418,收發模組100判斷於計時器120計時期内 是否從終端設備20接收到任何訊息。若計時器120逾時, 收發模組100仍未從終端設備20接收到任何訊息,在步驟 S420,狀態設置模組110將網路設備10之狀態切換到空閒 狀態,然後回到步驟S400。 * 若收發模組100於計時器120計時期内從終端設備20 接收到訊息,在步驟S422,收發模組100關閉計時器120, 判斷接收到之訊息之類型。若接收到的訊息為呼叫建立取消 訊息,在步驟S424,狀態設置模組110將網路設備10之狀 態切換到空閒狀態,然後回到步驟S400。 ' 若接收到的訊息為請求響應訊息,則回到步驟S418。 若接收到的訊息為確認訊息,在步驟S426,收發模組 _ 100判斷確認訊息與請求響應訊息是否來自網路同一側。若 來自網路同一側,表明是訊息異常,忽略該確認訊息,在步 驟S428,狀態設置模組110將網路設備10之狀態由嘗試狀 態切換到空閒狀態,然後回到步驟S400。 若確認訊息與請求響應訊息來自網路之兩側,在步驟 S430,收發模組100發送確認訊息至另一個終端設備20’, 開啟計時器120,狀態設置模組110將網路設備10之狀態切 換到確認狀態。 在步驟S432,收發模組100判斷於計時器120計時期内 14 1376911 •是否從該等終端設備20與20’之任一者接收到任何訊息。若 .計時器120逾時,收發模組100仍未接收到任何訊息,在步 驟S434,狀態設置模組110將網路設備10之狀態切換到空 閒狀態,即回到步驟S400。 若收發模組100於計時器120計時期内接收到訊息,在 步驟S436,收發模組100關閉計時器120,判斷接收到之訊 息之類型。若接收到的訊息為呼叫建立取消訊息,在步驟 S438,狀態設置模組110將網路設備10之狀態切換到空閒 鲁狀態,然後回到步驟S400。 若接收到的訊息為QoS請求,在步驟S440,收發模組 100判斷QoS請求是否成功。在本實施方式中,收發模組100 藉由判斷是否接收到該等終端設備20與20’之另一者所發送 之對QoS請求之響應,判斷QoS請求是否成功。若收發模 •組100接收到該等終端設備20與20’之另一者所發送之對 QoS請求之響應,則判斷QoS請求成功。若未成功,則到步 $驟S438,狀態設置模組110將網路設備10之狀態切換到空 閒狀態,然後回到步驟S400。 若QoS請求成功,則在步驟S442,狀態設置模組110 將網路設備10之狀態切換到QoS狀態。 若該等終端設備20與20’之通訊結束,該等終端設備 20與20’之任一者發出呼叫結束訊息至網路設備10。在步驟 S444,收發模組100接收該等終端設備20與20’之任一者發 送之呼叫結束訊息,將呼叫結束訊息發送至該等終端設備20 與20’之另一者,同時,狀態設置模組110將網路設備10之 15 1376911 •狀態由Q〇s狀態切換到Q〇s釋放狀態。 該等终端設備20與20,之任一者發出釋放QoS請求至 網路設備10,在步驟S446,收發模組100接收該等終端設 備20與20,之任一者發送之釋放Q〇s請求’將釋放Q〇s請 求發送至該等終端設備20與20,之另一者’且接收該等終端 設備20與20,之另一者發送之釋放Q〇S響應’狀態設置模 組110將網路設備之狀態由Q〇s釋放狀態切換到空閒狀 態。 ® 利用本發明之網路設備10及其建立服務品質之方法’ 當通話經過三方握手(Three-Way Handshake)後,才允許 QoS請求,如此可避免呼叫建立請求異常所造成的q〇s資源 的佔用,確保QoS的正確性。 综上所述,本發明符合發明專利要件,爰依法提出專利 ‘申請。惟,以上所述者僅為本發明之較佳實施例,舉凡熟悉 本案技藝之人士,在爰依本案發明精神所作之等效修飾或變 籲化’皆應包含於以下之申請專利範圍内。 【圖式簡單說明】 圖1為本發明一實施方式中網路設備之應用環境圖。 圖2為本發明一實施方式中網路設備之模組圖。 圖3為本發明一實施方式中建立服務品質之方法之流程圖。 圖4A與4B為本發明另一實施方式中建立服務品質之方法 之流程圖。 【主要元件符號說明】 10 、 10, 網路設備 16 1376911 收發模組 100 狀態設置模組 110 計時器 120 終端設備 20 ' 20,Nine, invention description: * [Technical field to which the invention pertains] The present invention relates to a network telephone, and more particularly to a network device and a method thereof for establishing service quality. [Prior Art] In VoIP applications, the transmission of voice packets requires a network environment with low latency and stable traffic. If the network environment does not provide quality of service (Quality of > Service 'Qos), voice packets cannot be guaranteed. Stable transmission, easy to cause poor call quality. The existing QoS establishment method sends a Q〇S request message before the sender of the network telephone system sends a Session Initiation Protocol (SIP) call setup request (INVITE), or the callee receives the call from the caller. The QoS is only started after the SIP INVITE. ¥ However, the existing practice makes QoS resources unable to be effectively managed. The reason is that the calling terminal requires Q0S before issuing the SIP INVITE, but the communication is not guaranteed to be established. In addition, if the Sip INVITE from the originating terminal is abnormal, resources that are likely to cause QoS are occupied, resulting in waste. SUMMARY OF THE INVENTION In view of the above, it is desirable to provide a network device for establishing quality of service between two terminal devices connected to a network. In addition, there is a need to provide a method of establishing service quality for establishing service quality between two terminal devices connected to the network. A network device for establishing a quality of service (Q〇s) between two terminal devices connected to a network, including a transceiver module and a state setting module. The transceiver module is configured to send and receive any of the terminal devices, a call setup request, a request response message, an acknowledgement message, and a QoS request. The state setting module is used to set the state of the network device, and the state of the network device includes an idle state, an invitation state, an attempt state, an acknowledgement state, and a QoS state. The status setting module is configured to: when the transceiver module receives the call setup request in the idle state, switch the state of the network device from the idle state to the invite state, when the transceiver module is in the invite state Receiving the request response message, the state of the network device is switched from the invitation state to the trial state, and when the transceiver module receives the confirmation message in the attempt state, the state of the network device is Switching from the attempted state to the acknowledgment state, and when the transceiver module receives the QoS request in the acknowledgment state and the QoS request is successful, the state of the network device is switched from the acknowledgment state to the QoS state. A method for establishing service quality, which is applied to a network device to establish QoS between two terminal devices connected to the network, including: the network device is in an idle state; and receiving one of the terminal devices is sent by a call setup request, φ sending the call setup request to the other of the terminal devices, and switching the state of the network device to the request state; receiving a request response message sent by the other of the terminal devices, sending The request response message to one of the terminal devices, and switching the state of the network device to an attempted state; receiving an acknowledgement message sent by one of the terminal devices, and transmitting the confirmation message to the other of the terminal devices And switching the state of the network device to an acknowledgment state; and receiving a QoS request sent by any one of the terminal devices, and switching the state of the network device to a QoS state after the QoS request succeeds. [Embodiment] 1376911 - Referring to Figure 1, there is shown an application environment diagram of a network device 10 in an embodiment of the present invention. In the present embodiment, the two terminal devices 20 and 20' are connected to the network via the network devices 10 and 10', respectively, to communicate with each other. In the present embodiment, the network devices 10 and 10' are gateway devices, the connected network is a Voice over Internet Protocol (VoIP) network, and the terminal devices 20 and 20' are network telephones. The packets transmitted by each other are voice packets, so quality of service (QoS) needs to be established to ensure stable transmission of voice packets. In other embodiments of the invention, the network devices 10 and 10' may also be used in other networks. In the present embodiment, the structure and operation principle of the network devices 10 and 10' are completely the same. Therefore, only one network device 10 will be described below as an example. 2 is a block diagram of a network device 10 in accordance with an embodiment of the present invention. In the present embodiment, the network device 10 establishes QoS between the two terminals-devices 20 and 20' connected to the network, and includes a transceiver module 100 and a state setting module 110. The transceiver module 100 is configured to send and receive a call setup request, a request response message, a confirmation message, and a QoS request sent by any of the terminal devices 20 and 20'. The state setting module 110 is configured to set the state of the network device 10. The state of the network device 10 includes an idle state (Idle), an invite state (Invite), a try state (Trying), an acknowledgment state (Acknowledge), and a QoS state. In the present embodiment, at the beginning, there is no message transmission between the terminal devices 20 and 20', and the network device 10 is in an idle state. At this time, if communication is required between the terminal devices 20 and 20', one of the terminal devices 20 transmits a call setup request to the network device 10 corresponding thereto for transmission to the other terminal device 20'. The transceiver module 100 of the network device 10 receives the 1376911-to call setup request in an idle state, and sends the call setup request to another terminal device 20'. At the same time, the state setting module 110 sets the state of the network device 10 by The idle state is switched to the invitation state. If the other terminal device 20' accepts the call setup request, it sends a request response message to the network device 10. The transceiver module 100 receives the request response message in the invitation state, and sends the request response message to the terminal device 20. At the same time, the state setting module 110 switches the state of the network device 10 from the invitation state to the attempt state. In this embodiment, the transceiver module 100 is further configured to determine whether the call setup request and the request * response message are from the terminal devices 20 and 20' on the same side of the network. If the call setup request and the request response message are from the terminal devices 20 and 20' on the same side of the network, indicating that the communication is internal or the message is abnormal, the state setting module 110 does not switch the state of the network device 10 from the invitation state to Try the status. t. After receiving the request response message, the caller sends a confirmation message to the network device. The transceiver module 100 receives the confirmation message in the attempt state, and transmits the confirmation message to the other terminal device 20'. At the same time, the state setting module 110 switches the state of the network Φ device 10 from the attempted state to the confirmed state. In this embodiment, the transceiver module 100 is further configured to determine whether the request response message and the confirmation message are from the terminal devices 20 and 20' on the same side of the network. If the request response message and the confirmation message are from the terminal devices 20 and 20' on the same side of the network, indicating that the message is abnormal, the state setting module 110 does not switch the state of the network device 10 from the attempted state to the confirmed state. If any of the terminal devices 20 and 20' issues a QoS request to the network device 10, the transceiver module 100 receives the QoS request in the acknowledgment state, and sends the QoS request to the terminal devices 20 and 20'. In one case, when the 1376911 • QoS request is successful, the state setting module 110 switches the state of the network device 10 from the acknowledgment state to the QoS state. In this embodiment, the transceiver module 100 is further configured to send and receive the terminal devices 20 and 20, and the call termination message sent by any of the terminal devices 20 and 20 is released, and the Q〇S response is released and the network device 1 is released. The status also includes the QoS release status. If the communication between the terminal device 20 and the terminal device 2' ends, any of the terminal devices 20 and 20 issues a call end message to the network device 10. The transceiver module 100 receives the call end message 'the call end message is sent to the other of the terminal devices 20 and 20' in the QoS state. Meanwhile, the state setting module 11 sets the state of the network device ίο from the Q. The 〇s state is switched to the Q〇s release state. The terminal devices 20 and 20' issue a release QoS request to the network device ίο, and the transceiver module 100 receives the release Q〇s request in the Q〇s release state, and sends a release QoS request to the terminal devices. 20 corresponds to 20' - the other one. When the transceiver module 100 receives the release QoS response sent by the other of the terminal devices 20 and 20', the status setting module 110 switches the state of the network device 10 from the QoS release state to the idle state. In this embodiment, the network device 10 is applied to a VoIP network, where the call setup request is a Session Initiation Protocol (SIP) INVITE, the request response message is SIP 1XX-2XX, and the acknowledge message is a SIP ACK, and the call ends. The message is SIP BYE. In this embodiment, the network device 10 further includes a timer 120 for starting when the state of the network device 10 is switched to an invite state, an attempt state, and an acknowledgment state. The state setting module 110 is further configured to switch the state of the network device 10 to an idle state when the timer 120 does not receive any message when the transceiver module 100 receives the message in the invitation state, the attempt state, and the acknowledge state. When the transceiver module 100 receives the call setup cancellation or call setup error message in the invite state, the state setting module 110 switches the state of the network device 10 from the invite state to the idle state. When the transceiver module 100 receives the call setup cancellation message in the attempted state and the confirmed state, the state setting module 110 switches the state of the network device 10 to the idle state. When the transceiver module 100 receives the QoS® failure message in the QoS state and the release QoS state, the state setting module 110 switches the state of the network device 10 to the idle state. Fig. 3 is a flow chart showing a method of establishing service quality in an embodiment of the present invention. First, in step S300, there is no message transmission between the terminal devices 20 and 20', and the network device 10 is in an idle state. At this time, if communication is required between the terminal devices 20, one of the terminal devices 20 transmits a call setup request to the network device 10 to transmit to the other terminal device 20'. In step S302, the transceiver module 100 of the network device 10 receives the call setup request sent by the terminal device 20, and sends the call setup request to another terminal device 20'. At the same time, the state setting module 110 connects the network device 10. The state is switched from idle to inviting. If the other terminal device 20' accepts the call setup request, it sends a request response message to the network device 10. In step S304, the transceiver module 100 receives the request response message sent by the other terminal device 20', and sends the request response message to the terminal device 20. At the same time, the state setting module 110 switches the state of the network device 10 from the invitation state. To try the state. 11 1376911 • After receiving the request response message, the terminal device 20 sends a confirmation message to the network device 10. In step S306, the transceiver module 100 receives the confirmation message sent by the terminal device 20, and sends an acknowledgement message to the other terminal device 20'. At the same time, the state setting module 110 switches the state of the network device 10 from the attempted state to the confirmed state. If at this time, any of the terminal devices 20 and 20' issues a QoS request to the network device 10, the transceiver module 100 receives the QoS request sent by any of the terminal devices 20 and 20' in step S308. The QoS request is sent to the other of the terminal devices 20 and 20'. When the QoS request is successful, the state setting module 110 switches the state of the network device 10 from the acknowledgment state to the QoS state. If the communication between the terminal devices 20 and 20' ends, either of the terminal devices 20 and 20' issues a call end message to the network device 10. In step S310, the transceiver module 100 receives a call termination message sent by any of the terminal devices 20 and 20', and sends a call termination message to the other of the terminal devices 20 and 20'. The state setting module 110 switches the state of the network device 10 from the QoS state to the QoS release state. Any one of the terminal devices 20 and 20' issues a release QoS request to the network device 10. In step S312, the transceiver module 100 receives a release QoS request sent by any of the terminal devices 20 and 20'. Release the QoS request for the other of the terminal devices 20 and 20', and receive the release QoS response sent by the other of the terminal devices 20 and 20', and the state setting module 110 sets the state of the network device 10 by QoS. The release state is switched to the idle state. 4A and 4B are flow diagrams showing a method of establishing service 12 1376911 • Quality in another embodiment of the present invention. First, in step S400, the network device ίο is in an idle state. At this time, the terminal device 20 transmits a call setup request to the network device 10 to transmit to another terminal device 20'. In step S402, the transceiver module 100 of the network device 10 receives the call setup request sent by the terminal device 20, sends the call setup request to another terminal device 20', starts the timer 120, and the state setting module 110 connects the network device. The state of 10 is switched from the idle state to the inviting state. In step S404, the transceiver module 100 determines whether any message is received from another terminal device 20' during the timer 120 period. If the timer 120 expires and the transceiver module 100 has not received any message, the state setting module 110 switches the state of the network device 10 from the invited state to the idle state in step S406, and then returns to step S400. If the transceiver module 100 receives the message within the time period of the timer 120, in step S408, the transceiver module 100 turns off the timer 120 and determines the type of the received message. If the received message is a call setup cancellation or call setup error message, the state setting module 110 switches the state of the network device 10 to the idle state in step S410, and then returns to step S400. If the received message is a request response message, in step S412, the transceiving module 100 determines whether the request response message and the call setup request are from the same side of the network. If the user from the same side of the network indicates that the users in the area network communicate with each other or the message is abnormal, the request response message is ignored. In step S414, the state setting module 110 switches the state of the network device 10 from the invited state to the idle state. Then it returns to step S400. If the request response message and the call setup request come from both sides of the network, that is, the terminal 13 1376911 • the end devices 20 and 20' are located on both sides of the network, in step S416, the transceiver module • . 100 sends a request response message to the terminal device. 20. The timer 120 is started and the state setting module 110 switches the state of the network device 10 to the attempted state. In step S418, the transceiver module 100 determines whether any message is received from the terminal device 20 during the timer 120 period. If the timer 120 has expired, the transceiver module 100 has not received any message from the terminal device 20. In step S420, the state setting module 110 switches the state of the network device 10 to the idle state, and then returns to step S400. * If the transceiver module 100 receives a message from the terminal device 20 during the time period of the timer 120, in step S422, the transceiver module 100 turns off the timer 120 to determine the type of the received message. If the received message is a call setup cancel message, the state setting module 110 switches the state of the network device 10 to the idle state in step S424, and then returns to step S400. ' If the received message is a request response message, then return to step S418. If the received message is a confirmation message, in step S426, the transceiver module _100 determines whether the confirmation message and the request response message are from the same side of the network. If the message is abnormal from the same side of the network, the confirmation message is ignored. In step S428, the state setting module 110 switches the state of the network device 10 from the attempted state to the idle state, and then returns to step S400. If the confirmation message and the request response message are from both sides of the network, in step S430, the transceiver module 100 sends a confirmation message to the other terminal device 20', and the timer 120 is turned on, and the state setting module 110 sets the state of the network device 10. Switch to the confirmation status. In step S432, the transceiver module 100 determines whether the timer 120 has a period of time 14 1376911. • whether any message is received from any of the terminal devices 20 and 20'. If the timer 120 is over, the transceiver module 100 has not received any message. In step S434, the state setting module 110 switches the state of the network device 10 to the idle state, that is, returns to step S400. If the transceiver module 100 receives the message within the time period of the timer 120, the transceiver module 100 turns off the timer 120 in step S436 to determine the type of the received message. If the received message is a call setup cancel message, the state setting module 110 switches the state of the network device 10 to the idle state in step S438, and then returns to step S400. If the received message is a QoS request, in step S440, the transceiver module 100 determines whether the QoS request is successful. In the present embodiment, the transceiver module 100 determines whether the QoS request is successful by determining whether or not the response to the QoS request sent by the other of the terminal devices 20 and 20' is received. If the transceiving module group 100 receives a response to the QoS request sent by the other of the terminal devices 20 and 20', it determines that the QoS request is successful. If it is not successful, then to step S438, the state setting module 110 switches the state of the network device 10 to the idle state, and then returns to step S400. If the QoS request is successful, the state setting module 110 switches the state of the network device 10 to the QoS state in step S442. If the communication between the terminal devices 20 and 20' ends, either of the terminal devices 20 and 20' issues a call end message to the network device 10. In step S444, the transceiver module 100 receives the call termination message sent by any of the terminal devices 20 and 20', and sends a call termination message to the other of the terminal devices 20 and 20', and at the same time, the state setting The module 110 switches the state of the network device 10 from 13 to 776911 to the Q〇s state. Any one of the terminal devices 20 and 20 issues a release QoS request to the network device 10. In step S446, the transceiver module 100 receives the release Q〇s request sent by any of the terminal devices 20 and 20. 'Release the Q〇s request to the other of the terminal devices 20 and 20' and receive the terminal devices 20 and 20, the other of which sends the release Q〇S response' status setting module 110 The state of the network device is switched from the Q〇s release state to the idle state. ® Using the network device 10 of the present invention and its method of establishing quality of service' When a call passes a Three-Way Handshake, the QoS request is allowed, so that the q〇s resource caused by the abnormal call setup request can be avoided. Occupy to ensure the correctness of QoS. In summary, the present invention complies with the requirements of the invention patent, and patents are filed according to law. However, the above description is only the preferred embodiment of the present invention, and those skilled in the art will be able to include the equivalent modifications or changes in the spirit of the invention. BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a diagram showing an application environment of a network device according to an embodiment of the present invention. 2 is a block diagram of a network device in an embodiment of the present invention. 3 is a flow chart of a method for establishing service quality in an embodiment of the present invention. 4A and 4B are flow charts of a method for establishing service quality in another embodiment of the present invention. [Main component symbol description] 10, 10, network equipment 16 1376911 transceiver module 100 status setting module 110 timer 120 terminal device 20 ' 20,
1717