Linux Networking
Mar 18, 2002
Yongguang Zhang
Linux Networking
- Setting up networks with UML
- Structure of Linux Networking Code
Virtual Networks with UML
- UML can simulate an Ethernet segment with an IP multicast group
- UML: send Ethernet packet to the group
- UML: listen from the group
UML Networking: Step 1
- Adding a network device to UML
- Specify a virtual Ethernet device in UML command line
- Pick an Ethernet segment for this device (i.e. pick a multicast address)
- UML command line syntax
- eth0=mcast,EthernetAddr,multicastAddr,port,ttl
- Example:
- ./linux ubd0=root_fs_1 eth0=mcast,,224.1.0.0,,
- To add an eth0 device on Ethernet segment 224.1.0.0
UML Networking: Step 2
- Configure the network interface within UML
- Once you run UML with the eth0= argument, you get an eth0 device: ifconfig -a
- Now, you need to know a little bit about Linux networking and network administration
- Assign it an IP address
- ifconfig eth0 192.168.1.1 up
- To check:
- ifconfig -a
- route -n
- ping 192.168.1.1
UML Networking: Step 3
- Start another UML host with the same virtual network
- In the same Linux host or another host in the same physical network (e.g, both in UTCS net)
- ./linux ubd0=root_fs_2 eth0=mcast,,224.1.0.0,,
- Make sure you use the same multicast address & port!
- Within this UML, configure the network with a different IP address, but in the same subnet
- ifconfig eth0 192.168.1.2 up
UML Networking: Step 4
- Now, you have two UML hosts connected by a virtual network
- In first host: try ping 192.168.1.2
UML Networking:
- Pick your multicast address to avoid conflict with others
- I suggest: 224.1.ab.cd, where abcd is the last 4 digits of your student-ID
More Complex Example
- Build your own network (with multiple subnets)
- Remember to use different multicast address (one per subnet)
- Set up your own routing
Networking Stack
Networking Stack Components
- Network device driver
- Manage hardware (network interface card)
- Deal with data-link functions (such as MAC)
- Can be virtual (e.g., ppp0)
- Files: drivers/net/
- Network/Transport parts
- All different network+transport protocols
- One directory per type: net/ (e.g, net/ipv4/ )
Input Chain and Output Chain
Data Structure: sk_buff
- Used in all network stack
- Carry the data (payload) for going through the input/output chain
- Minimize copying: only twice (from user space to kernel space, and from/to the network hardware)
- Definition:
- include/linux/skbuff.h
- struct skbuff
Socket Interface
- BSD socket
- struct socket (include/linux/net.h)
- INET socket
- struct sock (include/net/sock.h)
- Code
- net/socket.c
- Start exploring from sys_socket(), sys_sendto()
Next Lecture
- Continue with Linux networking
- Network device driver
- Actual IP input/output modules
© 2002 Yongguang Zhang