# Networking

This page should help solving common network/related problems,
a-la `I can't connect, please help`.

## Common problems

1. `device_db.py` has misleading `core_addr` address.
2. PC and the crate are in different subnets. They should be in the same network. Also you may want to directly attach the Kasli to the PC.
3. Network restrictions/problems on your router, either by IP, MAC, protocols or anything else.
4. Wrong configuration of the Kasli. Change IP or MAC address to correspond your network. For ARTIQ-8, add 
   network mask to the `ip` setting on Kasli, like `192.168.1.75/24`.
5. Incompatible Ethernet cables/SFP RJ45. Try different cables and SFP adapters. 
   We usually test them with CAT6 cables, but lower categories should be supported too.
6. SFP or Ethernet are not pushed til the end.
7. Some weird bugs in Vivado, leading to not working SFP on certain combinations of builds and Kaslis (very rare)
8. Running configured for external reference Kasli without external reference clock signal 
9. Using legacy firmware with newer hardware. ARTIQ-6 doesn't support Kasli v2.0.2

## Ways to diagnose

1. `ping` the device. If destination is unreachable, than it is either didn't connect to the network
    or connected to different address. If the packets just do not respond then it is not as clear, we cannot know all the truth.
2. See the SFP0 LED
3. See the ERR LED
4. [UART logs](uart_logs.md)
5. `nmap` and `arp` to scan your network to help your Kasli get discovered. May be restricted in your network.
6. Directly connect your Kasli to the PC via Ethernet and set up networking on the PC: `ip addr change 192.168.1.0/24 dev eth0`
7. Become a router and capture all the packets when your Kasli tries to connect to the network.


## Direct connection

Sometimes it is neccessary to connect your Kasli/Kasli-SoC (Carrier) directly to the PC/NUC. For example, your Kasli-SoC
may be configured for the wrong network. In order to do this, you will just need to:
1. Connect Carrier via Ethernet directly to the NUC/PC
2. Set the network settings (example for default 192.168.1.75 Carrier setting):
    ```
    IPv4 method: Manual
    Address: 192.168.1.0
    Netmask: 255.255.255.0
    Gateway: 192.168.1.0
    DNS, Routes - Auto
    ```
   ![gnome_direct_conn_settings.png](../img/gnome_direct_conn_settings.png)