作者头像

CentOS 7 搭建 FSD 连飞平台

零、前言

最近认识了一些玩模拟飞行的朋友,我们想自己搞一个模拟连飞平台,支持微软模拟飞行2020,x-plane11等跨平台连飞。

一、环境信息

参考链接:
https://github.com/nhfy1w/
(已Fork到我自己的github上,因为这套代码已经5年没有更新了,我在原有代码基础上进行了小修改。)

二、操作步骤

1)升级cmake

参考教程:CentOS 7 cmake升级

2)下载fsd源码并编译

yum install -y git gcc gcc-c++
cd $HOME
git clone https://github.com/immoke/fsd-server.git

cd $HOME/fsd-server/fsd
mkdir -p $HOME/fsd-server/fsd/build

cmake ..
make

3)编译文件及使用

# 继续上文
mkdir -p /opt/fsd/
mv $HOME/fsd-server/fsd/fsd /opt/fsd
mv $HOME/fsd-server/unix/* /opt/fsd
cd /opt/fsd

cert.txt初始化

sed -i "/password/d" /opt/fsd/cert.txt
sed -i "/122222/d" /opt/fsd/cert.txt

fsd.conf初始化

adminmail='imoke@mmoke.com'
servername="iMoke FSD server"
serverhostname='fsd.mmoke.com'
adminpassword='adminpassword'
serverlocation='ZBAA'
weatherserver='tgftp.nws.noaa.gov'

sed -i "s/email=nobody@nowhere.com/email=$adminmail/" /opt/fsd/fsd.conf
sed -i "s/name=FSFDT FSD Unix Windows server/name=$servername/" /opt/fsd/fsd.conf

sed -i "s/hostname=localhost/hostname=$serverhostname/" /opt/fsd/fsd.conf
sed -i "s/password=disable/password=$adminpassword/" /opt/fsd/fsd.conf
sed -i "s/location=Nowhere/location=$serverlocation/" /opt/fsd/fsd.conf
sed -i "s/server=weather.noaa.gov/server=$weatherserver/" /opt/fsd/fsd.conf

fsd.sh调整

sed -i "s/USER=fsd/USER=$(whoami)/" /opt/fsd/fsd.sh
sed -i "s/DIR=\/home\/fsd\/fsd/DIR=\/opt\/fsd/" /opt/fsd/fsd.sh

4)启动fsd服务器

chmod +x /opt/fsd/fsd.sh
./fsd.sh start

5)开通防火墙

# 6809 swift连飞客户端端口
firewall-cmd --add-port=6809/tcp --permanent
# 3010 是管理员的,协议是telnet,无需开通防火墙
# 3011 (server interface) 可能是信息输出的,目前不清楚干什么用的。

三、测试效果

管理员命令

以下内容部分摘自 adminhelp.txt,按照 iMoke 使用习惯前后顺序有调整。

安装telnet

yum install -y telnet
telnet localhost 3010

pwd - 认证密码

# 先认证 pwd <管理员密码> 之前配置的adminpassword
FSD> pwd adminpassword
Password correct.

help - 帮助命令

FSD> help
Could not open help file 'help.txt'

servers:SERVER OVERVIEW(1)

Syntax:
   servers []

This command will show an overview of the servers in the network.
When the optional , is specified, only servers with  in their ident code or in their name will be shown.

The following fields are shown:
ID     : The server ID.
Host   : The hostname of the server.
Email  : The maintainer's email address.
Fl     : The flags associated with the server. M = Metar capable server, S = silent server, not for clients.
Hops   : The amount of hops needed to reach the host.
Lag    : The amount of seconds currently needed for a round trip.
Name   : The description of a server.

# 此命令将显示网络中服务器的概述。
# 当指定可选的时,将只显示标识代码或名称中有的服务器。

# 显示以下字段:
# ID   : 服务器ID。
# Host : 服务器的主机名。
# Email: 维护人员的电子邮件地址。
# Fl   : 与服务器关联的标志。M = 支持Metar的服务器, S = 静默服务器,不适用于客户端。
# Hops : 到达主机所需的跳数。
# Lag   : 往返行程当前所需的秒数。
# Name : 服务器的描述。
FSD> servers
ID         Host                      Fl Hops Lag  Name
-------------------------------------------------------------
FSD        fsd.mmoke.com             M-   -1  -1  iMoke FSD server

servers2:SERVER OVERVIEW(2)

Syntax:
   servers2 []

This command will show an overview of the servers in the network.
When the optional , is specified, only servers with  in their ident code or in their name will be shown.

The following fields are shown:
ID      : The server ID.
Version : The server version.
Email   : The maintainer's email address.
Location: The location of the server

# 此命令将显示网络中服务器的概述。
# 当指定可选的时,将只显示标识代码或名称中有的服务器。

# 显示以下字段:
# ID    : 服务器ID。
# Version : 服务器的版本
# Email: 维护人员的电子邮件地址。
# Location: 服务器的位置。
FSD> servers2
ID         Version     Mail                 Location
-------------------------------------------------------------
FSD        V3.000 d9   imoke@mmoke.com      ZBAA

connect:CONNECT TO A SERVER

Syntax:
   connect [ []]

Will connect the local server to the specified server. Without arguments, the command will show the current connections. For every connection some information is shown:
fd    : The file descriptor that can be used for "disconnect"
Out-Q : The amount of bytes waiting to be sent on this connection.
In-Q  : The amount of bytes waiting to be processed from this connection.
Feed  : The throughput of this connection is bytes/second (last 10 min.).
Peer  : The peer of this connection.

# 将本地服务器连接到指定的服务器。如果没有参数,该命令将显示当前连接。对于每个连接,都会显示一些信息:
# fd:可以用于"断开连接"的文件描述符
# Out-Q:此连接上等待发送的字节数。
# In-Q:等待从此连接处理的字节数。
# 馈送:此连接的吞吐量为字节/秒(最后10分钟)。
# 对等端:此连接的对等端。

disconnect:DISCONNECT FROM A SERVER

Syntax:
   disconnect 

Will disconnect the indicated server connection. Use 'connect' to get a list of active server connections.
# 将断开指示的服务器连接。使用"connect"获取活动服务器连接的列表。

ping:PING A NETWORK SERVER

Syntax:
   ping 

This command sends a PING request to the specified server. When this servers receives the ping, it will send it back to the originating host.
When a reply has been received, the reply time will be shown.

# 此命令向指定的服务器发送PING请求。当该服务器接收到ping时,它将把它发送回始发主机。
# 收到回复后,将显示回复时间。

route:SHOW ROUTING TABLES

Syntax
   route []

Will show the internal routing table to all servers, or only to the servers which have the  in their ident.
The routing table is configured automatically and does not need human intervention.
# 将向所有服务器显示内部路由表,或仅向其标识中包含的服务器显示。
# 路由表是自动配置的,不需要人工干预。

say:SEND A MESSAGE TO A CLIENT

Syntax
   say  

This command sends a message to a client.
 can be either:
- A broadcast address (* = all clients, *P = all pilots, *A = all ATC)
- A callsign, like "KL348"
- A frequency address, like "@11240"

# 此命令向客户端发送消息。
# 可以是:
# -广播地址(*=所有客户端,*P=所有飞行员,*A=所有ATC)
# -呼号,比如"KL348"
# -频率地址,如"@11240"

clients:CLIENTS OVERVIEW

Syntax
   clients []

This command will show a list of all clients matching the given callsign.
If only one client matches the callsign, a detailed overview of this client is shown.

# 此命令将显示与给定呼号匹配的所有客户端的列表。
# 如果只有一个客户端与呼号匹配,则会显示此客户端的详细概述。

distance:CALCULATE DISTANCE

Syntax
   distance  

This command can be used to calculate the distance between two clients.
It only works if both client have reported their positions. The distance will be shown in Nautical Miles.

# 此命令可用于计算两个客户端之间的距离。
# 只有当两个客户都报告了他们的位置时,它才有效。距离将以海里为单位显示。

cert:CERTIFICATE CONTROL

Syntax
   cert
   cert add    
   cert delete  
   cert modify   

This command will add/delete or modify the certificate  in the network.
 can either be 'P' for a Pilot certificate or 'A' for an ATC certificate.
The maximum level of this certificate is .
 can be one of:

     Observer              Instructor1
     Student1              Instructor2
     Student2              Instructor3
     Student3              Supervisor
     Controller1           Administrator
     Controller2
     Controller3
# 此命令将添加/删除或修改网络中的权限。
# 可以是飞行员权限的"P",也可以是ATC权限的"A"。
# 此权限的最高级别为<级别>。
# 可以是以下之一:

cert:SHOW CERTIFICATES

Syntax:
   cert []

This command will show an overview of the current certificates. If  is specified, only certificates which have  in their code will be shown.
# 此命令将显示当前权限的概述。如果指定了,则只显示代码中包含的权限。

time:SHOW CURRENT TIME

Syntax:
   time

This command gives the current time. The local time will be shown, as well as the UTC time.
# 此命令提供当前时间。将显示当地时间以及UTC时间。
FSD> time
12:45:44 local
04:45:44 UTC

range:SHOW COM RANGE

Syntax:
   range 

This command shows the communication range of the client with  in NM.
# 此命令以NM显示客户端与的通信范围。

weather:SEND WEATHER REQUEST

Syntax:
   weather 

This command will send out a weather request to the nearest METAR capable server. If no such server exists in the network, the command will fail.
 is the name of the requested weather profile. Usually this is an ICAO station code like KJFK, but it can also be a hand made profile.

Note that because the server has to send out a request, the prompt will be returned immediately. When a response has been received, it will be displayed.

# 此命令将向最近的METAR服务器发送天气请求。如果网络中不存在这样的服务器,则该命令将失败。
# 是请求的天气配置文件的名称。通常这是像KJFK一样的国际民航组织站点代码,但也可以是手工制作的配置文件。
# 请注意,由于服务器必须发出请求,因此会立即返回提示。当收到响应时,将显示该响应。

metar:SEND METAR REQUEST

Syntax:
   metar 

This command will send out a weather request to the nearest METAR capable server. If no such server exists in the network, the command will fail.
 is the name of the requested weather profile. Usually this is an ICAO station code like KJFK, but it can also be a hand made profile.

Note that because the server has to send out a request, the prompt will be returned immediately. When a response has been received, it will be displayed.

# 此命令将向最近的METAR服务器发送天气请求。如果网络中不存在这样的服务器,则该命令将失败。
# 是请求的天气配置文件的名称。通常这是像KJFK一样的国际民航组织站点代码,但也可以是手工制作的配置文件。
# 请注意,由于服务器必须发出请求,因此会立即返回提示。当收到响应时,将显示该响应。

log:ACCESS SYSTEM LOGS

Syntax:
   log (show|delete)  []

This command will show or delete log messages. If  is specified, only  messages will be shown/deleted.

The importance of the log messages can be specified with the  option.  can be one if:

0  Critical messages       3  Warning messages
1  Alert messages          4  Info messages
2  Error messages          5  Debug messages

# 此命令将显示或删除日志消息。如果指定了,则只显示/删除消息。
# 可以使用选项指定日志消息的重要性可以是如下选项:

stat:SHOW SERVER STATISTICS

Syntax:
   stat []

This command will show the server statistical entries. When  is specified, only the entries with  in their name will be shown.

# 此命令将显示服务器统计条目。当指定时,将只显示名称中包含的条目。

wall:BROADCAST MESSAGE

Syntax:
   wall 

This command will send the text  to all clients connected to the local server.

# 此命令将向连接到本地服务器的所有客户端发送文本

delguard:DELETE GUARD CONNECTIONS

Syntax:
   delguard

This command will delete all guard connections (pending connections).

# 此命令将删除所有地面的用户连接(准备连接的用户)。

wp:CONTROL WEATHER PROFILES

Syntax:
   wp show []
   wp create 
   wp delete 
   wp activate 
   wp set  =

Examples:
   wp create eham
   wp set eham visibility 6
   wp set eham pressure 2110
   wp set eham clouds.1.floor 5000
   wp set eham clouds.1.ceiling 9000
   wp set eham clouds.1.coverage 6
   wp set eham winds.1.floor 0
   wp set eham winds.1.ceiling 250
   wp set eham winds.1.speed 11
   wp set eham winds.1.direction 240
   wp set eham temperature.1.temperature 12
   wp activate eham

pos:SET LOCAL POSITION

Syntax:
   pos  

This command is used to set the local position for the weather system.
The command 'weather' uses this position to calculate the upper winds.

# 此命令用于设置天气系统的本地位置。
# "weather"命令使用这个位置来计算上层风。

refreshmetar:DOWNLOAD LATEST METAR

Syntax:
   refreshmetar

This command downloads the latest weather reports and places these in the file 'metar.txt'. This command is not available if the metar source was set to 'network'.

# 此命令下载最新的天气报告并将其放在文件"metar.txt"中。如果metar源设置为"network",则此命令不可用。
说明:
# noaa.gov官方文档:https://www.weather.gov/tg/anonymous
# 由于默认地址改变,目前此功能暂时不可用