Skip to content

ch8 mget example not unicast #7

Open

Description

@cmdrtomalak

Hi Tim,

It seems like there are two problems with the ch8-mget example, first the default version of smoltcp 0.5 no longer compiles, I updated to 0.6 and that worked. The second is the example seems to have issues with ethernet not being unicast

❯ cargo run http://www.rustinaction.com/ tap-rust -s 8.8.8.8
warning: unused manifest key: profile.release.codegen_units
warning: trait objects without an explicit `dyn` are deprecated
  --> src/dns.rs:40:101
   |
40 | pub fn resolve(dns_server_address: &str, domain_name: &str) -> Result<Option<std::net::IpAddr>, Box<Error>> {
   |
                            ^^^^^ help: use `dyn`: `dyn Error`
   |
   = note: `#[warn(bare_trait_objects)]` on by default

    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `/home/user/build-artifacts/debug/mget 'http://www.rustinaction.com/' tap-rust -s 8.8.8.8`
thread 'main' panicked at 'Ethernet address f7-f0-a7-28-e7-57 is not unicast', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/smoltcp-0.6.0/src/iface/ethernet.rs:705:13

Activity

  1. timClicks commented on Jul 12, 2020

    @timClicks
    Contributor

    I'll need to spend some time addressing these issues. This may involve re-working the examples somewhat.

  2. jiayihu commented on Aug 12, 2020

    @jiayihu

    The least significant bit of the first octate should be zero to 0, not 1, for be considered as unicast. I managed to do so in this way:

    octets[0] |= 0b_0000_0010; // Set bit for local address
    octets[0] &= 0b_1111_1110; // Clear bit for unicast
    

    Unfortunately, running the example still results in error:

    Poll error: Unrecognized
    Connecting
    Poll error: Unrecognized
    

    The error is from these lines:

    match iface.poll(&mut sockets, timestamp) {
                Ok(_) => {}
                Err(e) => {
                    eprintln!("Poll error: {:?}", e);
                }
    }

    The error seems to be caused by unknown packets in the socket, but I have no idea what is the cause since I don't know much how to debug it. I tried running the code with cargo run -- http://www.rustinaction.com/ tap-rust.

    In case, full source code of my attempt is available here: https://github.com/jiayihu/lab/blob/master/rust/mget-tcp/src/http.rs but it should be almost identical to the book

  3. mgiles commented on Nov 14, 2020

    @mgiles

    I don't think those errors from poll are a problem. From the poll documentation:

    This method will routinely return errors in response to normal network activity as well as certain boundary conditions such as buffer exhaustion. These errors are provided as an aid for troubleshooting, and are meant to be logged and ignored.

    As a special case, Err(Error::Unrecognized) is returned in response to packets containing any unsupported protocol, option, or form, which is a very common occurrence and on a production system it should not even be logged.

  4. jiayihu commented on Nov 14, 2020

    @jiayihu

    @mgiles You're right, my mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions