Symbian OS Communications (779884), страница 36
Текст из файла (страница 36)
Asthere is no central control over their allocation, it is perfectly feasibleto be using one network, for example WLAN, and have an IP addressof 192.168.1.1, and also be connected to your network operator’s MMSnetwork where you could be given exactly the same IP address! At thispoint an IP stack using a traditional routing table approach would becompletely stuck. Even when the same address is not given to both localinterfaces, there are still problems with deciding where packets shouldgo – which interface do you use for a packet destined for 192.168.1.5,for example? There’s no way to tell, as the routing table is likely to offerboth interfaces as equally good routes – even though the device to whichyou want to connect is reachable on only one of the two networks.Symbian OS solves these multihoming problems by getting applications to declare which interface they want to use, through use ofthe RConnection API, then allowing them to associate their sockets160IP AND RELATED TECHNOLOGIESOperator ‘walledgarden’ servicesThe InternetOperator MMSnetworkInternet-basedweb serverOperator MMSgatewayOperator ‘walledgarden’ web serverFigure 6.2 A typical multihoming scenariowith that connection.
Host resolver connections can also be scoped inthe same way. This means that an application is unaware of other,potentially conflicting, network connections that are active on thedevice, and therefore works as it would if there were only the oneconnection.6.2 IP Networks and Symbian OSAn IP network for a mobile phone can provide many services over anumber of different bearers:• Network operators provide IP-based services on their own networks,for example, MMS, music and video downloads.• Most network operators offer access to the Internet as well as theirown walled garden services.• Ad-hoc networks can be created using local area networking technologies such as Bluetooth, for example, for multi-player gaming.IP NETWORKS AND SYMBIAN OS161• Service providers on the internet may provide their own IP services,for example, Skype.Because of the variety of networks available, you need to give carefulconsideration to which of these different networks are most suitable fortheir application.
Symbian OS aims to make it as easy as possible tosupport any or all of these network technologies by providing commoninterfaces that enable applications to use different bearers and networktypes without being concerned with the details of a specific networktechnology or connection.It is important to remember that devices running Symbian OS are‘mobile’. This means availability of networks may change as the devicemoves geographically – this can occur over large distances, such asgoing to a different country where a different service provider may beused; and over shorter distances, such as travelling on the train, wherethe availability of the GPRS network can vary from minute to minute.Applications need to be able cope with this dynamic behavior.
Thisis an important point to consider when developing for mobile devices,particularly if you are porting an application from another platform whichhas been designed to use a fixed network with a very high availability (aswould be the case for many PC-based applications, for example).This chapter discusses the basics of how to create a network connection, how to use it to enable IP-based services on Symbian OS and whatto consider when creating applications for mobile devices.ESOCKControlDataIP threadCommsDATConfiguration,Connection,Disconnectionetc.TCPNETWORKINTERFACE (NIF)NETWORKINTERFACE (NIF)GPRS/WCDMAGGSNUDPDNSICMPIPWIFIWIFI accesspointNETWORKINTERFACE (NIF)NETWORKINTERFACE (NIF)Circuitswitched callISPBluetoothBluetooth PANaccess pointFigure 6.3 Symbian OS networking subsystem and bearer technologies162IP AND RELATED TECHNOLOGIES6.2.1 Getting StartedOne of the most important concepts to understand for IP-based applications on Symbian OS is the Internet Access Point (IAP).
An IAP is acollection of settings that define how a connection to a particular network is made. These settings are stored in the communications database,CommsDat (discussed in section 6.3.2) – the application itself does notneed to know the parameters required to connect to different networks. Itcan use the system-wide connection preferences, or the application canprovide a specific connection preference.Here are some examples of information stored relating to a specificIAP:• The phone number, for a dial-up ISP.• The access point name (APN), for a GPRS connection.• The SSID of a WLAN access point.These details will be discussed further in section 6.3.2, but the conceptof an IAP is important to understand as it is used throughout the rest of thechapter. An IAP can also be thought of as representing a single networkinterface, and each IAP refers to a single interface.CommsDat is a new component in Symbian OS v9.1, and replacesCommDB which performed the same role in earlier releases.
A compatibility layer exists for clients of CommDB using the C++ API, howeverthere is no longer any support for querying the comms database usingSQL statements.The three most important classes for IP-based applications on SymbianOS are RConnection, RSocket and RHostResolver. These havealready been introduced in Chapter 3 but are discussed with particularreference to IP here.
RConnection was first introduced in SymbianOS v7.0s in order to support multihoming. RConnection allows anapplication to select which IAP to use for its network connection, andto associate its sockets with that connection. This is very importantbecause this ensures that the IP traffic from those sockets is sent to thecorrect network. RConnection also has APIs for gathering informationabout a network connection such as the status, connection informationetc.The RConnection API serves a similar purpose to the RNif andRGenericAgent APIs in v7.0, which were removed in v9.1.NETWORK BEARER TECHNOLOGIES IN SYMBIAN OS163RConnection is discussed in more detail in section 6.3.1.
In practice,an application should consider an RConnection to represent a handleto a network connection. Note, that we said a handle to the connection,not the connection itself. Multiple applications may have handles to thesame network connection.6.2.2 The Default or ‘implicit’ ConnectionEach Symbian OS device has a default network connection configured.This can be used by legacy applications (created before the RConnection API was introduced in Symbian OS v7.0s), or applications usingthe stdlib or PIPS sockets implementations (which are layered on top ofRSocket), which do not use an RConnection – in this case the defaultnetwork connection is started automatically if IP data is sent withoutfirst having connected an IAP explicitly.
This is known as the implicitconnection. The IAP used for the implicit connection is configured inCommsDat as part of the Connection Preferences table (again, discussedin section 6.3.2). UIQ allows the user to configure which IAP is usedfor the default connection as part of the internet account settings on thedevice, and it is presented to the user as the ‘Preferred’ internet account.The user also has an option to decide whether to be prompted to selectan IAP when a connection is requested by an application that does notspecify a connection itself, or whether the default IAP should always beused. For most applications on S60 the user is always prompted to selectthe IAP at connection time.
This allows the user to have control of whichconnections are made for each application. However, it may not alwaysbe appropriate for the user to make this decision since not all applicationswill work on all networks (for example, MMS will only work on thenetwork operator’s MMS network, which is why S60 allow the user tospecify a single IAP for this in the messaging settings). Therefore if yourapplication needs to connect over a specific network it is suggested thatyou provide a configuration option to the user to allow them to specifya network that should always be used.
This gives your application fullcontrol over its choice of network connection.6.3 Network Bearer Technologies in Symbian OSSymbian OS supports the following IP bearer technologies, althoughconfiguration options may not be available for all of these on a given UIplatform:• Packet-switched data connections over GPRS/W-CDMA – providesoperator services such as Internet access, MMS, music and videostreaming.164IP AND RELATED TECHNOLOGIES• Circuit-switched data calls – provides Internet access via dial-up ISPs,access to private networks.• Bluetooth PAN – provides a virtual Ethernet network over Bluetooth.Can be used for multi-player games over ad-hoc local networks.From v9.1 onwards Symbian OS supports the PAN-User (PANU) andGateway Node (GN) roles.