Skip to content

Commit 55b5c2a

Browse files
author
Amanda Butler
authored
Edit Layer3IP.md
Edit updated file.
1 parent 882b59a commit 55b5c2a

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

docs/porting/connectivity/Layer3IP.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ The L3IP interface abstracts network stacks and drivers and easily permits multi
2525

2626
The first step in the port is to create a driver class for the cellular device that you can instantiate to control your device. You must derive this class from the `L3IP` class. A network stack (or test framework) uses this API to control your driver.
2727

28-
2928
Class L3IP is entirely abstract - you need to implement about a dozen calls to activate the driver, send and receive packets and perform other control and information functions.
3029

3130
There are also callback registration functions for upcalls from the driver - the stack can register callback functions for packet reception and link status changes.
@@ -49,33 +48,35 @@ Steps that the network stack uses to power the L3IP driver:
4948
1. The network stack might query for the memory buffer align preference from the driver.
5049
1. The network stack is not required to use the alignment for the memory buffers on link out.
5150

52-
### The IP Layer3 memory manager
51+
### The IP Layer3 memory manager
5352

54-
The IP Layer3 memory manager class provides an abstracted memory interface toward memory modules used in different network stacks. For the send and receive paths, data is transferred in memory buffers controlled through an `NetStackMemoryManager` object. The network stack provides L3IP driver with reference to the memory manager before L3IP device powers up.
53+
The IP Layer3 memory manager class provides an abstracted memory interface toward memory modules used in different network stacks. For the send and receive paths, data is transferred in memory buffers controlled through a `NetStackMemoryManager` object. The network stack provides the L3IP driver with reference to the memory manager before the L3IP device powers up.
5554

5655
Memory buffer chains store the data on the memory interface. The data passed in either direction either may be contiguous (a single-buffer chain) or may consist of multiple buffers. You can chain the buffers using a singly linked list.
5756

5857
On the output call, the L3IP driver is given ownership of a buffer chain - it must free the chain when it has finished with the data. The data may or may not be contiguous. A driver can express alignment preferences for outgoing data, but the network stack is not required to meet these preferences, so a driver relying on alignment may need a slow path that copies data into an aligned (or contiguous) buffer.
5958

6059
For reception, the L3IP driver must allocate memory from the `NetStackMemoryManager` to store the received packets - this is then passed to the link input callback, which frees it. By preference, you should allocate this memory using the pool, but if contiguous memory is necessary, you can allocate it from the heap.
6160

62-
### IP Layer3 Interface
61+
### IP Layer3 interface
6362

6463
All Mbed OS connectivity devices should provide an Mbed OS `NetworkInterface` implementation.
6564

66-
To create and use an IP Layer3 interface, you need the `L3IPInterface` and `L3IP` classes. Moreover you need an L3IP derived driver class for specific target device. Otherwise the linker error `undefined reference to L3IP::get_default_instance()` stops build process.
65+
To create and use an IP Layer3 interface, you need the `L3IPInterface` and `L3IP` classes. Moreover, you need an L3IP derived driver class for the specific target device. Otherwise, the linker error `undefined reference to L3IP::get_default_instance()` stops the build process.
6766

6867
The user application code can create IP Layer3:
6968

69+
```
7070
NetworkInterface *l3interface;
7171
l3interface =new L3IPInterface(L3IP::get_default_instance(), OnboardNetworkStack::get_default_instance());
7272
l3interface->connect();
73+
```
7374

7475
This attaches the default network stack (usually LWIP - the other alternative is Nanostack) to the specified L3IP driver and provides all the `NetworkInterface` and `NetworkStack` APIs.
7576

7677
Below is an example of a target device driver class that needs to be implemented:
7778

78-
79+
```
7980
class Cellular_driver_L3IP : public L3IP {... }
8081
8182
Cellular_driver_L3IP &Cellular_driver_L3IP::get_instance()
@@ -89,34 +90,33 @@ Below is an example of a target device driver class that needs to be implemented
8990
{
9091
return Cellular_driver_L3IP::get_instance();
9192
}
93+
```
9294

93-
You can find this driver class example in the `mbed-os/TESTS/network/l3ip directory`.
95+
You can find this driver class example in the `mbed-os/TESTS/network/l3ip` directory.
9496

95-
### Being the default Interface
97+
### Being the default interface
9698

9799
In Mbed OS, targets may provide default network interfaces through an automated factory method. You can do this with the following call:
98100

99101
NetworkInterface::get_default_instance()
100102

101-
This way, you can create an ethernet, Wi-fi, mesh or cellular interface. The interface type depends on the `NETWORK_DEFAULT_INTERFACE_TYPE` value in the JSON configuration. Any interface you create this way is set as the default.
103+
This way, you can create an ethernet, Wi-Fi, mesh or cellular interface. The interface type depends on the `NETWORK_DEFAULT_INTERFACE_TYPE` value in the JSON configuration. Any interface you create this way is set as the default.
102104

103105
IP Layer3 Interface doesn't use `NetworkInterface::get_default_instance`, so it is not set as the default when you create it.
104106

105107
To set IP Layer3 as the default interface, you can use a new member of `set_as_default()`. This method is not limited to IP Layer3 and can set any network interface as default.
106-
107108

108109
### Cellular interfaces
109110

110111
As a cellular interface, a little more work is necessary - at a minimum, you need to implement the extra configuration calls in `L3IPInterface`. This is because the network stacks and IP Layer3 APIs only relate to the basic data path - they have no knowledge of any other configuration mechanisms and assume they are already set up.
111112

112113
To do this, create a C++ class that inherits from both `L3IPInterface` and a base class for the new IP Layer3 cellular interface solution. The `L3IPInterface` is a helper class that implements all the core `NetworkInterface` functionality for you. You then need to implement the extra configuration methods.
113114

114-
You don't usually directly expose the `L3IP` driver class of a cellular driver - it is not usually declared as `L3IP::get_default_instance`, but you would pass it to the constructor of your base `L3IPInterface`. This then makes it visible using the `getl3ip` method which provides access to L3IP device driver instance. Method `getl3ip`is a member of `L3IPInterface` class.
115-
115+
You don't usually directly expose the `L3IP` driver class of a cellular driver because it is not usually declared as `L3IP::get_default_instance`, but you would pass it to the constructor of your base `L3IPInterface`. This then makes it visible using the `getl3ip` method, which provides access to the L3IP device driver instance. The `getl3ip` method is a member of the `L3IPInterface` class.
116116

117117
### OnboardNetworkStack
118118

119-
You do not have to memorize the precise details of the `OnboardNetworkStack` API - it provides the mechanism to bind a driver to a stack and the APIs needed to implement a `NetworkInterface`, but `L3IPInterface` handles this.
119+
You do not have to memorize the precise details of the `OnboardNetworkStack` API. It provides the mechanism to bind a driver to a stack and the APIs needed to implement a `NetworkInterface`, but `L3IPInterface` handles this.
120120

121121
### Tuning memory allocations
122122

@@ -126,12 +126,10 @@ Depending on a driver's use of pool and heap memory and other factors, you might
126126

127127
The Mbed OS tree contains Greentea-based tests that exercise the L3IP API directly, along with more general socket tests.
128128

129-
For general Greentea information, please see the [Greentea](../tools/greentea-testing-applications.html) documentation.
129+
For Greentea information, please see the [Greentea](../tools/greentea-testing-applications.html) documentation.
130130

131131
Greentea L3IP tests are in the Mbed OS tree under the `TESTS/network/L3IP` directory.
132132

133+
The driver should also be tested with both network stacks available in Mbed OS because they use the driver somewhat differently. Do this with the JSON option `nsapi.default-stack` set to `LWIP` and `NANOSTACK`.
133134

134-
The driver should also be tested with both network stacks available in Mbed OS, as they use the driver somewhat differently - try with the JSON option `nsapi.default-stack` set to each of `LWIP` and `NANOSTACK`.
135-
136-
137-
Please see the [Network Socket test plan](https://github.com/ARMmbed/mbed-os/blob/master/TESTS/netsocket/README.md) for instructions how to run Mbed OS socket tests.
135+
Please see the [Network Socket test plan](https://github.com/ARMmbed/mbed-os/blob/master/TESTS/netsocket/README.md) for instructions on how to run Mbed OS socket tests.

0 commit comments

Comments
 (0)