AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 458099
Accepted
ibrahim
ibrahim
Asked: 2012-12-15 06:35:05 +0800 CST2012-12-15 06:35:05 +0800 CST 2012-12-15 06:35:05 +0800 CST

使用多进程或单进程运行 dhcrelay 有什么区别吗?

  • 772

我想问一下dhcreay的运行机制。我们可以用两个命令运行 dhcrelay,然后它将作为 2 个进程运行

dhcrelay -i eth3 172.16.17.3
dhcrelay -i eth1 172.16.17.5

#ps ax | grep dhcre
26464 ?        Ss     0:00 /usr/sbin/dhcrelay -i eth3 172.16.17.3
26465 ?        Ss     0:00 /usr/sbin/dhcrelay -i eth1 172.16.17.5

或者使用一个命令,换句话说,单个进程

dhcrelay -i eth3 -i eth1 172.16.17.3 172.16.17.5

#ps ax | grep dhcre
28127 ?        Ss     0:00 /usr/sbin/dhcrelay -i eth1 -i eth3 172.16.17.3 172.16.17.5

我想知道这两种方式除了进程计数之外是否有任何技术差异?

linux
  • 1 1 个回答
  • 677 Views

1 个回答

  • Voted
  1. Best Answer
    slm
    2013-01-25T00:09:56+08:002013-01-25T00:09:56+08:00

    在查看源代码时,有几件事跳出来,似乎会受到运行单个命令和多个命令的影响。

    首先这条评论在dispatch.c:

    /*
     * Wait for packets to come in using poll().  When a packet comes in,
     * call receive_packet to receive the packet and possibly strip hardware
     * addressing information from it, and then call through the
     * bootp_packet_handler hook to try to do something with it.
     */
    

    它似乎dhcrelay.c使用了轮询架构。在轮询其中一个接口(例如:-i eth0或-i eth1 )时,这看起来会使用超时(基于时间)。

    这似乎表明在轮询另一个接口时可能会阻塞一个接口。

    另一个片段,这次在dispatch()函数内,它正在轮询指定接口之一:

    /* Wait for a packet or a timeout... XXX */
    count = poll(fds, nfds, to_msec);
    

    在上面的轮询函数超时或接收到数据包后,dhcrelay移动到“下一个”接口:

        /* Get the current time... */
        time(&cur_time);
    
        i = 0;
        for (l = protocols; l; l = l->next) {
          struct interface_info *ip = l->local;
    
          if ((fds[i].revents & (POLLIN | POLLHUP))) {
            fds[i].revents = 0;
            if (ip && (l->handler != got_one ||
                !ip->dead))
              (*(l->handler))(l);
            if (interfaces_invalidated)
              break;
          }
          i++;
        }
        interfaces_invalidated = 0;
      } while (1);
    

    请注意,整个dispatch包含一个while(1)循环。

    那么,这意味着什么?

    我想说的是,如果您的网络流量很大且有很多主机并且您的 DHCP 租约相对较短,那么您可能需要考虑运行 2 个 dchrelay 实例。

    但是,如果您的网络相对较小并且 DHCP 租约超时时间相对较长,那么运行单个实例应该没问题。

    一些额外的事情要考虑

    • 运行 2 个实例允许您为每个实例维护单独的日志文件。
    • 运行 2 个实例允许一个中继器在不影响另一个的情况下重新启动。
    • 0

相关问题

  • Linux 主机到主机迁移

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 在 RHEL4 上修改 CUPS 中的现有打印机设置

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve