Share via


NetworkOperatorTetheringSessionAccessPointConfiguration 클래스

정의

Wi-Fi 테더링 핫스팟을 구성하는 데 사용되는 모든 세션별 구성 필드와 관련 도우미 메서드를 포함합니다.

NetworkOperatorTetheringSessionAccessPointConfiguration 에는 영구 대응 NetworkOperatorTetheringAccessPointConfiguration 과 동일한 필드 및 도우미 메서드가 포함되어 있으며 몇 가지 추가가 있습니다. 그러나 NetworkOperatorTetheringSessionAccessPointConfiguration 의 모든 구성 가능한 속성은 모든 공유 속성을 포함하여 세션별로 처리됩니다.

NetworkOperatorTetheringSessionAccessPointConfiguration 은 주로 StartTetheringAsync 와 함께 사용되어 세션별 테더링 구성을 지정합니다. 이렇게 하면 기존 영구 구성이 지워지거나 변경되지 않습니다. 매개 변수 없이 StartTetheringAsync를 호출하면 항상 ConfigureAccessPointAsync를 통해 미리 구성된 영구 구성이 사용됩니다.

public ref class NetworkOperatorTetheringSessionAccessPointConfiguration sealed
/// [Windows.Foundation.Metadata.Activatable(1114112, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 1114112)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class NetworkOperatorTetheringSessionAccessPointConfiguration final
[Windows.Foundation.Metadata.Activatable(1114112, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 1114112)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class NetworkOperatorTetheringSessionAccessPointConfiguration
function NetworkOperatorTetheringSessionAccessPointConfiguration()
Public NotInheritable Class NetworkOperatorTetheringSessionAccessPointConfiguration
상속
Object Platform::Object IInspectable NetworkOperatorTetheringSessionAccessPointConfiguration
특성

Windows 요구 사항

디바이스 패밀리
Windows 11 Insider Preview (10.0.26100.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v19.0에서 도입되었습니다.)
앱 기능
wiFiControl

예제

Windows.Networking.NetworkOperators 네임스페이스의 테더링 API는 테더링을 프로그래밍 방식으로 구성하고 제어할 수 있는 포괄적인 기능 집합(즉, 디바이스의 인터넷 연결을 다른 디바이스와 공유)을 제공합니다. 아래 코드 예제에서는 세션별 테더링 구성을 사용하는 방법을 보여 줍니다.

세션별 테더링 구성을 사용하면 영구 테더링 핫스폿 구성을 영구적으로 변경하지 않고 일시적으로 재정의할 수 있습니다. 이는 임시 설정이 필요한 경우에 특히 유용합니다. 예를 들어 모바일 핫스팟을 사용하여 PC에 HMD를 연결할 때는 사용자에게 구성 세부 정보를 공개하지 않고 사용자의 현재 모바일 핫스팟 구성을 변경하지 않고 임시 Wi-Fi 네트워크를 통해 디바이스를 연결하여 최대한 원활하게 작업을 수행하려는 경우입니다.

또한 PC에 대한 짧은 대기 시간과 낮은 지터 연결을 달성하기 위해 6GHz 연결을 사용할 수 있습니다. 사용자의 PC가 5GHz Wi-Fi 연결을 통해 인터넷에 연결된 경우 6GHz 대역에서 모바일 핫스팟을 시작할 수 없습니다. 따라서 테더링 핫스팟과 스테이션 연결 간의 성능 우선 순위를 지정하는 방법을 드라이버에 알려주는 세션별 매개 변수 PerformancePriority가 있습니다. 기본 상수는 다른 모든 항목보다 스테이션 연결의 우선 순위를 지정하도록 드라이버에 지시합니다. 반면 TetheringOverStation 은 드라이버에 테더링 핫스팟의 성능 우선 순위를 지정하도록 지시하므로 필요한 경우 드라이버가 스테이션 연결을 2.4GHz로 다운그레이드할 수 있습니다. 이는 사용자에게 핫스팟 구성 및 스테이션 연결을 개인적으로 변경할 필요 없이 최대한 원활한 환경을 제공하는 것입니다.

아래 코드 샘플은 다음을 보여 줍니다.

  • API 지원 확인. 앱에서 실행 중인 운영 체제가 세션별 테더링 구성을 지원하는지 여부를 테스트하는 것이 중요합니다. 이렇게 하려면 ApiInformation.IsApiContractPresent 메서드를 사용합니다.
  • 테더링 관리자를 가져옵니다. 코드 샘플의 로컬로 정의된 GetTetheringManagerForCurrentConnection 메서드는 사용 중인 인터넷 연결 프로필을 식별하고 해당 프로필에 해당하는 테더링 관리자를 검색합니다. 테더링 관리자는 나중에 기본 액세스 지점 구성을 검색하고 실제 테더링 세션을 시작하는 데 사용됩니다.
  • 세션 구성 설정 기존 기본 구성에서 테더링 세션 구성을 파생하거나 처음부터 설정할 수 있습니다. 그런 다음 SSID, 암호, 대역, 인증 종류 및 성능 우선 순위와 같은 다양한 매개 변수를 설정하거나 수정할 수 있습니다.
  • 테더링 세션을 시작합니다. 세션 구성을 StartTetheringAsync 메서드에 전달하여 테더링 세션을 시작할 수 있습니다. 또한 이 메서드는 TetheringOperationStatus 열거형을 통해 광범위한 피드백을 제공하여 작업의 결과에 대한 미묘한 이해를 제공합니다.
using System;
using System.Threading.Tasks;
using Windows.Foundation.Metadata;
using Windows.Networking.NetworkOperators;
using Windows.Networking.Connectivity;

namespace TetheringApiDemoApp
{
  static class TetheringApiDemoClass
  {
    // Sample desired per-session access point configuration values.
    private const string DesiredSsid = "DemoSsid";

    private const string DesiredPassphrase = "DemoPassphrase";

    private const TetheringWiFiBand DesiredBand =
      TetheringWiFiBand.SixGigahertz;

    private const TetheringWiFiAuthenticationKind DesiredAuthenticationKind =
      TetheringWiFiAuthenticationKind.Wpa3;

    private const TetheringWiFiPerformancePriority DesiredPerformancePriority =
      TetheringWiFiPerformancePriority.TetheringOverStation;

    public static void VerifyPerSessionTetheringApiSupport()
    {
      if (!ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 17))
      {
        throw new InvalidOperationException(
          "This OS doesn't support per-session tethering configurations.");
      }
    }

    public static NetworkOperatorTetheringManager GetTetheringManagerForCurrentConnection()
    {
      // Get the connection profile associated with the internet connection currently used by the local machine.
      ConnectionProfile currentConnectionProfile = NetworkInformation.GetInternetConnectionProfile();

      if (currentConnectionProfile == null)
      {
        throw new InvalidOperationException("Machine isn't connected to the internet.");
      }

      TetheringCapability tetheringCapability =
        NetworkOperatorTetheringManager.GetTetheringCapabilityFromConnectionProfile(currentConnectionProfile);

      if (tetheringCapability != TetheringCapability.Enabled)
      {
        throw new InvalidOperationException(
          $"Tethering is disabled on this machine. Reason code: {tetheringCapability}.");
      }

      return NetworkOperatorTetheringManager.CreateFromConnectionProfile(currentConnectionProfile);
    }

    public static async Task<NetworkOperatorTetheringSessionAccessPointConfiguration>
      SetUpSessionConfigurationAsync(NetworkOperatorTetheringManager tetheringManager)
    {
      NetworkOperatorTetheringSessionAccessPointConfiguration sessionConfiguration =
         new NetworkOperatorTetheringSessionAccessPointConfiguration();

      sessionConfiguration.Ssid = DesiredSsid;
      sessionConfiguration.Passphrase = DesiredPassphrase;

      if (await sessionConfiguration.IsBandSupportedAsync(DesiredBand))
      {
        sessionConfiguration.Band = DesiredBand;
      }
      else
      {
        throw new InvalidOperationException("Desired band isn't supported.");
      }

      if (await sessionConfiguration.IsAuthenticationKindSupportedAsync(DesiredAuthenticationKind))
      {
        sessionConfiguration.AuthenticationKind = DesiredAuthenticationKind;
      }
      else
      {
        throw new InvalidOperationException("Desired authentication kind isn't supported.");
      }

      sessionConfiguration.PerformancePriority = DesiredPerformancePriority;

      return sessionConfiguration;
    }

    public static async Task StartTetheringSessionAsync(
      NetworkOperatorTetheringManager tetheringManager,
      NetworkOperatorTetheringSessionAccessPointConfiguration sessionConfiguration)
    {
      TetheringOperationStatus operationResult =
        await tetheringManager.StartTetheringAsync(sessionConfiguration);

      if (operationResult.Status == TetheringOperationStatus.Success)
      {
        Console.WriteLine("Tethering started successfully.");
      }
      else if (operationResult.Status == TetheringOperationStatus.AlreadyOn)
      {
        // Custom error message for AlreadyOn status.
        Console.WriteLine("Tethering is already on.");
      }
      else if (operationResult.Status == TetheringOperationStatus.RadioRestriction)
      {
        // Custom error message for RadioRestriction status.
        Console.WriteLine(
          "Can't start tethering at 6 GHz due to radio restrictions (2x2 + dual radio).");
      }
      else if (operationResult.Status == TetheringOperationStatus.BandInterference)
      {
        // Custom error message for BandInterference status.
        Console.WriteLine(
          "Can't start tethering at 6 GHz because a 5 GHz connection interferes.");
      }
      else
      {
        // Generic error message for all other statuses.
        Console.WriteLine(
          $"Failed to start tethering: {operationResult.AdditionalErrorMessage}.");
      }
    }

    public static async Task Main()
    {
      try
      {
        VerifyPerSessionTetheringApiSupport();

        NetworkOperatorTetheringManager tetheringManager = GetTetheringManagerForCurrentConnection();

        NetworkOperatorTetheringSessionAccessPointConfiguration sessionConfiguration =
          await SetUpSessionConfigurationAsync(tetheringManager);

        await StartTetheringSessionAsync(tetheringManager, sessionConfiguration);
      }
      catch (InvalidOperationException ex)
      {
        Console.WriteLine($"Failed to initialize tethering configuration: {ex.Message}.");
      }
      catch (Exception ex)
      {
        Console.WriteLine($"Unexpected error: {ex.Message}.");
      }
    }
  }
}

설명

테더링 기능은 Windows 디바이스가 모바일 핫스팟으로 작동할 수 있도록 하는 기능으로, Wi-Fi 또는 Bluetooth를 통해 다른 디바이스에 인터넷 연결을 제공합니다. 네트워크 SSID, 네트워크 암호, 네트워크 무선 주파수 대역(예: 2.4GHz, 5GHz, 6GHz) 및 네트워크 인증 알고리즘(예: WPA2, WPA3)의 네 가지 영구 필드를 Wi-Fi 테더링 핫스팟에서 구성할 수 있습니다. 설정되면 모든 필드가 테더링 세션 간에 유지됩니다. 즉, 값이 비휘발성 스토리지에 저장됩니다.

그러나 전체 세션별 구성을 사용하여 테더링 세션을 시작할 수도 있습니다. 세션별 테더링 구성은 테더링 세션 간에 유지되지 않으며 현재 영구 구성을 변경하지 않습니다. 세션별 필드는 성능 우선 순위입니다.

따라서 NetworkOperatorTetheringSessionAccessPointConfiguration 의 목적은 StartTetheringAsync를 통해 테더링 세션을 시작할 때 세션별 테더링 구성을 지정하는 것입니다. 세션별 이 클래스의 추가 멤버는 일반적으로 Windows 설정을 통해 사용자가 현재 구성할 수 없는 값입니다.

생성자

NetworkOperatorTetheringSessionAccessPointConfiguration()

NetworkOperatorTetheringSessionAccessPointConfiguration의 instance 만듭니다.

속성

AuthenticationKind

Wi-Fi 테더링 연결에 사용할 인증 종류를 가져오거나 설정합니다. NetworkOperatorTetheringAccessPointConfiguration.AuthenticationKind와 유사합니다.

Band

Wi-Fi 테더링 연결에 사용할 빈도 대역을 가져오거나 설정합니다. NetworkOperatorTetheringAccessPointConfiguration.Band와 유사합니다.

Passphrase

Wi-Fi 테더링 연결에 사용할 네트워크 암호를 가져오거나 설정합니다. NetworkOperatorTetheringAccessPointConfiguration.Passphrase와 유사합니다.

PerformancePriority

기본 인터넷 연결이 Wi-Fi를 통해서도 있을 때 Wi-Fi 테더링 연결에 사용할 성능 우선 순위 값을 가져오거나 설정합니다. 스테이션 연결이 요청된 테더링 주파수 대역을 방해하는 주파수 대역에 있는 경우 Wi-Fi 칩셋은 연결의 주파수 대역을 방해하지 않는 다른 대역으로 변경하려고 시도합니다.

많은 Wi-Fi 칩셋은 기본 연결이 5GHz 대역을 넘는 경우 테더링 핫스팟을 6GHz 대역을 사용하도록 구성할 수 없는 제한 사항이 있습니다. 테더링 연결(TetheringOverStation)의 우선 순위를 지정하면 Wi-Fi 칩셋에서 기본 연결을 2.4GHz 대역으로 변경하여 테더링 핫스팟에 대해 요청된 6GHz 대역과 더 이상 간섭하지 않도록 합니다.

빈도 대역 이동이 불가능하거나 다른 성능 우선 순위 값을 지정하여 허용되는 경우 StartTetheringAsync를 호출하면 적절한 결과 상태(BandInterference)가 실패합니다.

Ssid

Wi-Fi 테더링 연결에 사용할 네트워크 SSID를 가져오거나 설정합니다. NetworkOperatorTetheringAccessPointConfiguration.Ssid와 유사합니다.

메서드

IsAuthenticationKindSupported(TetheringWiFiAuthenticationKind)

Wi-Fi 어댑터에서 특정 인증 종류로 테더링 핫스팟을 구성할 수 있는지 여부를 나타내는 값을 가져옵니다. NetworkOperatorTetheringAccessPointConfiguration.IsAuthenticationKindSupported와 유사합니다.

IsAuthenticationKindSupportedAsync(TetheringWiFiAuthenticationKind)

Wi-Fi 어댑터에서 특정 인증 종류로 테더링 핫스팟을 구성할 수 있는지 여부를 나타내는 값을 비동기적으로 가져옵니다. NetworkOperatorTetheringAccessPointConfiguration.IsAuthenticationKindSupportedAsync와 유사합니다.

IsBandSupported(TetheringWiFiBand)

Wi-Fi 어댑터에서 특정 빈도 대역을 사용하여 테더링 핫스팟을 구성할 수 있는지 여부를 나타내는 값을 가져옵니다. NetworkOperatorTetheringAccessPointConfiguration.IsBandSupported와 유사합니다.

IsBandSupportedAsync(TetheringWiFiBand)

Wi-Fi 어댑터가 특정 빈도 대역을 사용하여 테더링 핫스팟을 구성할 수 있는지 여부를 나타내는 값을 비동기적으로 가져옵니다. NetworkOperatorTetheringAccessPointConfiguration.IsBandSupportedAsync와 유사합니다.

적용 대상