

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用資料流程端點的公有廣播衛星 （窄頻帶）
<a name="examples.pbs-data-dataflow-endpoint"></a>

 此範例建立在使用者指南的 [JPSS-1 - 公有廣播衛星 (PBS) - 評估](examples.md#examples.pbs-definition)區段中完成的分析。

 若要完成此範例，您需要假設一個案例 -- 您想要將 HRD 通訊路徑擷取為數位中繼頻率 (DigIF)，並使用 SDR 在 Amazon EC2 執行個體上的資料流程端點應用程式收到時加以處理。

## 通訊路徑
<a name="examples.pbs-dataflow-endpoint.communication-paths"></a>

 本節代表[規劃您的資料流程通訊路徑](getting-started.step2.md)入門。在此範例中，您將在 CloudFormation 範本中建立兩個區段：參數和資源區段。

**注意**  
 如需 CloudFormation 範本內容的詳細資訊，請參閱[範本章節](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html)。

 針對參數區段，您將新增下列參數。透過 CloudFormation 主控台建立堆疊時，您將指定這些值。

```
Parameters:
  EC2Key:
    Description: The SSH key used to access the EC2 receiver instance. Choose any SSH key if you are not creating an EC2 receiver instance. For instructions on how to create an SSH key see [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html)
    Type: AWS::EC2::KeyPair::KeyName
    ConstraintDescription: must be the name of an existing EC2 KeyPair.

  ReceiverAMI:
    Description: The Ground Station DDX AMI ID you want to use. Please note that AMIs are region specific. For instructions on how to retrieve an AMI see [https://docs.aws.amazon.com/ground-station/latest/ug/dataflows.ec2-configuration.html#dataflows.ec2-configuration.amis](https://docs.aws.amazon.com/ground-station/latest/ug/dataflows.ec2-configuration.html#dataflows.ec2-configuration.amis)
    Type: AWS::EC2::Image::Id
```

**注意**  
 **您需要**建立金鑰對，並提供 Amazon EC2 `EC2Key` 參數的名稱。請參閱[為您的 Amazon EC2 執行個體建立金鑰對](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html)。  
 此外，建立 CloudFormation 堆疊時，**您需要**提供正確的**區域特定** AMI ID。請參閱 [AWS Ground Station Amazon Machine Image AMIs)](dataflows.ec2-configuration.md#dataflows.ec2-configuration.amis)。

 剩餘的範本程式碼片段屬於範本的資源區段 CloudFormation 。

```
Resources:
  # Resources that you would like to create should be placed within the resource section.
```

 鑒於我們將單一通訊路徑交付至 EC2 執行個體的情況，您將擁有單一同步交付路徑。根據 [同步資料交付](getting-started.step2.md#getting-started.step2.sync-data-delivery)區段，您必須使用資料流程端點應用程式設定 Amazon EC2 執行個體，並建立一或多個資料流程端點群組。

```
  # The EC2 instance that will send/receive data to/from your satellite using AWS Ground Station.
  ReceiverInstance:
    Type: AWS::EC2::Instance
    Properties:
      DisableApiTermination: false
      IamInstanceProfile: !Ref GeneralInstanceProfile
      ImageId: !Ref ReceiverAMI
      InstanceType: m5.4xlarge
      KeyName: !Ref EC2Key
      Monitoring: true
      PlacementGroupName: !Ref ClusterPlacementGroup
      SecurityGroupIds:
        - Ref: InstanceSecurityGroup
      SubnetId: !Ref ReceiverSubnet
      BlockDeviceMappings:
        - DeviceName: /dev/xvda
          Ebs:
            VolumeType: gp2
            VolumeSize: 40
      Tags:
        - Key: Name
          Value: !Join [ "-" , [ "Receiver" , !Ref "AWS::StackName" ] ]
      UserData:
        Fn::Base64:
          |
          #!/bin/bash
          exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
          echo `date +'%F %R:%S'` "INFO: Logging Setup" >&2

          GROUND_STATION_DIR="/opt/aws/groundstation"
          GROUND_STATION_BIN_DIR="${GROUND_STATION_DIR}/bin"
          STREAM_CONFIG_PATH="${GROUND_STATION_DIR}/customer_stream_config.json"

          echo "Creating ${STREAM_CONFIG_PATH}"
          cat << STREAM_CONFIG > "${STREAM_CONFIG_PATH}"
          {
            "ddx_streams": [
              {
                "streamName": "Downlink",
                "maximumWanRate": 4000000000,
                "lanConfigDevice": "lo",
                "lanConfigPort": 50000,
                "wanConfigDevice": "eth1",
                "wanConfigPort": 55888,
                "isUplink": false
              }
            ]
          }
          STREAM_CONFIG

          echo "Waiting for dataflow endpoint application to start"
          while netstat -lnt | awk '$4 ~ /:80$/ {exit 1}'; do sleep 10; done

          echo "Configuring dataflow endpoint application streams"
          python "${GROUND_STATION_BIN_DIR}/configure_streams.py" --configFileName "${STREAM_CONFIG_PATH}"
          sleep 2
          python "${GROUND_STATION_BIN_DIR}/save_default_config.py"

          exit 0

  # The AWS Ground Station Dataflow Endpoint Group that defines the endpoints that AWS Ground
  # Station will use to send/receive data to/from your satellite.
  DataflowEndpointGroup:
    Type: AWS::GroundStation::DataflowEndpointGroup
    Properties:
      ContactPostPassDurationSeconds: 180
      ContactPrePassDurationSeconds: 120
      EndpointDetails:
        - Endpoint:
            Name: !Join [ "-" , [ !Ref "AWS::StackName" , "Downlink" ] ] # needs to match DataflowEndpointConfig name
            Address:
              Name: !GetAtt ReceiverInstanceNetworkInterface.PrimaryPrivateIpAddress
              Port: 55888
          SecurityDetails:
            SecurityGroupIds:
              - Ref: "DataflowEndpointSecurityGroup"
            SubnetIds:
              - !Ref ReceiverSubnet
            RoleArn: !GetAtt DataDeliveryServiceRole.Arn

  # The security group for your EC2 instance.
  InstanceSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: AWS Ground Station receiver instance security group.
      VpcId: !Ref ReceiverVPC
      SecurityGroupIngress:
        # To allow SSH access to the instance, add another rule allowing tcp port 22 from your CidrIp
        - IpProtocol: udp
          FromPort: 55888
          ToPort: 55888
          SourceSecurityGroupId: !Ref DataflowEndpointSecurityGroup
          Description: "AWS Ground Station Downlink Stream"

  # The security group that the ENI created by AWS Ground Station belongs to.
  DataflowEndpointSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Security Group for AWS Ground Station registration of Dataflow Endpoint Groups
      VpcId: !Ref ReceiverVPC
      SecurityGroupEgress:
        - IpProtocol: udp
          FromPort: 55888
          ToPort: 55888
          CidrIp: 10.0.0.0/8
          Description: "AWS Ground Station Downlink Stream To 10/8"
        - IpProtocol: udp
          FromPort: 55888
          ToPort: 55888
          CidrIp: 172.16.0.0/12
          Description: "AWS Ground Station Downlink Stream To 172.16/12"
        - IpProtocol: udp
          FromPort: 55888
          ToPort: 55888
          CidrIp: 192.168.0.0/16
          Description: "AWS Ground Station Downlink Stream To 192.168/16"

  # The placement group in which your EC2 instance is placed.
  ClusterPlacementGroup:
    Type: AWS::EC2::PlacementGroup
    Properties:
      Strategy: cluster

  ReceiverVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: "10.0.0.0/16"
      Tags:
        - Key: "Name"
          Value: "AWS Ground Station - PBS to dataflow endpoint Example VPC"
        - Key: "Description"
          Value: "VPC for EC2 instance receiving AWS Ground Station data"

  ReceiverSubnet:
    Type: AWS::EC2::Subnet
    Properties:
      # Ensure your CidrBlock will always have at least one available IP address per dataflow endpoint.
      # See https://docs.aws.amazon.com/vpc/latest/userguide/subnet-sizing.html for subent sizing guidelines.
      CidrBlock: "10.0.0.0/24"
      Tags:
        - Key: "Name"
          Value: "AWS Ground Station - PBS to dataflow endpoint Example Subnet"
        - Key: "Description"
          Value: "Subnet for EC2 instance receiving AWS Ground Station data"
      VpcId: !Ref ReceiverVPC

  # An ENI providing a fixed IP address for AWS Ground Station to connect to.
  ReceiverInstanceNetworkInterface:
    Type: AWS::EC2::NetworkInterface
    Properties:
      Description: Floating network interface providing a fixed IP address for AWS Ground Station to connect to.
      GroupSet:
        - !Ref InstanceSecurityGroup
      SubnetId: !Ref ReceiverSubnet

  # Attach the ENI to the EC2 instance.
  ReceiverInstanceInterfaceAttachment:
    Type: AWS::EC2::NetworkInterfaceAttachment
    Properties:
      DeleteOnTermination: false
      DeviceIndex: "1"
      InstanceId: !Ref ReceiverInstance
      NetworkInterfaceId: !Ref ReceiverInstanceNetworkInterface
```

 此外，您還需要建立適當的政策和角色，以允許 在帳戶中 AWS Ground Station 建立彈性網路界面 (ENI)。

```
  # AWS Ground Station assumes this role to create/delete ENIs in your account in order to stream data.
  DataDeliveryServiceRole:
    Type: AWS::IAM::Role
    Properties:
      Policies:
        - PolicyDocument:
            Statement:
              - Action:
                  - ec2:CreateNetworkInterface
                  - ec2:DeleteNetworkInterface
                  - ec2:CreateNetworkInterfacePermission
                  - ec2:DeleteNetworkInterfacePermission
                  - ec2:DescribeSubnets
                  - ec2:DescribeVpcs
                  - ec2:DescribeSecurityGroups
                Effect: Allow
                Resource: '*'
            Version: '2012-10-17'
          PolicyName: DataDeliveryServicePolicy
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service:
              - groundstation.amazonaws.com
            Action:
            - sts:AssumeRole

  # The EC2 instance assumes this role.
  InstanceRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: "Allow"
            Principal:
              Service:
                - "ec2.amazonaws.com"
            Action:
              - "sts:AssumeRole"
      Path: "/"
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
        - arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role
        - arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy
        - arn:aws:iam::aws:policy/service-role/AmazonEC2RoleforSSM

  # The instance profile for your EC2 instance.
  GeneralInstanceProfile:
    Type: AWS::IAM::InstanceProfile
    Properties:
      Roles:
        - !Ref InstanceRole
```

## AWS Ground Station 組態
<a name="examples.pbs-dataflow-endpoint.configs"></a>

 本節代表[建立組態](getting-started.step3.md)入門。

 您需要使用*追蹤組態*，才能在 上使用自動追蹤來設定偏好設定。選擇 *PREFERRED* 作為自動追蹤可以改善訊號品質，但由於足夠的 JPSS-1 暫時性品質，因此不需要滿足訊號品質。

```
  TrackingConfig:
    Type: AWS::GroundStation::Config
    Properties:
      Name: "JPSS Tracking Config"
      ConfigData:
        TrackingConfig:
          Autotrack: "PREFERRED"
```

 根據通訊路徑，您需要定義*天線下行*組態來代表衛星部分，以及定義端點詳細資訊*之資料流程端點群組的資料流程端點*組態。

```
  # The AWS Ground Station Antenna Downlink Config that defines the frequency spectrum used to
  # downlink data from your satellite.
  SnppJpssDownlinkDigIfAntennaConfig:
    Type: AWS::GroundStation::Config
    Properties:
      Name: "SNPP JPSS Downlink DigIF Antenna Config"
      ConfigData:
        AntennaDownlinkConfig:
          SpectrumConfig:
            Bandwidth:
              Units: "MHz"
              Value: 30
            CenterFrequency:
              Units: "MHz"
              Value: 7812
            Polarization: "RIGHT_HAND"

  # The AWS Ground Station Dataflow Endpoint Config that defines the endpoint used to downlink data
  # from your satellite.
  DownlinkDigIfEndpointConfig:
    Type: AWS::GroundStation::Config
    Properties:
      Name: "Aqua SNPP JPSS Downlink DigIF Endpoint Config"
      ConfigData:
        DataflowEndpointConfig:
          DataflowEndpointName: !Join [ "-" , [ !Ref "AWS::StackName" , "Downlink" ] ]
          DataflowEndpointRegion: !Ref AWS::Region
```

## AWS Ground Station 任務描述檔
<a name="examples.pbs-dataflow-endpoint.mission-profile"></a>

 本節代表[建立任務描述檔](getting-started.step4.md)入門。

 現在您已有相關聯的組態，您可以使用它們來建構資料流程。您將使用其餘參數的預設值。

```
  # The AWS Ground Station Mission Profile that groups the above configurations to define how to
  # uplink and downlink data to your satellite.
  SnppJpssMissionProfile:
    Type: AWS::GroundStation::MissionProfile
    Properties:
      Name: "37849 SNPP And 43013 JPSS"
      ContactPrePassDurationSeconds: 120
      ContactPostPassDurationSeconds: 60
      MinimumViableContactDurationSeconds: 180
      TrackingConfigArn: !Ref TrackingConfig
      DataflowEdges:
        - Source: !Ref SnppJpssDownlinkDigIfAntennaConfig
          Destination: !Ref DownlinkDigIfEndpointConfig
```

## 將它放在一起
<a name="examples.pbs-dataflow-endpoint.putting-it-together"></a>

 使用上述資源，您現在可以排程 JPSS-1 聯絡人，以便從任何已加入的 同步資料交付 AWS Ground Station [AWS Ground Station 位置](aws-ground-station-antenna-locations.md)。

 以下是完整的 CloudFormation 範本，其中包含本節所述的所有資源，合併為可以直接使用的單一範本 CloudFormation。

 名為 的 CloudFormation 範本`AquaSnppJpssTerraDigIF.yml`旨在讓您快速存取，以開始接收 Aqua、SNPP、JPSS-1/NOAA-20 和 Terra 衛星的數位化中繼頻率 (DigIF) 資料。它包含 Amazon EC2 執行個體和接收原始 DigIF 直接廣播資料所需的 CloudFormation 資源。

 如果 Aqua、SNPP、JPSS-1/NOAA-20 和 Terra 未加入您的帳戶，請參閱 [加入衛星](getting-started.step1.md)。

**注意**  
 您可以使用有效的 AWS 登入資料存取客戶加入 Amazon S3 儲存貯體來存取範本。以下連結使用區域 Amazon S3 儲存貯體。變更`us-west-2`區域碼以代表您要在其中建立 CloudFormation 堆疊的對應區域。  
 此外，下列指示使用 YAML。但是，範本同時提供 YAML 和 JSON 格式。若要使用 JSON，請在下載範本`.json`時將`.yml`副檔名取代為 。

 若要使用 下載範本 AWS CLI，請使用下列命令：

```
aws s3 cp s3://groundstation-cloudformation-templates-us-west-2/AquaSnppJpssTerraDigIF.yml .
```

 您可以在瀏覽器中瀏覽至以下 URL，以在主控台中檢視和下載範本：

```
https://s3.console.aws.amazon.com/s3/object/groundstation-cloudformation-templates-us-west-2/AquaSnppJpssTerraDigIF.yml
```

 您可以使用以下連結直接在 CloudFormation 中指定範本：

```
https://groundstation-cloudformation-templates-us-west-2.s3.us-west-2.amazonaws.com/AquaSnppJpssTerraDigIF.yml
```

**範本定義了哪些其他資源？**

`AquaSnppJpssTerraDigIF` 範本包含下列其他資源：
+ （選用） **CloudWatch Event Triggers** - AWS Lambda 使用聯絡 AWS Ground Station 前後由 傳送的 CloudWatch Events 觸發的函數。 AWS Lambda 函數將啟動並選擇性地停止您的接收者執行個體。
+ （選用） **聯絡的 EC2 驗證** - 使用 Lambda 為具有 SNS 通知的聯絡設定 Amazon EC2 執行個體驗證系統的選項 (SNS)。請務必注意，這可能會產生費用，這取決於您目前的用量。
+  **Ground Station Amazon Machine Image Retrieval Lambda** - 選擇執行個體中安裝的軟體以及您選擇的 AMI 的選項。軟體選項包括 `DDX 2.6.2 Only`和 `DDX 2.6.2 with qRadio 3.6.0`。隨著其他軟體更新和功能發佈，這些選項將繼續擴展。
+  **其他任務描述檔** - 其他公有廣播衛星 (Aqua、SNPP 和 Terra) 的任務描述檔。
+  **其他天線下行組態** - 其他公有廣播衛星 (Aqua、SNPP 和 Terra) 的天線下行組態。

 在此範本中，衛星的值和參數已經產生。這些參數可讓您輕鬆地 AWS Ground Station 立即與這些衛星搭配使用。您不需要設定自己的值，即可在使用此範本 AWS Ground Station 時使用 。但是，您可以自訂這些值，讓範本適用於您的使用案例。

**我可以在什麼地方接收我的資料？**

 資料流程端點群組的設定，是使用以範本的一部分建立的接收器執行個體網路界面。接收者執行個體使用資料流程端點應用程式，在資料流程端點定義的連接埠 AWS Ground Station 上接收來自 的資料串流。接收到以後，資料就可以透過 UDP 連接埠 50000 在接收器執行個體的回送介面卡上使用。如需設定資料流程端點群組的詳細資訊，請參閱 [ AWS::GroundStation::DataflowEndpointGroup](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-groundstation-dataflowendpointgroup.html)。